summaryrefslogtreecommitdiffstats
path: root/app/gfx
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 23:21:11 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-04 23:21:11 +0000
commit4bfc560b5779536c900fb20844dde6e68d45e0ab (patch)
tree901306de7f7d3571d6ffa8be22eb63e5dab82d22 /app/gfx
parent0b28f3b07cf243d582fcc2ed4a59dceb3e3378ce (diff)
downloadchromium_src-4bfc560b5779536c900fb20844dde6e68d45e0ab.zip
chromium_src-4bfc560b5779536c900fb20844dde6e68d45e0ab.tar.gz
chromium_src-4bfc560b5779536c900fb20844dde6e68d45e0ab.tar.bz2
Workaround bug in Pango that was resulted in incorrect wrapping.
BUG=30361 TEST=see bug Review URL: http://codereview.chromium.org/512002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx')
-rwxr-xr-xapp/gfx/canvas_linux.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/gfx/canvas_linux.cc b/app/gfx/canvas_linux.cc
index 2e213e5..2b427a8 100755
--- a/app/gfx/canvas_linux.cc
+++ b/app/gfx/canvas_linux.cc
@@ -167,6 +167,7 @@ static void SetupPangoLayout(PangoLayout* layout,
void Canvas::SizeStringInt(const std::wstring& text,
const gfx::Font& font,
int* width, int* height, int flags) {
+ int org_width = *width;
cairo_surface_t* surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 0, 0);
cairo_t* cr = cairo_create(surface);
@@ -179,6 +180,22 @@ void Canvas::SizeStringInt(const std::wstring& text,
pango_layout_get_pixel_size(layout, width, height);
+ if (org_width > 0 && flags & Canvas::MULTI_LINE &&
+ pango_layout_is_wrapped(layout)) {
+ // The text wrapped. There seems to be a bug in Pango when this happens
+ // such that the width returned from pango_layout_get_pixel_size is too
+ // small. Using the width from pango_layout_get_pixel_size in this case
+ // results in wrapping across more lines, which requires a bigger height.
+ // As a workaround we use the original width, which is not necessarily
+ // exactly correct, but isn't wrong by much.
+ //
+ // It looks like Pango uses the size of whitespace in calculating wrapping
+ // but doesn't include the size of the whitespace when the extents are
+ // asked for. See the loop in pango-layout.c process_item that determines
+ // where to wrap.
+ *width = org_width;
+ }
+
g_object_unref(layout);
cairo_destroy(cr);
cairo_surface_destroy(surface);