From cea2e5d13f262270631175e273f739631da9b12c Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Fri, 17 Jul 2020 21:37:46 +0200 Subject: [PATCH] Only show tag in chart if utf8 character width is within the width - Closes #309 Signed-off-by: Thomas Lauf --- src/Chart.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Chart.cpp b/src/Chart.cpp index b6b2830f..1a061078 100644 --- a/src/Chart.cpp +++ b/src/Chart.cpp @@ -35,6 +35,7 @@ #include #include #include +#include //////////////////////////////////////////////////////////////////////////////// Chart::Chart (const ChartConfig& configuration) : @@ -493,7 +494,23 @@ void Chart::renderInterval ( if (width) { std::vector text_lines; - wrapText (text_lines, label, width, false); + + // -- + // The hang/memory consumption in #309 is due to a bug in libshared's wrapText + // It would be best to make wrapText/extractText width be the count of characters on the screen (and not a byte width). + // This fix will only show the tag if the utf8 character width is within the width (and it won't try to wrap), + // but otherwise functions normally for text where the utf-8 width matches the byte length of the label. + // + size_t utf8_characters = utf8_text_width (label); + if (static_cast (width) >= utf8_characters) + { + text_lines.push_back (label); + } + else if (utf8_characters == label.size ()) + { + wrapText (text_lines, label, width, false); + } + // -- for (unsigned int i = 0; i < lines.size (); ++i) {