Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2525)

Unified Diff: app/gfx/canvas_linux.cc

Issue 512002: Workaround bug in Pango that was resulted in incorrect wrapping.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/gfx/canvas_linux.cc
===================================================================
--- app/gfx/canvas_linux.cc (revision 35152)
+++ app/gfx/canvas_linux.cc (working copy)
@@ -167,6 +167,7 @@
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,17 @@
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.
+ *width = org_width;
+ }
+
g_object_unref(layout);
cairo_destroy(cr);
cairo_surface_destroy(surface);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698