1
0
Fork 0

Fix: ICUParagraphLayout line wrapping (#12956)

In the case where the overflow run is not the start run,
and the start run had a partial offset
pull/12958/head
Jonathan G Rennison 2024-09-21 22:14:41 +01:00 committed by GitHub
parent 16b4e737a3
commit a7d405b02d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -461,9 +461,11 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
/* See if there is a good breakpoint inside this run. */ /* See if there is a good breakpoint inside this run. */
int32_t break_pos = break_iterator->preceding(char_pos + 1); int32_t break_pos = break_iterator->preceding(char_pos + 1);
if (break_pos != icu::BreakIterator::DONE && break_pos > overflow_run->start + this->partial_offset) { auto overflow_run_start = overflow_run->start;
if (overflow_run == start_run) overflow_run_start += this->partial_offset;
if (break_pos != icu::BreakIterator::DONE && break_pos > overflow_run_start) {
/* There is a line-break inside this run that is suitable. */ /* There is a line-break inside this run that is suitable. */
new_partial_length = break_pos - overflow_run->start - this->partial_offset; new_partial_length = break_pos - overflow_run_start;
} else if (overflow_run != start_run) { } else if (overflow_run != start_run) {
/* There is no suitable line-break in this run, but it is also not /* There is no suitable line-break in this run, but it is also not
* the only run on this line. So we remove the run. */ * the only run on this line. So we remove the run. */
@ -472,7 +474,7 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
/* There is no suitable line-break and this is the only run on the /* 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 * line. So we break at the cluster. This is not pretty, but the
* best we can do. */ * best we can do. */
new_partial_length = char_pos - overflow_run->start - this->partial_offset; new_partial_length = char_pos - overflow_run_start;
} }
} }
@ -520,6 +522,7 @@ std::unique_ptr<const ICUParagraphLayout::Line> ICUParagraphLayout::NextLine(int
if (new_partial_length > 0) { if (new_partial_length > 0) {
this->current_run = last_run - 1; this->current_run = last_run - 1;
if (this->current_run != start_run) this->partial_offset = 0;
this->partial_offset += new_partial_length; this->partial_offset += new_partial_length;
} else { } else {
this->current_run = last_run; this->current_run = last_run;