vcl/source/gdi/CommonSalLayout.cxx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
New commits: commit c73f32dd137710ad4c322c45eb00743538dc6149 Author: Khaled Hosny <[email protected]> AuthorDate: Sat Aug 20 15:45:49 2022 +0200 Commit: خالد حسني <[email protected]> CommitDate: Sat Aug 20 16:32:09 2022 +0200 Fix displacement of Arabic combining marks This reverts part of: commit 5e2b7a656024b621bdeeb6efd977331191b66d9d Author: Khaled Hosny <[email protected]> Date: Fri Aug 12 02:12:04 2022 +0200 Streamline Kashida validation logic Reverts an unnecessary change that was supposed to be a harmless simplification. Also add a warning to my future self not to try to do this again. Change-Id: I9213b6d0fb50f13fa98ed97b226f8fa1f3a807dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138588 Tested-by: Jenkins Reviewed-by: خالد حسني <[email protected]> diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 4072a47d7109..73b7e58ae43d 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -716,19 +716,28 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas m_GlyphItems[i].addNewWidth(nDiff); m_GlyphItems[i].adjustLinearPosX(nDelta + nDiff); + // Warning: + // If you are tempted to improve the two loops below, think again. + // Even though I wrote this code, I no longer understand how it + // works, and every time I think I finally got it, I introduce a + // bug. - Khaled + + // Adjust the X position of the rest of the glyphs in the cluster. size_t j = i; while (j > 0) { --j; - if (!(m_GlyphItems[j].IsDiacritic() || m_GlyphItems[j].IsInCluster())) + if (!m_GlyphItems[j].IsInCluster()) break; + m_GlyphItems[j].adjustLinearPosX(nDelta + nDiff); + } - if (m_GlyphItems[j].IsInCluster()) - // Adjust X position of the remainder of the cluster. - m_GlyphItems[j].adjustLinearPosX(nDelta + nDiff); - else - // Move non-spacing marks to keep attached to this cluster. - m_GlyphItems[j].adjustLinearPosX(nDiff); + // Move any non-spacing marks to keep attached to this cluster. + while (j > 0) + { + if (!m_GlyphItems[j].IsDiacritic()) + break; + m_GlyphItems[j--].adjustLinearPosX(nDiff); } // This is a Kashida insertion position, mark it. Kashida glyphs
