diff options
author | Khaled Hosny <khaled@libreoffice.org> | 2023-07-16 07:37:55 +0300 |
---|---|---|
committer | خالد حسني <khaled@libreoffice.org> | 2023-07-23 06:00:30 +0200 |
commit | dfe42e756b37642355356a6035081f4473609832 (patch) | |
tree | 77a42535ddef1f76802fa4221f33fd97755bb2ff /vcl/win | |
parent | 32144b5dc617d5a375eeadf25b5b62befb529785 (diff) |
vcl: Use HarfBuzz to get glyph bounding rectangle
For consistent cross-platform results that also matches our glyph
advances since platform functions might be using hints which we don’t
use.
Change-Id: I4aebd3e7c5f460dff584f5eba74f7a11bab0f9b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154388
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'vcl/win')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 3b31028c88bb..51ddcce741b7 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1156,56 +1156,6 @@ void WinSalGraphics::ClearDevFontCache() ImplReleaseTempFonts(*GetSalData(), false); } -bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bIsVertical) const -{ - assert(m_pGraphics); - HDC hDC = m_pGraphics->getHDC(); - const HFONT hOrigFont = static_cast<HFONT>(GetCurrentObject(hDC, OBJ_FONT)); - const HFONT hFont = GetHFONT(); - if (hFont != hOrigFont) - SelectObject(hDC, hFont); - - const ::comphelper::ScopeGuard aFontRestoreScopeGuard([hFont, hOrigFont, hDC]() - { if (hFont != hOrigFont) SelectObject(hDC, hOrigFont); }); - - // use unity matrix - MAT2 aMat; - const vcl::font::FontSelectPattern& rFSD = GetFontSelectPattern(); - - // Use identity matrix for fonts requested in horizontal - // writing (LTR or RTL), or rotated glyphs in vertical writing. - if (!rFSD.mbVertical || !bIsVertical) - { - aMat.eM11 = aMat.eM22 = FixedFromDouble(1.0); - aMat.eM12 = aMat.eM21 = FixedFromDouble(0.0); - } - else - { - constexpr double nCos = 0.0; - constexpr double nSin = 1.0; - aMat.eM11 = FixedFromDouble(nCos); - aMat.eM12 = FixedFromDouble(nSin); - aMat.eM21 = FixedFromDouble(-nSin); - aMat.eM22 = FixedFromDouble(nCos); - } - - UINT nGGOFlags = GGO_METRICS; - nGGOFlags |= GGO_GLYPH_INDEX; - - GLYPHMETRICS aGM; - aGM.gmptGlyphOrigin.x = aGM.gmptGlyphOrigin.y = 0; - aGM.gmBlackBoxX = aGM.gmBlackBoxY = 0; - DWORD nSize = ::GetGlyphOutlineW(hDC, nId, nGGOFlags, &aGM, 0, nullptr, &aMat); - if (nSize == GDI_ERROR) - return false; - - rRect = tools::Rectangle( Point( +aGM.gmptGlyphOrigin.x, -aGM.gmptGlyphOrigin.y ), - Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) ); - rRect.SetRight(rRect.Right() + 1); - rRect.SetBottom(rRect.Bottom() + 1); - return true; -} - bool WinFontInstance::GetGlyphOutline(sal_GlyphId nId, basegfx::B2DPolyPolygon& rB2DPolyPoly, bool) const { rB2DPolyPoly.clear(); |