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 07:12:18 +0200 |
commit | 8557ea84c9336ba8061246f1f46ddb6e02f413a1 (patch) | |
tree | 47280a24520592c50a74532699c02b604365de14 | |
parent | 748561425774fa40ab685fed80d113f7e8301158 (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 d4bb45e5895b..b822a6bca488 100644 --- a/vcl/inc/win/DWriteTextRenderer.hxx +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -71,19 +71,4 @@ 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; -}; - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index cfb36e825b54..31066a7db28a 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 bb0f7e6b7661..633dcf82b13b 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -93,6 +93,20 @@ HRESULT checkResult(HRESULT hr, const char* location) #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) @@ -214,7 +228,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); @@ -247,11 +260,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, @@ -302,7 +315,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) @@ -310,11 +323,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 19eaae2ecee7..0c64759e1ab8 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -146,14 +146,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); |