include/vcl/outdev.hxx | 2 +- vcl/source/outdev/textline.cxx | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-)
New commits: commit 5899b27e71430e490c2d3a6b87ae52c10f383ba7 Author: Khaled Hosny <kha...@aliftype.com> AuthorDate: Wed Feb 22 19:45:51 2023 +0200 Commit: خالد حسني <kha...@aliftype.com> CommitDate: Wed Feb 22 21:10:19 2023 +0000 tdf#151968: Fix vertical position of RTL spelling wavy line The code was guessing orientation based on the start and end points and mistakenly considered Arabic text to be 180° rotated which ended up raising the wavy line above baseline and covering the RTL text. Use font orientation instead of guessing it. Caching wavy line seems broken with RTL text as well (it was skipped for RTL before because of the wrong guessed orientation, so probably never worked), so we skip it explicitly as well for now. Change-Id: I4b0f5c4d6be2c6e3d33ea79b917b14927374acfa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147488 Tested-by: Jenkins Reviewed-by: خالد حسني <kha...@aliftype.com> diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index d550ecfce293..4075f28abf99 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -758,7 +758,7 @@ private: SAL_DLLPRIVATE void ImplDrawPolyPolygonWithB2DPolyPolygon(const basegfx::B2DPolyPolygon& rB2DPolyPoly); ///@} - SAL_DLLPRIVATE void ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double fOrientation, tools::Long nLineWidth); + SAL_DLLPRIVATE void ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, Degree10 nOrientation, tools::Long nLineWidth); /** @name Curved shape functions diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 3bd69a2ec994..03f6019dc2b3 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -1012,14 +1012,13 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to tools::Long nStartY = aStartPt.Y(); tools::Long nEndX = aEndPt.X(); tools::Long nEndY = aEndPt.Y(); - double fOrientation = 0.0; + auto nOrientation = mpFontInstance->mnOrientation; // handle rotation - if (nStartY != nEndY || nStartX > nEndX) + if (nOrientation) { - fOrientation = basegfx::rad2deg(std::atan2(nStartY - nEndY, nEndX - nStartX)); // un-rotate the end point - aStartPt.RotateAround(nEndX, nEndY, Degree10(static_cast<sal_Int16>(-fOrientation * 10.0))); + aStartPt.RotateAround(nEndX, nEndY, nOrientation); } // Handle HiDPI @@ -1046,7 +1045,9 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to nLineWidth = 0; } - if ( fOrientation == 0.0 ) + // The code below does not work for RTL text, that is what nEndX > nStartX + // check is for. + if ( nOrientation == 0_deg10 && nEndX > nStartX ) { static vcl::DeleteOnDeinit< WavyLineCache > snLineCache {}; if ( !snLineCache.get() ) @@ -1064,7 +1065,7 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to pVirtDev->SetBackground( Wallpaper( COL_TRANSPARENT ) ); pVirtDev->Erase(); pVirtDev->SetAntialiasing( AntialiasingFlags::Enable ); - pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, nWaveHeight, fOrientation, nLineWidth ); + pVirtDev->ImplDrawWaveLineBezier( 0, 0, nWordLength, 0, nWaveHeight, nOrientation, nLineWidth ); BitmapEx aBitmapEx(pVirtDev->GetBitmapEx(Point(0, 0), pVirtDev->GetOutputSize())); // Ideally we don't need this block, but in the split rgb surface + separate alpha surface @@ -1085,10 +1086,10 @@ void OutputDevice::DrawWaveLine(const Point& rStartPos, const Point& rEndPos, to return; } - ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, fOrientation, nLineWidth ); + ImplDrawWaveLineBezier( nStartX, nStartY, nEndX, nEndY, nWaveHeight, nOrientation, nLineWidth ); } -void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, double fOrientation, tools::Long nLineWidth) +void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStartY, tools::Long nEndX, tools::Long nEndY, tools::Long nWaveHeight, Degree10 nOrientation, tools::Long nLineWidth) { // we need a graphics if( !mpGraphics && !AcquireGraphics() ) @@ -1106,7 +1107,7 @@ void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStar const basegfx::B2DRectangle aWaveLineRectangle(nStartX, nStartY, nEndX, nEndY + nWaveHeight); const basegfx::B2DPolygon aWaveLinePolygon = basegfx::createWaveLinePolygon(aWaveLineRectangle); - const basegfx::B2DHomMatrix aRotationMatrix = basegfx::utils::createRotateAroundPoint(nStartX, nStartY, basegfx::deg2rad(-fOrientation)); + const basegfx::B2DHomMatrix aRotationMatrix = basegfx::utils::createRotateAroundPoint(nStartX, nStartY, toRadians(nOrientation)); const bool bPixelSnapHairline(mnAntialiasing & AntialiasingFlags::PixelSnapHairline); mpGraphics->SetLineColor(GetLineColor()); @@ -1123,7 +1124,7 @@ void OutputDevice::ImplDrawWaveLineBezier(tools::Long nStartX, tools::Long nStar *this); if( mpAlphaVDev ) - mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, nWaveHeight, fOrientation, nLineWidth); + mpAlphaVDev->ImplDrawWaveLineBezier(nStartX, nStartY, nEndX, nEndY, nWaveHeight, nOrientation, nLineWidth); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */