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
=== modified file 'src/PlacesSimpleTile.cpp'
=== modified file 'src/StaticCairoText.cpp'
--- src/StaticCairoText.cpp 2011-04-10 23:58:19 +0000
+++ src/StaticCairoText.cpp 2011-04-11 00:30:19 +0000
@@ -310,7 +310,6 @@
310 return;310 return;
311 }311 }
312312
313
314 int maxwidth = GetMaximumWidth ();313 int maxwidth = GetMaximumWidth ();
315314
316 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);315 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
@@ -337,7 +336,6 @@
337 else336 else
338 pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);337 pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
339338
340
341 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);339 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
342 pango_layout_set_height (layout, _lines);340 pango_layout_set_height (layout, _lines);
343 pango_layout_set_width (layout, maxwidth * PANGO_SCALE);341 pango_layout_set_width (layout, maxwidth * PANGO_SCALE);
@@ -359,8 +357,8 @@
359 pango_layout_context_changed (layout);357 pango_layout_context_changed (layout);
360 pango_layout_get_extents (layout, NULL, &logRect);358 pango_layout_get_extents (layout, NULL, &logRect);
361359
362 width = logRect.width / PANGO_SCALE;360 width = (logRect.x + logRect.width) / PANGO_SCALE;
363 height = logRect.height / PANGO_SCALE;361 height = (logRect.y + logRect.height) / PANGO_SCALE;
364 _cached_extent_height = height;362 _cached_extent_height = height;
365 _cached_extent_width = width;363 _cached_extent_width = width;
366364
@@ -369,7 +367,6 @@
369 g_object_unref (layout);367 g_object_unref (layout);
370 cairo_destroy (cr);368 cairo_destroy (cr);
371 cairo_surface_destroy (surface);369 cairo_surface_destroy (surface);
372
373}370}
374371
375void StaticCairoText::DrawText (cairo_t* cr,372void StaticCairoText::DrawText (cairo_t* cr,
@@ -393,7 +390,7 @@
393 fontName = g_strdup (_fontstring);390 fontName = g_strdup (_fontstring);
394391
395 GetTextExtents (fontName, textWidth, textHeight);392 GetTextExtents (fontName, textWidth, textHeight);
396393
397 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));394 cairo_set_font_options (cr, gdk_screen_get_font_options (screen));
398 layout = pango_cairo_create_layout (cr);395 layout = pango_cairo_create_layout (cr);
399 desc = pango_font_description_from_string (fontName);396 desc = pango_font_description_from_string (fontName);
@@ -410,7 +407,6 @@
410 else407 else
411 pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);408 pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_NONE);
412409
413
414 if (_align == NUX_ALIGN_LEFT)410 if (_align == NUX_ALIGN_LEFT)
415 pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);411 pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
416 else if (_align == NUX_ALIGN_CENTRE)412 else if (_align == NUX_ALIGN_CENTRE)
@@ -420,6 +416,7 @@
420416
421 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);417 pango_layout_set_markup (layout, _text.GetTCharPtr(), -1);
422 pango_layout_set_width (layout, textWidth * PANGO_SCALE);418 pango_layout_set_width (layout, textWidth * PANGO_SCALE);
419
423 pango_layout_set_height (layout, _lines);420 pango_layout_set_height (layout, _lines);
424 pangoCtx = pango_layout_get_context (layout); // is not ref'ed421 pangoCtx = pango_layout_get_context (layout); // is not ref'ed
425 pango_cairo_context_set_font_options (pangoCtx,422 pango_cairo_context_set_font_options (pangoCtx,