vcl/source/gdi/sallayout.cxx | 63 ++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 39 deletions(-)
New commits: commit 67b4d58544865dcc5f0fed5e55cec5967c747dab Author: Jonathan Clark <jonat...@libreoffice.org> AuthorDate: Wed Jun 25 07:59:56 2025 -0600 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Jun 26 19:09:39 2025 +0200 tdf#154104 Fix for overlapping chars in mixed-script fallback runs Fixed a bug inside MultiSalLayout::ImplAdjustMultiLayout() that caused improper position adjustment for single-glyph fallback runs. Change-Id: Ia79b0632b93f0fd06f31134588a4d7b00b825f12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186984 Tested-by: Jenkins Reviewed-by: Jonathan Clark <jonat...@libreoffice.org> (cherry picked from commit 836880d49b5eace490d94a80ab6e7177a4413095) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187059 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 0e4d1473c27d..aa9dca1d6e06 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -908,6 +908,26 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, bool bKeepNotDef = (nFBLevel >= nLevel); for(;;) { + // check for reordered glyphs + // tdf#154104: Moved this up in the loop body to handle the case of single-glyph + // runs that start on a reordered glyph. + if (!rstJustification.empty()) + { + if (vRtl[nActiveCharPos - mnMinCharPos]) + { + if (rstJustification.GetTotalAdvance(nRunVisibleEndChar) + >= rstJustification.GetTotalAdvance(pGlyphs[n]->charPos())) + { + nRunVisibleEndChar = pGlyphs[n]->charPos(); + } + } + else if (rstJustification.GetTotalAdvance(nRunVisibleEndChar) + <= rstJustification.GetTotalAdvance(pGlyphs[n]->charPos())) + { + nRunVisibleEndChar = pGlyphs[n]->charPos(); + } + } + nRunAdvance += pGlyphs[n]->newWidth(); // proceed to next glyph @@ -959,27 +979,6 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, { maFallbackRuns[0].NextRun(); break; } bKeepNotDef = bNeedFallback; } - // check for reordered glyphs - if (!rstJustification.empty() && - nRunVisibleEndChar < mnEndCharPos && - nRunVisibleEndChar >= mnMinCharPos && - pGlyphs[n]->charPos() < mnEndCharPos && - pGlyphs[n]->charPos() >= mnMinCharPos) - { - if (vRtl[nActiveCharPos - mnMinCharPos]) - { - if (rstJustification.GetTotalAdvance(nRunVisibleEndChar) - >= rstJustification.GetTotalAdvance(pGlyphs[n]->charPos())) - { - nRunVisibleEndChar = pGlyphs[n]->charPos(); - } - } - else if (rstJustification.GetTotalAdvance(nRunVisibleEndChar) - <= rstJustification.GetTotalAdvance(pGlyphs[n]->charPos())) - { - nRunVisibleEndChar = pGlyphs[n]->charPos(); - } - } } // if a justification array is available @@ -992,27 +991,13 @@ void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs, nActiveCharIndex = nActiveCharPos - mnMinCharPos; if (nActiveCharIndex >= 0 && vRtl[nActiveCharIndex]) { - if (nRunVisibleEndChar > mnMinCharPos && nRunVisibleEndChar <= mnEndCharPos) - { - nRunAdvance -= rstJustification.GetTotalAdvance(nRunVisibleEndChar - 1); - } - - if (nLastRunEndChar > mnMinCharPos && nLastRunEndChar <= mnEndCharPos) - { - nRunAdvance += rstJustification.GetTotalAdvance(nLastRunEndChar - 1); - } + nRunAdvance -= rstJustification.GetTotalAdvance(nRunVisibleEndChar - 1); + nRunAdvance += rstJustification.GetTotalAdvance(nLastRunEndChar - 1); } else { - if (nRunVisibleEndChar >= mnMinCharPos) - { - nRunAdvance += rstJustification.GetTotalAdvance(nRunVisibleEndChar); - } - - if (nLastRunEndChar >= mnMinCharPos) - { - nRunAdvance -= rstJustification.GetTotalAdvance(nLastRunEndChar); - } + nRunAdvance += rstJustification.GetTotalAdvance(nRunVisibleEndChar); + nRunAdvance -= rstJustification.GetTotalAdvance(nLastRunEndChar); } nLastRunEndChar = nRunVisibleEndChar; nRunVisibleEndChar = pGlyphs[nFirstValid]->charPos();