From 3836b99f335ac9e6890545607d07124e455eb531 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 12 Aug 2022 14:00:25 +0200 Subject: Use doubles when calculating the number of Kashidas to insert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- vcl/source/gdi/CommonSalLayout.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'vcl') 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); } -- cgit