diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-09-08 02:03:20 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-09-08 16:31:42 +0200 |
commit | 05b3d7ea4673654e809be816bee0fa67fbf0308a (patch) | |
tree | e64bf6d7a76df37ec2f4e214d89d9f1c23e92e91 | |
parent | f82e1596f5d886c60cbf41e9912de77be42eff9f (diff) |
vcl: Pass FontCharMap to OpenTTFont*() when possible
Avoids parsing “cmap” table again to get it.
Change-Id: I19eb882efd8c8aaaeb2fa770405ef2d69d985104
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139622
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 7 | ||||
-rw-r--r-- | vcl/quartz/salgdicommon.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 5 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/freetypetextrender.cxx | 9 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 9 |
5 files changed, 8 insertions, 24 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index f9b1930175da..f85a80901f74 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -267,18 +267,15 @@ public: // creates a new font subset of an existing SFNT font // returns true in case of success, else false - // nFont: the font to be subsetted + // pFace: the font face to be subsetted // rOutFile: the file to put the new subset into; // must be a valid osl file URL // pGlyphIDs: input array of glyph ids for new font // pNewEncoding: the corresponding encoding in the new font - // pWidths: output array of widths of requested glyphs // nGlyphs: number of glyphs in arrays - // pCapHeight:: capital height of the produced font - // pXMin, pYMin, pXMax, pYMax: outgoing font bounding box // TODO: callers of this method should use its FontSubsetInfo counterpart directly bool createFontSubset( FontSubsetInfo&, - fontID nFont, + const vcl::font::PhysicalFontFace* pFace, const OUString& rOutFile, const sal_GlyphId* pGlyphIDs, const sal_uInt8* pNewEncoding, diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx index 992db536e7d5..d9ca95d997a0 100644 --- a/vcl/quartz/salgdicommon.cxx +++ b/vcl/quartz/salgdicommon.cxx @@ -79,7 +79,7 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile, // prepare data for psprint's font subsetter TrueTypeFont* pSftFont = nullptr; - if (::OpenTTFontBuffer( static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont) + if (::OpenTTFontBuffer( static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont, pFontData->GetFontCharMap()) != SFErrCodes::Ok) return false; diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index e0131081481b..33ccb9987dad 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -941,13 +941,14 @@ int PrintFontManager::getFontDescend( fontID nFontID ) // TODO: move most of this stuff into the central font-subsetting code bool PrintFontManager::createFontSubset( FontSubsetInfo& rInfo, - fontID nFont, + const vcl::font::PhysicalFontFace* pFace, const OUString& rOutFile, const sal_GlyphId* pGlyphIds, const sal_uInt8* pNewEncoding, int nGlyphs ) { + psp::fontID nFont = pFace->GetFontId(); PrintFont* pFont = getFont( nFont ); if( !pFont ) return false; @@ -988,7 +989,7 @@ bool PrintFontManager::createFontSubset( const OString aFromFile = getFontFile( *pFont ); TrueTypeFont* pTTFont = nullptr; // TODO: rename to SfntFont - if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont ) != SFErrCodes::Ok ) + if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont, pFace->GetFontCharMap() ) != SFErrCodes::Ok ) return false; // prepare system name for write access for subset file target diff --git a/vcl/unx/generic/gdi/freetypetextrender.cxx b/vcl/unx/generic/gdi/freetypetextrender.cxx index 555bd2586eb9..beff9f33e652 100644 --- a/vcl/unx/generic/gdi/freetypetextrender.cxx +++ b/vcl/unx/generic/gdi/freetypetextrender.cxx @@ -136,16 +136,9 @@ bool FreeTypeTextRenderImpl::CreateFontSubset( FontSubsetInfo& rInfo ) { - // 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(); bool bSuccess = rMgr.createFontSubset( rInfo, - aFont, + pFont, rToFile, pGlyphIds, pEncoding, diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index 6632c4f077e1..630a02bdb061 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -324,16 +324,9 @@ bool GenPspGraphics::CreateFontSubset( FontSubsetInfo& rInfo ) { - // 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(); bool bSuccess = rMgr.createFontSubset( rInfo, - aFont, + pFont, rToFile, pGlyphIds, pEncoding, |