diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-08 02:45:28 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-08 10:40:50 +0500 |
commit | 36e8e419d022a9c43302efe5e702a704dea39e76 (patch) | |
tree | 754fffd75f8495b6dc795404ae8ac9c95e9d2c34 | |
parent | ee5584b926cd10ea600a3514242148db5a0a6f18 (diff) |
Exclude getHScale from DirectWrite font rendering
... and drop it, since it's unused now.
Unkike with Skia, where the ratio produces a visible effect, in
DirectWrite the effect seems cancelled by transformations. Yet,
it produced computational instability, noticable in small vertical
text.
Change-Id: I2f3b20913075d1338dc75c5a04c9cc0ef29c75ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165877
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | vcl/inc/win/DWriteTextRenderer.hxx | 15 | ||||
-rw-r--r-- | vcl/inc/win/winlayout.hxx | 2 | ||||
-rw-r--r-- | vcl/win/gdi/DWriteTextRenderer.cxx | 28 | ||||
-rw-r--r-- | vcl/win/gdi/winlayout.cxx | 8 |
4 files changed, 18 insertions, 35 deletions
diff --git a/vcl/inc/win/DWriteTextRenderer.hxx b/vcl/inc/win/DWriteTextRenderer.hxx index 67094052ebb5..a655df6459ea 100644 --- a/vcl/inc/win/DWriteTextRenderer.hxx +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -72,21 +72,6 @@ private: D2DTextAntiAliasMode meTextAntiAliasMode; }; -/** - * Sets and unsets the needed DirectWrite transform to support the font's horizontal scaling and - * rotation. - */ -class WinFontTransformGuard -{ -public: - WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical); - ~WinFontTransformGuard(); - -private: - ID2D1RenderTarget* mpRenderTarget; - D2D1::Matrix3x2F maTransform; -}; - #endif // INCLUDED_VCL_INC_WIN_DWRITERENDERER_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index 0f253230c1b4..ac70e42b66cf 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -36,8 +36,6 @@ class WinFontInstance : public LogicalFontInstance public: ~WinFontInstance() override; - float getHScale() const; - void SetGraphics(WinSalGraphics*); WinSalGraphics* GetGraphics() const { return m_pGraphics; } diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index b7d7c03e9995..321587db8137 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -97,6 +97,20 @@ HRESULT checkResult(HRESULT hr, const char* file, size_t line) #endif +// Sets and unsets the needed DirectWrite transform to support the font's rotation. +class WinFontTransformGuard +{ +public: + WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, + const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, + bool bIsVertical); + ~WinFontTransformGuard(); + +private: + ID2D1RenderTarget* mpRenderTarget; + D2D1::Matrix3x2F maTransform; +}; + } // end anonymous namespace D2DWriteTextOutRenderer::D2DWriteTextOutRenderer(bool bRenderingModeNatural) @@ -218,7 +232,6 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa } const WinFontInstance& rWinFont = static_cast<const WinFontInstance&>(rLayout.GetFont()); - float fHScale = rWinFont.getHScale(); float lfEmHeight = 0; IDWriteFontFace* pFontFace = GetDWriteFace(rWinFont, &lfEmHeight); @@ -251,11 +264,11 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa while (rLayout.GetNextGlyph(&pGlyph, aPos, nStart)) { UINT16 glyphIndices[] = { static_cast<UINT16>(pGlyph->glyphId()) }; - FLOAT glyphAdvances[] = { static_cast<FLOAT>(pGlyph->newWidth()) / fHScale }; + FLOAT glyphAdvances[] = { static_cast<FLOAT>(pGlyph->newWidth()) }; DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, }; - D2D1_POINT_2F baseline = { static_cast<FLOAT>(aPos.getX() - bounds.Left()) / fHScale, + D2D1_POINT_2F baseline = { static_cast<FLOAT>(aPos.getX() - bounds.Left()), static_cast<FLOAT>(aPos.getY() - bounds.Top()) }; - WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, baseline, pGlyph->IsVertical()); + WinFontTransformGuard aTransformGuard(mpRT, rLayout, baseline, pGlyph->IsVertical()); DWRITE_GLYPH_RUN glyphs = { pFontFace, lfEmHeight, @@ -306,7 +319,7 @@ IDWriteFontFace* D2DWriteTextOutRenderer::GetDWriteFace(const WinFontInstance& r return pFontFace; } -WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, +WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical) @@ -314,11 +327,6 @@ WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, f { pRenderTarget->GetTransform(&maTransform); D2D1::Matrix3x2F aTransform = maTransform; - if (fHScale != 1.0f) - { - aTransform - = aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), D2D1::Point2F(0, 0)); - } Degree10 angle = rLayout.GetOrientation(); diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 3865f2ebed66..f7ac7f5ff851 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -147,14 +147,6 @@ WinFontInstance::~WinFontInstance() ::DeleteFont(m_hFont); } -float WinFontInstance::getHScale() const -{ - const vcl::font::FontSelectPattern& rPattern = GetFontSelectPattern(); - if (!rPattern.mnHeight || !rPattern.mnWidth) - return 1.0; - return rPattern.mnWidth * GetAverageWidthFactor() / rPattern.mnHeight; -} - void WinFontInstance::ImplInitHbFont(hb_font_t* /*pHbFont*/) { assert(m_pGraphics); |