diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-09-04 20:39:30 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-09-05 06:51:09 +0200 |
commit | 0e2b9be640118cde6bb8dc1350cb619000969683 (patch) | |
tree | ac1f6636645a03260a3ceabe814be0cf838deca7 /vcl | |
parent | ca7d6be2d64a48e61db7a1c614d6325151817f59 (diff) |
vcl: Don’t parse cmap in PrintFontManager::getGlyphWidths()
Use PhysicalFontFace::GetFontCharMap() instead which has already parsed
the cmap table.
Change-Id: Ieba7bace65c9c5d85ffb8feb04e99cd826d7ab48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139341
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 4 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 40 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 8 |
3 files changed, 19 insertions, 33 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index e7ee08c4c193..7483a86e3d95 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -28,6 +28,8 @@ #include <com/sun/star/lang/Locale.hpp> #include <unx/fc_fontoptions.hxx> +#include <font/PhysicalFontFace.hxx> + #include <glyphid.hxx> #include <map> @@ -283,7 +285,7 @@ public: sal_Int32* pWidths, int nGlyphs ); - void getGlyphWidths( fontID nFont, + void getGlyphWidths( const vcl::font::PhysicalFontFace* pFace, bool bVertical, std::vector< sal_Int32 >& rWidths, std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc ); diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index 46e8ae1624c7..4ede52817180 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -1081,12 +1081,12 @@ bool PrintFontManager::createFontSubset( return bSuccess; } -void PrintFontManager::getGlyphWidths( fontID nFont, +void PrintFontManager::getGlyphWidths( const vcl::font::PhysicalFontFace* pFace, bool bVertical, std::vector< sal_Int32 >& rWidths, std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc ) { - PrintFont* pFont = getFont( nFont ); + PrintFont* pFont = getFont( pFace->GetFontId() ); if (!pFont) return; TrueTypeFont* pTTFont = nullptr; @@ -1113,32 +1113,22 @@ void PrintFontManager::getGlyphWidths( fontID nFont, } // fill the unicode map - // TODO: isn't this map already available elsewhere in the fontmanager? - sal_uInt32 nCmapSize = 0; - const sal_uInt8* pCmapData = pTTFont->table(O_cmap, nCmapSize); - if (pCmapData) + FontCharMapRef xFontCharMap = pFace->GetFontCharMap(); + for (sal_uInt32 cOld = 0;;) { - CmapResult aCmapResult; - if (ParseCMAP(pCmapData, nCmapSize, aCmapResult)) - { - FontCharMapRef xFontCharMap(new FontCharMap(aCmapResult)); - for (sal_uInt32 cOld = 0;;) - { - // get next unicode covered by font - const sal_uInt32 c = xFontCharMap->GetNextChar(cOld); - if (c == cOld) - break; - cOld = c; + // get next unicode covered by font + const sal_uInt32 c = xFontCharMap->GetNextChar(cOld); + if (c == cOld) + break; + cOld = c; #if 1 // TODO: remove when sal_Unicode covers all of unicode - if (c > sal_Unicode(~0)) - break; + if (c > sal_Unicode(~0)) + break; #endif - // get the matching glyph index - const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c); - // update the requested map - rUnicodeEnc[static_cast<sal_Unicode>(c)] = aGlyphId; - } - } + // get the matching glyph index + const sal_GlyphId aGlyphId = xFontCharMap->GetGlyphIndex(c); + // update the requested map + rUnicodeEnc[static_cast<sal_Unicode>(c)] = aGlyphId; } } CloseTTFont(pTTFont); diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index b1068082c26d..5b607b44610b 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -356,14 +356,8 @@ void GenPspGraphics::GetGlyphWidthsHelper(const vcl::font::PhysicalFontFace* pFo std::vector<sal_Int32>& rWidths, Ucs2UIntMap& rUnicodeEnc) { - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the FreetypeManager search for the PhysicalFontFace pFont - psp::fontID aFont = pFont->GetFontId(); psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - rMgr.getGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); + rMgr.getGlyphWidths( pFont, bVertical, rWidths, rUnicodeEnc ); } FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo ) |