From 8dc953c590233aba89cc25614c1eab031e17bf19 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 16 Aug 2023 19:04:34 +0100 Subject: [PATCH] Fix: ICU layout: Glyph to char mapping with multiple runs See: https://github.com/OpenTTD/OpenTTD/issues/11203 See: https://github.com/OpenTTD/OpenTTD/issues/10790 --- src/gfx_layout_icu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index 0cc24f4efb..3f3c686264 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -208,7 +208,7 @@ void ICURun::Shape(UChar *buff, size_t buff_length) { x_advance = glyph_pos[i].x_advance / FONT_SCALE; } - this->glyph_to_char.push_back(glyph_info[i].cluster - this->start); + this->glyph_to_char.push_back(glyph_info[i].cluster); this->advance.push_back(x_advance); advance += x_advance; } @@ -467,7 +467,7 @@ std::unique_ptr ICUParagraphLayout::NextLine(int /* There is no suitable line-break and this is the only run on the * line. So we break at the cluster. This is not pretty, but the * best we can do. */ - new_partial_length = char_pos - this->partial_offset; + new_partial_length = char_pos - overflow_run->start - this->partial_offset; } }