summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2016-11-11 18:24:11 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2016-11-11 18:26:20 +0200
commitc49d5dea164b09b05a898495fa2dd48b7ca4f0e4 (patch)
treee1cbefa026dd3e21023108a1ae8cfe851aa80b3c
parentd34572d39db1f94932fba492bb2a47f0237217b4 (diff)
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
-rw-r--r--vcl/source/gdi/CommonSalLayout.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx
index c402bed9cd87..047f845ba27d 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -553,19 +553,22 @@ bool CommonSalLayout::LayoutText(ImplLayoutArgs& rArgs)
if (aSubRun.maDirection == HB_DIRECTION_TTB)
{
nGlyphIndex |= GF_ROTL;
- nAdvance = -pHbPositions[i].y_advance * nYScale;
- nXOffset = pHbPositions[i].y_offset * nYScale;
- nYOffset = -pHbPositions[i].x_offset * nXScale;
+ nAdvance = -pHbPositions[i].y_advance;
+ nXOffset = pHbPositions[i].y_offset;
+ nYOffset = pHbPositions[i].x_offset;
}
else
{
- nAdvance = pHbPositions[i].x_advance * nXScale;
- nXOffset = pHbPositions[i].x_offset * nXScale;
- nYOffset = pHbPositions[i].y_offset * nYScale;
+ nAdvance = pHbPositions[i].x_advance;
+ nXOffset = pHbPositions[i].x_offset;
+ nYOffset = -pHbPositions[i].y_offset;
}
- Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset));
- const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nAdvance, nXOffset);
+ Point aNewPos(lround((aCurrPos.X() + nXOffset) * nXScale),
+ lround((aCurrPos.Y() + nYOffset) * nYScale));
+ const GlyphItem aGI(nCharPos, nGlyphIndex, aNewPos, nGlyphFlags,
+ lround(nAdvance * nXScale),
+ lround(nXOffset * nXScale));
AppendGlyph(aGI);
aCurrPos.X() += nAdvance;