diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-01-25 15:35:43 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-01-25 19:24:18 +0000 |
commit | 9d60497954ed25bd802e66b5de0f375b301c79eb (patch) | |
tree | a99e2b73b5e3d901991be8a0e67d63869acd103b /drawinglayer/source | |
parent | 4e0858dd9e1b4831eb117640d5d42f7e1e92fdb8 (diff) |
tdf#153092 text appears missing with font sizes < 1
where the size is scaled up, so restore use of scaling up when necessary.
But continue to use unscaled supplied values when provided integer sizes
to avoid scaling down.
Change-Id: I8de268d1c9ac8f0a75aa84e231812b12310db76a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146140
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'drawinglayer/source')
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 85 |
1 files changed, 60 insertions, 25 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 8bd9abadf15c..4563d30c518f 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -160,10 +160,24 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( rTextCandidate.getTextTransform().decompose(aFontSize, aTextTranslate, fIgnoreRotate, fIgnoreShearX); + // tdf#153092 Ideally we don't have to scale the font and dxarray, but we might have + // to nevertheless if dealing with non integer sizes + const bool bScaleFont(aFontSize.getY() != std::round(aFontSize.getY())); + vcl::Font aFont; + // Get the VCL font - vcl::Font aFont(primitive2d::getVclFontFromFontAttribute( - rTextCandidate.getFontAttribute(), aFontSize.getX(), aFontSize.getY(), fRotate, - rTextCandidate.getLocale())); + if (!bScaleFont) + { + aFont = primitive2d::getVclFontFromFontAttribute( + rTextCandidate.getFontAttribute(), aFontSize.getX(), aFontSize.getY(), fRotate, + rTextCandidate.getLocale()); + } + else + { + aFont = primitive2d::getVclFontFromFontAttribute( + rTextCandidate.getFontAttribute(), aFontScaling.getX(), aFontScaling.getY(), + fRotate, rTextCandidate.getLocale()); + } // Don't draw fonts without height if (aFont.GetFontHeight() <= 0) @@ -287,9 +301,17 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( if (!rTextCandidate.getDXArray().empty()) { + double fPixelVectorFactor(1.0); + if (bScaleFont) + { + const basegfx::B2DVector aPixelVector(maCurrentTransformation + * basegfx::B2DVector(1.0, 0.0)); + fPixelVectorFactor = aPixelVector.getLength(); + } + aDXArray.reserve(rTextCandidate.getDXArray().size()); for (auto const& elem : rTextCandidate.getDXArray()) - aDXArray.push_back(basegfx::fround(elem)); + aDXArray.push_back(basegfx::fround(elem * fPixelVectorFactor)); } // set parameters and paint text snippet @@ -339,28 +361,41 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( } } - basegfx::B2DHomMatrix aCombinedTransform( - getTransformFromMapMode(mpOutputDevice->GetMapMode()) * maCurrentTransformation); - - basegfx::B2DVector aCurrentScaling, aCurrentTranslate; - double fCurrentRotate; - aCombinedTransform.decompose(aCurrentScaling, aCurrentTranslate, fCurrentRotate, - fIgnoreShearX); - - const Point aOrigin(basegfx::fround(aCurrentTranslate.getX() / aCurrentScaling.getX()), - basegfx::fround(aCurrentTranslate.getY() / aCurrentScaling.getY())); - MapMode aMapMode(mpOutputDevice->GetMapMode().GetMapUnit(), aOrigin, - Fraction(aCurrentScaling.getX()), Fraction(aCurrentScaling.getY())); - - if (fCurrentRotate) - aTextTranslate *= basegfx::utils::createRotateB2DHomMatrix(fCurrentRotate); - const Point aStartPoint(aTextTranslate.getX(), aTextTranslate.getY()); - - const bool bChangeMapMode(aMapMode != mpOutputDevice->GetMapMode()); - if (bChangeMapMode) + Point aStartPoint; + bool bChangeMapMode(false); + if (!bScaleFont) + { + basegfx::B2DHomMatrix aCombinedTransform( + getTransformFromMapMode(mpOutputDevice->GetMapMode()) + * maCurrentTransformation); + + basegfx::B2DVector aCurrentScaling, aCurrentTranslate; + double fCurrentRotate; + aCombinedTransform.decompose(aCurrentScaling, aCurrentTranslate, fCurrentRotate, + fIgnoreShearX); + + const Point aOrigin( + basegfx::fround(aCurrentTranslate.getX() / aCurrentScaling.getX()), + basegfx::fround(aCurrentTranslate.getY() / aCurrentScaling.getY())); + MapMode aMapMode(mpOutputDevice->GetMapMode().GetMapUnit(), aOrigin, + Fraction(aCurrentScaling.getX()), + Fraction(aCurrentScaling.getY())); + + if (fCurrentRotate) + aTextTranslate *= basegfx::utils::createRotateB2DHomMatrix(fCurrentRotate); + aStartPoint = Point(aTextTranslate.getX(), aTextTranslate.getY()); + + bChangeMapMode = aMapMode != mpOutputDevice->GetMapMode(); + if (bChangeMapMode) + { + mpOutputDevice->Push(vcl::PushFlags::MAPMODE); + mpOutputDevice->SetMapMode(aMapMode); + } + } + else { - mpOutputDevice->Push(vcl::PushFlags::MAPMODE); - mpOutputDevice->SetMapMode(aMapMode); + const basegfx::B2DPoint aPoint(aLocalTransform * basegfx::B2DPoint(0.0, 0.0)); + aStartPoint = Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())); } // tdf#152990 set the font after the MapMode is (potentially) set so canvas uses the desired |