summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-08-12 14:00:25 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-08-14 21:12:37 +0200
commit3836b99f335ac9e6890545607d07124e455eb531 (patch)
tree940d1a707a06441ee30c97c2ec2a4fe1091f58fd /vcl
parent3d0e482df81a28e6d0eb86cda71ac49d3363ae50 (diff)
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 <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx10
1 files changed, 5 insertions, 5 deletions
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);
}