summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/fontmanager
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2017-10-10 23:18:10 +0200
committerJulien Nabet <serval2412@yahoo.fr>2017-10-11 00:05:57 +0200
commit78f79760d5cb768cb482646fc71a90cd6cd1e630 (patch)
tree6e1b8e078cd92a3234c41f7bae98b4e7576b71cc /vcl/unx/generic/fontmanager
parent42e8ca0f12c787f415bf644eb75e09849858f3ec (diff)
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@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'vcl/unx/generic/fontmanager')
-rw-r--r--vcl/unx/generic/fontmanager/fontconfig.cxx3
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx16
2 files changed, 9 insertions, 10 deletions
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