Merge lp:~unity-team/unity/unity.fix-750350 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Mirco Müller
Approved revision: no longer in the source branch.
Merged at revision: 1107
Proposed branch: lp:~unity-team/unity/unity.fix-750350
Merge into: lp:unity
Diff against target: 64 lines (+4/-7)
1 file modified
src/StaticCairoText.cpp (+4/-7)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-750350
Reviewer Review Type Date Requested Status
Sam Spilsbury (community) Approve
Review via email: mp+57094@code.launchpad.net

Description of the change

Width of GetTextExtents() now takes any x- and y-offset into account. Fixes LP: #750350

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Looks good, although if that's an X Y Width Height rect, I'm not sure why dividing x + width by PANGO_SCALE is going to cover all situations though.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/PlacesSimpleTile.cpp'
2=== modified file 'src/StaticCairoText.cpp'
3--- src/StaticCairoText.cpp 2011-04-10 23:58:19 +0000
4+++ src/StaticCairoText.cpp 2011-04-11 00:30:19 +0000
5@@ -310,7 +310,6 @@
6 return;
7 }
8
9-
10 int maxwidth = GetMaximumWidth ();
11
12 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
13@@ -337,7 +336,6 @@
14 else
15 pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
16
17-
18 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
19 pango_layout_set_height (layout, _lines);
20 pango_layout_set_width (layout, maxwidth * PANGO_SCALE);
21@@ -359,8 +357,8 @@
22 pango_layout_context_changed (layout);
23 pango_layout_get_extents (layout, NULL, &logRect);
24
25- width = logRect.width / PANGO_SCALE;
26- height = logRect.height / PANGO_SCALE;
27+ width = (logRect.x + logRect.width) / PANGO_SCALE;
28+ height = (logRect.y + logRect.height) / PANGO_SCALE;
29 _cached_extent_height = height;
30 _cached_extent_width = width;
31
32@@ -369,7 +367,6 @@
33 g_object_unref (layout);
34 cairo_destroy (cr);
35 cairo_surface_destroy (surface);
36-
37 }
38
39 void StaticCairoText::DrawText (cairo_t* cr,
40@@ -393,7 +390,7 @@
41 fontName = g_strdup (_fontstring);
42
43 GetTextExtents (fontName, textWidth, textHeight);
44-
45+
46 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));
47 layout = pango_cairo_create_layout (cr);
48 desc = pango_font_description_from_string (fontName);
49@@ -410,7 +407,6 @@
50 else
51 pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
52
53-
54 if (_align == NUX_ALIGN_LEFT)
55 pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
56 else if (_align == NUX_ALIGN_CENTRE)
57@@ -420,6 +416,7 @@
58
59 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
60 pango_layout_set_width (layout, textWidth * PANGO_SCALE);
61+
62 pango_layout_set_height (layout, _lines);
63 pangoCtx = pango_layout_get_context (layout); // is not ref'ed
64 pango_cairo_context_set_font_options (pangoCtx,