summaryrefslogtreecommitdiffstats
path: root/app/gfx/text_elider.cc
diff options
context:
space:
mode:
Diffstat (limited to 'app/gfx/text_elider.cc')
-rw-r--r--app/gfx/text_elider.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/gfx/text_elider.cc b/app/gfx/text_elider.cc
index dc9b199..3d94813 100644
--- a/app/gfx/text_elider.cc
+++ b/app/gfx/text_elider.cc
@@ -301,6 +301,14 @@ std::wstring ElideText(const std::wstring& text,
return text;
int current_text_pixel_width = font.GetStringWidth(text);
+
+ // Pango will return 0 width for absurdly long strings. Cut the string in
+ // half and try again.
+ if (current_text_pixel_width <= 0 && !text.empty()) {
+ return ElideText(text.substr(0, text.length() / 2), font,
+ available_pixel_width);
+ }
+
if (current_text_pixel_width <= available_pixel_width)
return text;