Index: ui/gfx/render_text_pango.cc |
diff --git a/ui/gfx/render_text_pango.cc b/ui/gfx/render_text_pango.cc |
index a126926461720aa771db13c3457180a4dae3ec2a..d8ff7f615e9aa22b0ce6dd7db4ffa9066a71641e 100644 |
--- a/ui/gfx/render_text_pango.cc |
+++ b/ui/gfx/render_text_pango.cc |
@@ -82,6 +82,15 @@ Size RenderTextPango::GetStringSize() { |
EnsureLayout(); |
int width = 0, height = 0; |
pango_layout_get_pixel_size(layout_, &width, &height); |
+ |
+ // Pango returns 0 widths for very long strings (of 0x40000 chars or more). |
+ // This is caused by an int overflow in pango_glyph_string_extents_range. |
+ // Absurdly long strings may even report non-zero garbage values for width; |
+ // while detecting that isn't worthwhile, this handles the 0 width cases. |
Alexei Svitkine (slow)
2014/07/03 20:12:33
Did we file a bug against pango for this? iirc Beh
msw
2014/07/08 19:07:36
I'm not sure and can't find any relevant open bugs
Evan Stade
2014/07/08 21:07:19
Unfortunately, my memory lasts exactly 5 years, so
|
+ const long kAbsurdLength = 100000; |
+ if (width == 0 && g_utf8_strlen(layout_text_, -1) > kAbsurdLength) |
+ width = font_list().GetExpectedTextWidth(g_utf8_strlen(layout_text_, -1)); |
+ |
// Keep a consistent height between this particular string's PangoLayout and |
// potentially larger text supported by the FontList. |
// For example, if a text field contains a Japanese character, which is |