tdf#152734: Calculate correctly the kashida glyph X position
Change-Id: I4c76aed58acd0598b9d09d147ed86e76ef468c4f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144878
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index 5cde002..92b09022 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -727,7 +727,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas
// Map of Kashida insertion points (in the glyph items vector) and the
// requested width.
std::map<size_t, DeviceCoordinate> pKashidas;
std::map<size_t, std::pair<DeviceCoordinate, DeviceCoordinate>> pKashidas;
// The accumulated difference in X position.
double nDelta = 0;
@@ -791,7 +791,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas
// This is a Kashida insertion position, mark it. Kashida glyphs
// will be inserted below.
if (pKashidaArray && pKashidaArray[nCharPos])
pKashidas[i] = nDiff;
pKashidas[i] = { nDiff, pNewCharWidths[nCharPos] };
i++;
}
@@ -823,7 +823,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas
auto pGlyphIter = m_GlyphItems.begin() + nInserted + pKashida.first;
// The total Kashida width.
double nTotalWidth = pKashida.second;
auto const& [nTotalWidth, nClusterWidth] = pKashida.second;
// Number of times to repeat each Kashida.
int nCopies = 1;
@@ -842,9 +842,12 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, const sal_Bool* pKas
nOverlap = nExcess / (nCopies - 1);
}
DevicePoint aPos(pGlyphIter->linearPos().getX() - nTotalWidth, 0);
DevicePoint aPos = pGlyphIter->linearPos();
int nCharPos = pGlyphIter->charPos();
GlyphItemFlags const nFlags = GlyphItemFlags::IS_IN_CLUSTER | GlyphItemFlags::IS_RTL_GLYPH;
// Move to the left side of the adjusted width and start inserting
// glyphs there.
aPos.adjustX(-nClusterWidth + pGlyphIter->origWidth());
while (nCopies--)
{
GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, nKashidaWidth, 0, 0);