diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-09-04 20:39:22 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-09-05 06:09:11 +0200 |
commit | ca7d6be2d64a48e61db7a1c614d6325151817f59 (patch) | |
tree | 437d23cc5944a8814a0c4bb739c8af420867f662 /vcl/win/gdi | |
parent | 8f9638424f7f88c99ff16a8015ca343f3042b26d (diff) |
vcl: Consolidate PhysicalFontFace::GetFontCharMap()
All subclasses are doing the same thing in slightly different ways, so
move it to the base class that we can now access font tables there.
Also drop unused PhysicalFontFace::HasChar().
Change-Id: I77022b4dc3688de2788c18966f39f407a6abb730
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139340
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl/win/gdi')
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index f2922c186c01..1c4ef2355f56 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -179,8 +179,7 @@ private: // does a font face hold the given missing characters? bool WinGlyphFallbackSubstititution::HasMissingChars(vcl::font::PhysicalFontFace* pFace, OUString& rMissingChars) const { - WinFontFace* pWinFont = static_cast< WinFontFace* >(pFace); - FontCharMapRef xFontCharMap = pWinFont->GetFontCharMap(); + FontCharMapRef xFontCharMap = pFace->GetFontCharMap(); // avoid fonts with unknown CMAP subtables for glyph fallback if( !xFontCharMap.is() || xFontCharMap->IsDefaultMap() ) @@ -615,7 +614,6 @@ WinFontFace::WinFontFace(const ENUMLOGFONTEXW& rEnumFont, const NEWTEXTMETRICW& WinFontFace::~WinFontFace() { DeleteFont(mhFont); - mxUnicodeMap.clear(); } sal_IntPtr WinFontFace::GetFontId() const @@ -713,13 +711,6 @@ hb_blob_t* WinFontFace::GetHbTable(hb_tag_t nTag) const static DWORD CalcTag( const char p[5]) { return (p[0]+(p[1]<<8)+(p[2]<<16)+(p[3]<<24)); } -FontCharMapRef WinFontFace::GetFontCharMap() const -{ - if (!mxUnicodeMap.is()) - ReadCmapTable(); - return mxUnicodeMap; -} - bool WinFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const { if (!mbFontCapabilitiesRead) @@ -728,39 +719,6 @@ bool WinFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange; } -void WinFontFace::ReadCmapTable() const -{ - if( mxUnicodeMap.is() ) - return; - - HDC hDC(::GetDC(nullptr)); - HFONT hOldFont = ::SelectFont(hDC, mhFont); - - bool bIsSymbolFont = (meWinCharSet == SYMBOL_CHARSET); - // get the CMAP table from the font which is selected into the DC - const DWORD nCmapTag = CalcTag( "cmap" ); - const RawFontData aRawFontData( hDC, nCmapTag ); - // parse the CMAP table if available - if( aRawFontData.get() ) { - CmapResult aResult; - ParseCMAP( aRawFontData.get(), aRawFontData.size(), aResult ); - aResult.mbSymbolic = bIsSymbolFont; - if( aResult.mnRangeCount > 0 ) - { - FontCharMapRef pUnicodeMap(new FontCharMap(aResult)); - mxUnicodeMap = pUnicodeMap; - } - } - - ::SelectFont(hDC, hOldFont); - ::ReleaseDC(nullptr, hDC); - - if( !mxUnicodeMap.is() ) - { - mxUnicodeMap = FontCharMap::GetDefaultMap( bIsSymbolFont ); - } -} - void WinFontFace::GetFontCapabilities() const { // read this only once per font |