diff options
author | Khaled Hosny <khaled@aliftype.com> | 2023-02-22 19:45:51 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2023-02-24 09:12:15 +0000 |
commit | 6327fdc149edab1eedabe5b0d4dde6bcf08a113e (patch) | |
tree | e4731e647992ec7fc4b54e301b3ebcf972c3250a /vcl | |
parent | 09d6e6c81633eef6eaecf011dc766cdc68e52fd7 (diff) |
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: خالد حسني <khaled@aliftype.com>
(cherry picked from commit 5899b27e71430e490c2d3a6b87ae52c10f383ba7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147441
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/outdev/textline.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/vcl/source/outdev/textline.cxx b/vcl/source/outdev/textline.cxx index 7c0f2f55d7ce..f88861d4c2f9 100644 --- a/vcl/source/outdev/textline.cxx +++ b/vcl/source/outdev/textline.cxx @@ -996,14 +996,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 @@ -1030,7 +1029,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() ) @@ -1049,7 +1050,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 @@ -1070,10 +1071,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() ) @@ -1091,7 +1092,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()); @@ -1108,7 +1109,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: */ |