include/vcl/vcllayout.hxx | 7 +++++++ vcl/source/gdi/sallayout.cxx | 18 ++++++++++++++---- vcl/source/outdev/text.cxx | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit 99460be87a11a404ce6c055fc540ec7ece404fb6 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Sun Jan 16 17:24:08 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sun Jan 16 20:22:22 2022 +0100 Related: tdf#146453 retain accurate positioning in rotated text rendering Change-Id: I477c5a72dd9618a2b0f3e91a96209ae3f6b3d1aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128484 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx index b766a0b4ccd6..87d9345f4b9b 100644 --- a/include/vcl/vcllayout.hxx +++ b/include/vcl/vcllayout.hxx @@ -82,6 +82,11 @@ public: int GetUnitsPerPixel() const { return mnUnitsPerPixel; } Degree10 GetOrientation() const { return mnOrientation; } + void SetTextRenderModeForResolutionIndependentLayout(bool bTextRenderModeForResolutionIndependentLayout) + { + mbTextRenderModeForResolutionIndependentLayout = bTextRenderModeForResolutionIndependentLayout; + } + // methods using string indexing virtual sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const = 0; virtual DeviceCoordinate FillDXArray( std::vector<DeviceCoordinate>* pDXArray ) const = 0; @@ -115,6 +120,8 @@ protected: mutable Point maDrawOffset; DevicePoint maDrawBase; + + bool mbTextRenderModeForResolutionIndependentLayout; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 64b1d22480e5..be020c2f11ae 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -135,7 +135,8 @@ SalLayout::SalLayout() mnEndCharPos( -1 ), mnUnitsPerPixel( 1 ), mnOrientation( 0 ), - maDrawOffset( 0, 0 ) + maDrawOffset( 0, 0 ), + mbTextRenderModeForResolutionIndependentLayout(false) {} SalLayout::~SalLayout() @@ -171,9 +172,18 @@ DevicePoint SalLayout::GetDrawPosition(const DevicePoint& rRelative) const double fX = aOfs.getX(); double fY = aOfs.getY(); - tools::Long nX = static_cast<tools::Long>( +fCos * fX + fSin * fY ); - tools::Long nY = static_cast<tools::Long>( +fCos * fY - fSin * fX ); - aPos += DevicePoint(nX, nY); + if (mbTextRenderModeForResolutionIndependentLayout) + { + double nX = +fCos * fX + fSin * fY; + double nY = +fCos * fY - fSin * fX; + aPos += DevicePoint(nX, nY); + } + else + { + tools::Long nX = static_cast<tools::Long>( +fCos * fX + fSin * fY ); + tools::Long nY = static_cast<tools::Long>( +fCos * fY - fSin * fX ); + aPos += DevicePoint(nX, nY); + } } return aPos; diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index f9f0fd54b673..49ca790b8aec 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1411,6 +1411,8 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr, if( !pSalLayout ) return nullptr; + pSalLayout->SetTextRenderModeForResolutionIndependentLayout(bTextRenderModeForResolutionIndependentLayout); + // do glyph fallback if needed // #105768# avoid fallback for very small font sizes if (aLayoutArgs.HasFallbackRun() && mpFontInstance->GetFontSelectPattern().mnHeight >= 3)