summaryrefslogtreecommitdiff
path: root/src/images/renderedText.vala
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-03-19 16:35:31 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-03-19 16:35:31 +0100
commit29a84e1125d507fcaf5d0cb39148ccaaa2d7ae58 (patch)
tree7d1c8e1c1b1d89af3a962671f60a422aa62af890 /src/images/renderedText.vala
parent178b4f90e26d6240aeaf5e455e4e78b3f4883bba (diff)
parenta248b1597394b4ee9a5817bc95c3c116e76cdd8f (diff)
Merge tag 'upstream/0.5.2'
Upstream version 0.5.2
Diffstat (limited to 'src/images/renderedText.vala')
-rw-r--r--src/images/renderedText.vala18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/images/renderedText.vala b/src/images/renderedText.vala
index e99d26a..544af1f 100644
--- a/src/images/renderedText.vala
+++ b/src/images/renderedText.vala
@@ -71,21 +71,29 @@ public class RenderedText : Image {
// add newlines at the end of each line, in order to allow ellipsizing
string broken_string = "";
- var lines = layout.get_lines().copy();
- foreach (var line in lines) {
+ for (int i=0; i<layout.get_line_count(); ++i) {
- string next_line = text.substring(line.start_index, line.length);
+ string next_line = "";
+ if (i == layout.get_line_count() -1)
+ next_line = text.substring(layout.get_line(i).start_index, -1);
+ else
+ next_line = text.substring(layout.get_line(i).start_index, layout.get_line(i).length);
if (broken_string == "") {
broken_string = next_line;
} else if (next_line != "") {
// test whether the addition of a line would cause the height to become too large
string broken_string_tmp = broken_string + "\n" + next_line;
+
+ var layout_tmp = Pango.cairo_create_layout(ctx);
+ layout_tmp.set_width(Pango.units_from_double(width));
+
+ layout_tmp.set_font_description(font_description);
- layout.set_text(broken_string_tmp, -1);
+ layout_tmp.set_text(broken_string_tmp, -1);
Pango.Rectangle extents;
- layout.get_pixel_extents(null, out extents);
+ layout_tmp.get_pixel_extents(null, out extents);
if (extents.height > height) broken_string = broken_string + next_line;
else broken_string = broken_string_tmp;