vcl/source/gdi/CommonSalLayout.cxx |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 3836b99f335ac9e6890545607d07124e455eb531
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Fri Aug 12 14:00:25 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Aug 14 21:12:37 2022 +0200

    Use doubles when calculating the number of Kashidas to insert
    
    Makes it a bit more stable across zoom levels and avoids excessive
    overlaps due to calculating one copy too many because of rounding
    errors.
    
    Change-Id: I6a21a89c1dfda085b1f7fa9570c9875a0d39f671
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138192
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0bea121896b4..eff9dab9acbb 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -754,7 +754,7 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, 
const sal_Bool* pKashida
         return;
 
     // Find Kashida glyph width and index.
-    DeviceCoordinate nKashidaWidth = 0;
+    double nKashidaWidth = 0;
     hb_codepoint_t nKashidaIndex = 0;
     if (hb_font_get_glyph(GetFont().GetHbFont(), 0x0640, 0, &nKashidaIndex))
         nKashidaWidth = GetFont().GetKashidaWidth();
@@ -771,7 +771,7 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, 
const sal_Bool* pKashida
         auto pGlyphIter = m_GlyphItems.begin() + nInserted + pKashida.first;
 
         // The total Kashida width.
-        DeviceCoordinate nTotalWidth = pKashida.second;
+        double nTotalWidth = pKashida.second;
 
         // Number of times to repeat each Kashida.
         int nCopies = 1;
@@ -780,12 +780,12 @@ void GenericSalLayout::ApplyDXArray(const DC* pDXArray, 
const sal_Bool* pKashida
 
         // See if we can improve the fit by adding an extra Kashidas and
         // squeezing them together a bit.
-        DeviceCoordinate nOverlap = 0;
-        DeviceCoordinate nShortfall = nTotalWidth - nKashidaWidth * nCopies;
+        double nOverlap = 0;
+        double nShortfall = nTotalWidth - nKashidaWidth * nCopies;
         if (nShortfall > 0)
         {
             ++nCopies;
-            DeviceCoordinate nExcess = nCopies * nKashidaWidth - nTotalWidth;
+            double nExcess = nCopies * nKashidaWidth - nTotalWidth;
             if (nExcess > 0)
                 nOverlap = nExcess / (nCopies - 1);
         }

Reply via email to