tdf#103765: Minimize the effect of rounding to int

Instead of scaling the relative coordinates and accumulating rounding
errors, scale the absolute coordinates. Also round to int instead of
truncating.

Change-Id: Ida0b4092685e898b7c5b5c07e923e386ffde8bcd
This commit is contained in:
Khaled Hosny
2016-11-11 18:24:11 +02:00
parent d34572d39d
commit c49d5dea16

View File

@@ -553,19 +553,22 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
if (aSubRun.maDirection == HB_DIRECTION_TTB) if (aSubRun.maDirection == HB_DIRECTION_TTB)
{ {
nGlyphIndex |= GF_ROTL; nGlyphIndex |= GF_ROTL;
nAdvance = -pHbPositions[i].y_advance * nYScale; nAdvance = -pHbPositions[i].y_advance;
nXOffset = pHbPositions[i].y_offset * nYScale; nXOffset = pHbPositions[i].y_offset;
nYOffset = -pHbPositions[i].x_offset * nXScale; nYOffset = pHbPositions[i].x_offset;
} }
else else
{ {
nAdvance = pHbPositions[i].x_advance * nXScale; nAdvance = pHbPositions[i].x_advance;
nXOffset = pHbPositions[i].x_offset * nXScale; nXOffset = pHbPositions[i].x_offset;
nYOffset = pHbPositions[i].y_offset * nYScale; nYOffset = -pHbPositions[i].y_offset;
} }
Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset)); Point aNewPos(lround((aCurrPos.X() + nXOffset) * nXScale),
const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nAdvance, nXOffset); lround((aCurrPos.Y() + nYOffset) * nYScale));
const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags,
lround(nAdvance * nXScale),
lround(nXOffset * nXScale));
AppendGlyph(aGI); AppendGlyph(aGI);
aCurrPos.X() += nAdvance; aCurrPos.X() += nAdvance;