vcl/inc/unx/fontmanager.hxx                 |    7 ++-----
 vcl/quartz/salgdicommon.cxx                 |    2 +-
 vcl/unx/generic/fontmanager/fontmanager.cxx |    5 +++--
 vcl/unx/generic/gdi/freetypetextrender.cxx  |    9 +--------
 vcl/unx/generic/print/genpspgraphics.cxx    |    9 +--------
 5 files changed, 8 insertions(+), 24 deletions(-)

New commits:
commit 05b3d7ea4673654e809be816bee0fa67fbf0308a
Author:     Khaled Hosny <[email protected]>
AuthorDate: Thu Sep 8 02:03:20 2022 +0200
Commit:     خالد حسني <[email protected]>
CommitDate: Thu Sep 8 16:31:42 2022 +0200

    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: خالد حسني <[email protected]>

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,

Reply via email to