Kaydet (Commit) 78f79760 authored tarafından Julien Nabet's avatar Julien Nabet

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/43317Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 42e8ca0f
......@@ -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;
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment