[Libreoffice-commits] core.git: vcl/inc vcl/unx

Julien Nabet serval2412 at yahoo.fr
Tue Oct 10 22:06:18 UTC 2017


 vcl/inc/unx/fontmanager.hxx                 |    2 +-
 vcl/unx/generic/fontmanager/fontconfig.cxx  |    3 +--
 vcl/unx/generic/fontmanager/fontmanager.cxx |   16 ++++++++--------
 3 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 78f79760d5cb768cb482646fc71a90cd6cd1e630
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Oct 10 23:18:10 2017 +0200

    Replace list by vector fontconfig/manager (vcl)
    
    + refactor a bit "analyzeFontFile" to return a vector of std::unique_ptr<PrintFont>
    instead of just a bool
    
    Change-Id: I9c8c307c5c323e40667359f5094672c1cde589fd
    Reviewed-on: https://gerrit.libreoffice.org/43317
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 47ea4348bdcc..16e819bace48 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -148,7 +148,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 
     OString getFontFile(const PrintFont* pFont) const;
 
-    bool analyzeFontFile(int nDirID, const OString& rFileName, std::list<std::unique_ptr<PrintFont>>& rNewFonts, const char *pFormat=nullptr) const;
+    std::vector<std::unique_ptr<PrintFont>> analyzeFontFile(int nDirID, const OString& rFileName, const char *pFormat=nullptr) const;
     static OUString convertSfntName( void* pNameRecord ); // actually a NameRecord* format font subsetting code
     static void analyzeSfntFamilyName( void* pTTFont, std::list< OUString >& rnames ); // actually a TrueTypeFont* from font subsetting code
     bool analyzeSfntFile(PrintFont* pFont) const;
diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx
index 459678819575..34b9ba27f642 100644
--- a/vcl/unx/generic/fontmanager/fontconfig.cxx
+++ b/vcl/unx/generic/fontmanager/fontconfig.cxx
@@ -548,7 +548,6 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS
 
             // see if this font is already cached
             // update attributes
-            std::list<std::unique_ptr<PrintFont>> aFonts;
             OString aDir, aBase, aOrgPath( reinterpret_cast<char*>(file) );
             splitPath( aOrgPath, aDir, aBase );
 
@@ -562,7 +561,7 @@ void PrintFontManager::countFontconfigFonts( std::unordered_map<OString, int, OS
             // not described by fontconfig (e.g. alias names, PSName)
             if (eFormatRes != FcResultMatch)
                 format = nullptr;
-            analyzeFontFile( nDirID, aBase, aFonts, reinterpret_cast<char*>(format) );
+            std::vector<std::unique_ptr<PrintFont>> aFonts = analyzeFontFile( nDirID, aBase, reinterpret_cast<char*>(format) );
             if(aFonts.empty())
             {
 #if OSL_DEBUG_LEVEL > 1
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index c7ff4c1f5e45..8336c1738b26 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -194,8 +194,8 @@ std::vector<fontID> PrintFontManager::addFontFile( const OString& rFileName )
     std::vector<fontID> aFontIds = findFontFileIDs( nDirID, aName );
     if( aFontIds.empty() )
     {
-        std::list<std::unique_ptr<PrintFont>> aNewFonts;
-        if (analyzeFontFile(nDirID, aName, aNewFonts))
+        std::vector<std::unique_ptr<PrintFont>> aNewFonts = analyzeFontFile(nDirID, aName);
+        if (!aNewFonts.empty())
         {
             for (auto it = aNewFonts.begin(); it != aNewFonts.end(); ++it)
             {
@@ -214,9 +214,9 @@ enum fontFormat
     UNKNOWN, TRUETYPE, CFF
 };
 
-bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, std::list<std::unique_ptr<PrintFontManager::PrintFont>>& rNewFonts, const char *pFormat ) const
+std::vector<std::unique_ptr<PrintFontManager::PrintFont>> PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, const char *pFormat ) const
 {
-    rNewFonts.clear();
+    std::vector<std::unique_ptr<PrintFontManager::PrintFont>> aNewFonts;
 
     OString aDir( getDirectory( nDirID ) );
 
@@ -226,7 +226,7 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, st
 
     // #i1872# reject unreadable files
     if( access( aFullPath.getStr(), R_OK ) )
-        return false;
+        return aNewFonts;
 
     fontFormat eFormat = UNKNOWN;
     if (pFormat)
@@ -290,7 +290,7 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, st
                 xFont->m_aFontFile          = rFontFile;
                 xFont->m_nCollectionEntry   = i;
                 if (analyzeSfntFile(xFont.get()))
-                    rNewFonts.push_back(std::move(xFont));
+                    aNewFonts.push_back(std::move(xFont));
             }
         }
         else
@@ -302,10 +302,10 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, st
 
             // need to read the font anyway to get aliases inside the font file
             if (analyzeSfntFile(xFont.get()))
-                rNewFonts.push_back(std::move(xFont));
+                aNewFonts.push_back(std::move(xFont));
         }
     }
-    return ! rNewFonts.empty();
+    return aNewFonts;
 }
 
 fontID PrintFontManager::findFontFileID( int nDirID, const OString& rFontFile, int nFaceIndex ) const


More information about the Libreoffice-commits mailing list