diff options
-rw-r--r-- | vcl/inc/unx/fontmanager.hxx | 3 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontconfig.cxx | 20 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 2 |
3 files changed, 23 insertions, 2 deletions
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx index a76474f856fc..a7817652d9ae 100644 --- a/vcl/inc/unx/fontmanager.hxx +++ b/vcl/inc/unx/fontmanager.hxx @@ -175,6 +175,9 @@ class VCL_PLUGIN_PUBLIC PrintFontManager */ static void addFontconfigDir(const OString& rDirectory); + /* register an application specific font file for libfontconfig */ + static void addFontconfigFile(const OString& rFile); + std::set<OString> m_aPreviousLangSupportRequests; std::vector<OUString> m_aCurrentRequests; Timer m_aFontInstallerTimer; diff --git a/vcl/unx/generic/fontmanager/fontconfig.cxx b/vcl/unx/generic/fontmanager/fontconfig.cxx index eb66017d98fa..a34d0e08b050 100644 --- a/vcl/unx/generic/fontmanager/fontconfig.cxx +++ b/vcl/unx/generic/fontmanager/fontconfig.cxx @@ -153,8 +153,6 @@ class FontCfgWrapper { FcFontSet* m_pFontSet; - void addFontSet( FcSetName ); - FontCfgWrapper(); ~FontCfgWrapper(); @@ -162,6 +160,8 @@ public: static FontCfgWrapper& get(); static void release(); + void addFontSet( FcSetName ); + FcFontSet* getFontSet(); void clear(); @@ -766,6 +766,22 @@ void PrintFontManager::addFontconfigDir( const OString& rDirName ) } } +void PrintFontManager::addFontconfigFile( const OString& rFileName ) +{ + const char* pFileName = rFileName.getStr(); + bool bFileOk = (FcConfigAppFontAddFile(FcConfigGetCurrent(), reinterpret_cast<FcChar8 const *>(pFileName) ) == FcTrue); + + SAL_INFO("vcl.fonts", "FcConfigAppFontAddFile(\"" << pFileName << "\") => " << std::boolalpha << bFileOk); + + if( !bFileOk ) + return; + + // FIXME: we want to add only the newly added font not re-add the whole + // application font set. + FontCfgWrapper& rWrapper = FontCfgWrapper::get(); + rWrapper.addFontSet( FcSetApplication ); +} + static void addtopattern(FcPattern *pPattern, FontItalic eItalic, FontWeight eWeight, FontWidth eWidth, FontPitch ePitch) { diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index b8f99d122e1f..d7b6a211df13 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -159,6 +159,8 @@ std::vector<fontID> PrintFontManager::addFontFile( std::u16string_view rFileUrl std::vector<fontID> aFontIds = findFontFileIDs( nDirID, aName ); if( aFontIds.empty() ) { + addFontconfigFile(OUStringToOString(aPath.GetFull(), osl_getThreadTextEncoding())); + std::vector<PrintFont> aNewFonts = analyzeFontFile(nDirID, aName); for (auto & font : aNewFonts) { |