summaryrefslogtreecommitdiff
path: root/vcl/source/outdev/font.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2024-03-29 20:15:06 +0500
committerMike Kaganski <mike.kaganski@collabora.com>2024-04-01 13:05:56 +0200
commit8962141a12c966b2d891829925e6203bf8d51852 (patch)
tree9b56088816775fb7907f5fb9c2c91f63998571d8 /vcl/source/outdev/font.cxx
parent7c18a0bb37fc2cd50bd3fa4386b02d88fbedb773 (diff)
tdf#160430: Fix glyph bounds calculation, and use basegfx::B2DRectangle
... instead of tools::Rectangle. Several problems were there: 1. First, a horizontal bounding rectangle was calculated, with due rounding; and then the result was rotated, and after that, rounded again. That made the resulting rotated rectangle coordinates very imprecise. 2. Also, ceil/floor was applied without normalization; and in case of rotated font, that meant, that sometimes the range could be not expanded to cover partially covered pixels, but instead collapsed. 3. The rotation to angles other than 90 degree multiples was done incorrectly, resulting in cut off parts of characters. 4. For 90 degrees, the imprecise result of sin/cos converted 0.0 into values like 3e-16, which then could be ceil'ed up to 1. Using B2DRectangle and its transform allows to simplify and fix the calculations easily, and avoids premature rounding. Render of rotated text of small size is more stable with this change. Change-Id: Idffd74b9937feb2418ab76a8d325fdaf4ff841b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165553 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'vcl/source/outdev/font.cxx')
-rw-r--r--vcl/source/outdev/font.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 0b87c8ef8418..9416963b93b6 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -948,7 +948,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
aOffset += Point( nEmphasisWidth2, nEmphasisHeight2 );
basegfx::B2DPoint aOutPoint;
- tools::Rectangle aRectangle;
+ basegfx::B2DRectangle aRectangle;
const GlyphItem* pGlyph;
const LogicalFontInstance* pGlyphFont;
int nStart = 0;
@@ -968,7 +968,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout )
else
{
aAdjPoint = aOffset;
- aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 );
+ aAdjPoint.AdjustX(aRectangle.getMinX() + (aRectangle.getWidth() - aEmphasisMark.GetWidth()) / 2 );
}
if ( mpFontInstance->mnOrientation )