From 169e5daed03048fea4064e0b60e8c40aa3064085 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 13 Jul 2026 05:01:23 +0300 Subject: [PATCH] vcl: Rename psp::PrintFontManager to FontConfigManager MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “psp” stands for PostScript print, there is no PostScript and the class has nothing to do with printing. Change-Id: I45ceb4b5deb5ae9cbb731158a5f84f0d716c6036 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208527 Tested-by: Jenkins Reviewed-by: Khaled Hosny --- compilerplugins/clang/staticmethods.cxx | 3 +- vcl/inc/unx/font/fontmanager.hxx | 14 +++------ vcl/inc/unx/gendata.hxx | 6 ++-- vcl/qa/unx/generic/generic.cxx | 2 +- vcl/qt5/QtGraphics.cxx | 2 +- vcl/qt5/QtTools.cxx | 2 +- vcl/source/gdi/impglyphitem.cxx | 2 +- vcl/unx/generic/app/gendata.cxx | 12 ++++---- vcl/unx/generic/font/fontconfig.cxx | 32 +++++++++----------- vcl/unx/generic/font/fontmanager.cxx | 18 +++++------ vcl/unx/generic/font/fontsubst.cxx | 2 +- vcl/unx/generic/font/freetype_glyphcache.cxx | 6 ++-- vcl/unx/generic/font/glyphcache.cxx | 2 +- vcl/unx/gtk3/salnativewidgets-gtk.cxx | 2 +- 14 files changed, 49 insertions(+), 56 deletions(-) diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx index 7769d47e6493..f4f9750722a7 100644 --- a/compilerplugins/clang/staticmethods.cxx +++ b/compilerplugins/clang/staticmethods.cxx @@ -214,8 +214,7 @@ bool StaticMethods::TraverseCXXMethodDecl(const CXXMethodDecl * pCXXMethodDecl) return true; } // depends on config options - if ((fdc.Function("autoInstallFontLangSupport").Class("PrintFontManager") - .Namespace("psp").GlobalNamespace()) + if (fdc.Function("autoInstallFontLangSupport").Class("FontConfigManager").GlobalNamespace() || fdc.Function("AllocateFrame").Class("GtkSalFrame").GlobalNamespace() || (fdc.Function("TriggerPaintEvent").Class("GtkSalFrame") .GlobalNamespace())) diff --git a/vcl/inc/unx/font/fontmanager.hxx b/vcl/inc/unx/font/fontmanager.hxx index ebee8b10e69b..b37fe9555dc3 100644 --- a/vcl/inc/unx/font/fontmanager.hxx +++ b/vcl/inc/unx/font/fontmanager.hxx @@ -44,8 +44,6 @@ class FontSelectPattern; } class GenericUnixSalData; -namespace psp { - struct FontconfigFont { FontAttributes m_aFontAttributes; @@ -55,7 +53,7 @@ struct FontconfigFont int m_nVariationEntry = 0; // 0 for regular fonts, 0 to ... for fonts stemming from font variations }; -class VCL_PLUGIN_PUBLIC PrintFontManager +class VCL_PLUGIN_PUBLIC FontConfigManager { std::vector m_aSystemFonts; @@ -92,11 +90,11 @@ class VCL_PLUGIN_PUBLIC PrintFontManager Timer m_aFontInstallerTimer; DECL_DLLPRIVATE_LINK( autoInstallFontLangSupport, Timer*, void ); - PrintFontManager(); + FontConfigManager(); public: - ~PrintFontManager(); - friend class ::GenericUnixSalData; - static PrintFontManager& get(); // one instance only + ~FontConfigManager(); + friend class GenericUnixSalData; + static FontConfigManager& get(); // one instance only std::vector takeSystemFonts() { return std::move(m_aSystemFonts); } @@ -142,6 +140,4 @@ public: }; -} // namespace - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/gendata.hxx b/vcl/inc/unx/gendata.hxx index a3012503aa0b..e64788317f80 100644 --- a/vcl/inc/unx/gendata.hxx +++ b/vcl/inc/unx/gendata.hxx @@ -15,10 +15,10 @@ #ifndef IOS class FreetypeFontList; +class FontConfigManager; namespace psp { -class PrintFontManager; class PrinterInfoManager; } @@ -47,7 +47,7 @@ class VCL_PLUGIN_PUBLIC GenericUnixSalData : public SalData friend class ::psp::PrinterInfoManager; std::unique_ptr m_pFreetypeFontList; - std::unique_ptr m_pPrintFontManager; + std::unique_ptr m_pFontConfigManager; std::unique_ptr m_pPrinterInfoManager; #endif @@ -57,7 +57,7 @@ public: #ifndef IOS FreetypeFontList* GetFreetypeFontList(); - psp::PrintFontManager* GetPrintFontManager(); + FontConfigManager* GetFontConfigManager(); #endif }; diff --git a/vcl/qa/unx/generic/generic.cxx b/vcl/qa/unx/generic/generic.cxx index c665ebdef665..f596fa433416 100644 --- a/vcl/qa/unx/generic/generic.cxx +++ b/vcl/qa/unx/generic/generic.cxx @@ -38,7 +38,7 @@ public: vcl::font::FontSelectPattern aPattern(rFont, rFont.GetFamilyName(), aSize, fExactHeight, bNonAntialias); aPattern.maTargetName = rFont.GetFamilyName(); - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + FontConfigManager& rMgr = FontConfigManager::get(); OUString aMissingCodes; rMgr.Substitute(aPattern, aMissingCodes); diff --git a/vcl/qt5/QtGraphics.cxx b/vcl/qt5/QtGraphics.cxx index 2c3321aa4453..fefa5e6ebc58 100644 --- a/vcl/qt5/QtGraphics.cxx +++ b/vcl/qt5/QtGraphics.cxx @@ -143,7 +143,7 @@ void QtGraphics::GetDevFontList(vcl::font::PhysicalFontCollection* pPFC) return; #if USE_HEADLESS_CODE - psp::PrintFontManager::get(); + FontConfigManager::get(); static const bool bUseFontconfig = (nullptr == getenv("SAL_VCL_QT_NO_FONTCONFIG")); if (bUseFontconfig) diff --git a/vcl/qt5/QtTools.cxx b/vcl/qt5/QtTools.cxx index 57413ff4f602..6c46d0d86ae8 100644 --- a/vcl/qt5/QtTools.cxx +++ b/vcl/qt5/QtTools.cxx @@ -347,7 +347,7 @@ std::optional toVclFont(const QFont& rQFont, const css::lang::Locale& FontAttributes aFA; QtFontFace::fillAttributesFromQFont(rQFont, aFA); - bool bFound = psp::PrintFontManager::matchFont(aFA, rLocale); + bool bFound = FontConfigManager::matchFont(aFA, rLocale); SAL_INFO("vcl.qt", "font match result for '" << rQFont.family() << "': " diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx index b464dadc45b6..fadcf67576b4 100644 --- a/vcl/source/gdi/impglyphitem.cxx +++ b/vcl/source/gdi/impglyphitem.cxx @@ -373,7 +373,7 @@ const SalLayoutGlyphs* SalLayoutGlyphsCache::GetLayoutGlyphs( bool bEnableOptimization = (text.getLength() < nOptLengthThreshold); // Writer layouts tests enable SAL_NON_APPLICATION_FONT_USE=abort in order - // to make PrintFontManager::Substitute() abort if font fallback happens. When + // to make FontConfigManager::Substitute() abort if font fallback happens. When // laying out the entire string the chance this happens increases (e.g. testAbi11870 // normally calls this function only for a part of a string, but this optimization // lays out the entire string and causes a fallback). Since this optimization diff --git a/vcl/unx/generic/app/gendata.cxx b/vcl/unx/generic/app/gendata.cxx index 55873c65b355..c02bd14e6d09 100644 --- a/vcl/unx/generic/app/gendata.cxx +++ b/vcl/unx/generic/app/gendata.cxx @@ -43,7 +43,7 @@ GenericUnixSalData::~GenericUnixSalData() #ifndef IOS // the font list was enumerated from fontconfig, so it goes first m_pFreetypeFontList.reset(); - m_pPrintFontManager.reset(); + m_pFontConfigManager.reset(); m_pPrinterInfoManager.reset(); #endif } @@ -55,18 +55,18 @@ FreetypeFontList* GenericUnixSalData::GetFreetypeFontList() { // fontconfig has to be up, and know about our own font directories, // before it can hand the system fonts over to the font list - GetPrintFontManager(); + GetFontConfigManager(); m_pFreetypeFontList.reset(new FreetypeFontList); m_pFreetypeFontList->Init(); } return m_pFreetypeFontList.get(); } -psp::PrintFontManager* GenericUnixSalData::GetPrintFontManager() +FontConfigManager* GenericUnixSalData::GetFontConfigManager() { - if (!m_pPrintFontManager) - m_pPrintFontManager.reset(new psp::PrintFontManager); - return m_pPrintFontManager.get(); + if (!m_pFontConfigManager) + m_pFontConfigManager.reset(new FontConfigManager); + return m_pFontConfigManager.get(); } #endif diff --git a/vcl/unx/generic/font/fontconfig.cxx b/vcl/unx/generic/font/fontconfig.cxx index 23f26a787a1f..98847cf0dbe8 100644 --- a/vcl/unx/generic/font/fontconfig.cxx +++ b/vcl/unx/generic/font/fontconfig.cxx @@ -56,8 +56,6 @@ #include #include -using namespace psp; - namespace { @@ -520,9 +518,9 @@ void FontCfgWrapper::clear() } /* - * PrintFontManager::initFontconfig + * FontConfigManager::initFontconfig */ -void PrintFontManager::initFontconfig() +void FontConfigManager::initFontconfig() { FontCfgWrapper& rWrapper = FontCfgWrapper::get(); rWrapper.clear(); @@ -611,7 +609,7 @@ namespace } } -std::optional PrintFontManager::fontFromFcPattern(FcPattern* pPattern) +std::optional FontConfigManager::fontFromFcPattern(FcPattern* pPattern) { FontCfgWrapper& rWrapper = FontCfgWrapper::get(); @@ -696,7 +694,7 @@ std::optional PrintFontManager::fontFromFcPattern(FcPattern* pPa return aFont; } -std::vector PrintFontManager::fontsFromFontconfigFile(std::string_view rFilePath) +std::vector FontConfigManager::fontsFromFontconfigFile(std::string_view rFilePath) { std::vector aFonts; @@ -721,7 +719,7 @@ std::vector PrintFontManager::fontsFromFontconfigFile(std::strin return aFonts; } -void PrintFontManager::collectSystemFonts() +void FontConfigManager::collectSystemFonts() { FontCfgWrapper& rWrapper = FontCfgWrapper::get(); @@ -774,12 +772,12 @@ void PrintFontManager::collectSystemFonts() SAL_INFO("vcl.fonts", "collected " << m_aSystemFonts.size() << " fonts from fontconfig"); } -void PrintFontManager::deinitFontconfig() +void FontConfigManager::deinitFontconfig() { FontCfgWrapper::release(); } -void PrintFontManager::addFontconfigDir( const OString& rDirName ) +void FontConfigManager::addFontconfigDir( const OString& rDirName ) { const char* pDirName = rDirName.getStr(); bool bDirOk = (FcConfigAppFontAddDir(FcConfigGetCurrent(), reinterpret_cast(pDirName) ) == FcTrue); @@ -806,7 +804,7 @@ void PrintFontManager::addFontconfigDir( const OString& rDirName ) } } -void PrintFontManager::addFontconfigFile( const OString& rFileName ) +void FontConfigManager::addFontconfigFile( const OString& rFileName ) { const char* pFileName = rFileName.getStr(); bool bFileOk = (FcConfigAppFontAddFile(FcConfigGetCurrent(), reinterpret_cast(pFileName) ) == FcTrue); @@ -822,7 +820,7 @@ void PrintFontManager::addFontconfigFile( const OString& rFileName ) rWrapper.addFontSet( FcSetApplication ); } -void PrintFontManager::removeFontconfigFile(std::string_view aFileName) +void FontConfigManager::removeFontconfigFile(std::string_view aFileName) { FcFontSet* pOrig = FcConfigGetFonts(FcConfigGetCurrent(), FcSetApplication); if (!pOrig) @@ -1036,7 +1034,7 @@ namespace } } -IMPL_LINK_NOARG(PrintFontManager, autoInstallFontLangSupport, Timer *, void) +IMPL_LINK_NOARG(FontConfigManager, autoInstallFontLangSupport, Timer *, void) { try { @@ -1057,7 +1055,7 @@ IMPL_LINK_NOARG(PrintFontManager, autoInstallFontLangSupport, Timer *, void) m_aCurrentRequests.clear(); } -void PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUString& rMissingCodes) +void FontConfigManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUString& rMissingCodes) { FontCfgWrapper& rWrapper = FontCfgWrapper::get(); @@ -1279,7 +1277,7 @@ void PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri FcFontSetDestroy( pSet ); } - SAL_INFO("vcl.fonts", "PrintFontManager::Substitute: replacing missing font: '" + SAL_INFO("vcl.fonts", "FontConfigManager::Substitute: replacing missing font: '" << rPattern.maTargetName << "' with '" << rPattern.maSearchName << "'"); @@ -1300,7 +1298,7 @@ void PrintFontManager::Substitute(vcl::font::FontSelectPattern &rPattern, OUStri } if (rPattern.maTargetName == "Linux Libertine G" && rPattern.maSearchName == "Linux Libertine O") return; - SAL_WARN("vcl.fonts", "PrintFontManager::Substitute: missing font: '" << rPattern.maTargetName << + SAL_WARN("vcl.fonts", "FontConfigManager::Substitute: missing font: '" << rPattern.maTargetName << "' try: " << rPattern.maSearchName << " instead"); std::cerr << "terminating test due to missing font: " << rPattern.maTargetName << std::endl; std::abort(); @@ -1348,7 +1346,7 @@ void FontConfigFontOptions::SyncPattern(const OString& rFileName, sal_uInt32 nIn } } -std::unique_ptr PrintFontManager::getFontOptions(const FontAttributes& rInfo, int nSize) +std::unique_ptr FontConfigManager::getFontOptions(const FontAttributes& rInfo, int nSize) { FontOptionsKey aKey{ rInfo.GetFamilyName(), nSize, rInfo.GetItalic(), rInfo.GetWeight(), rInfo.GetWidthType(), rInfo.GetPitch() }; @@ -1392,7 +1390,7 @@ std::unique_ptr PrintFontManager::getFontOptions(const Fo } -bool PrintFontManager::matchFont(FontAttributes& rDFA, const css::lang::Locale& rLocale) +bool FontConfigManager::matchFont(FontAttributes& rDFA, const css::lang::Locale& rLocale) { bool bFound = false; FontCfgWrapper& rWrapper = FontCfgWrapper::get(); diff --git a/vcl/unx/generic/font/fontmanager.cxx b/vcl/unx/generic/font/fontmanager.cxx index ea13a4d091a3..1ac80e397304 100644 --- a/vcl/unx/generic/font/fontmanager.cxx +++ b/vcl/unx/generic/font/fontmanager.cxx @@ -41,21 +41,21 @@ using namespace psp; /* * one instance only */ -PrintFontManager& PrintFontManager::get() +FontConfigManager& FontConfigManager::get() { GenericUnixSalData* const pSalData(GetGenericUnixSalData()); assert(pSalData); - return *pSalData->GetPrintFontManager(); + return *pSalData->GetFontConfigManager(); } /* - * the PrintFontManager + * the FontConfigManager */ -PrintFontManager::PrintFontManager() - : m_aFontInstallerTimer("PrintFontManager m_aFontInstallerTimer") +FontConfigManager::FontConfigManager() + : m_aFontInstallerTimer("FontConfigManager m_aFontInstallerTimer") { - m_aFontInstallerTimer.SetInvokeHandler(LINK(this, PrintFontManager, autoInstallFontLangSupport)); + m_aFontInstallerTimer.SetInvokeHandler(LINK(this, FontConfigManager, autoInstallFontLangSupport)); m_aFontInstallerTimer.SetTimeout(5000); initFontconfig(); @@ -83,19 +83,19 @@ PrintFontManager::PrintFontManager() collectSystemFonts(); } -PrintFontManager::~PrintFontManager() +FontConfigManager::~FontConfigManager() { m_aFontInstallerTimer.Stop(); deinitFontconfig(); } -std::vector PrintFontManager::addFontFile(const OString& rFile) +std::vector FontConfigManager::addFontFile(const OString& rFile) { addFontconfigFile(rFile); return fontsFromFontconfigFile(rFile); } -void PrintFontManager::removeFontFile(std::string_view rFile) +void FontConfigManager::removeFontFile(std::string_view rFile) { removeFontconfigFile(rFile); } diff --git a/vcl/unx/generic/font/fontsubst.cxx b/vcl/unx/generic/font/fontsubst.cxx index 9bceaf894010..a54f072f2d03 100644 --- a/vcl/unx/generic/font/fontsubst.cxx +++ b/vcl/unx/generic/font/fontsubst.cxx @@ -64,7 +64,7 @@ void SalGenericInstance::RegisterFontSubstitutors(vcl::font::PhysicalFontCollect static vcl::font::FontSelectPattern GetFcSubstitute(const vcl::font::FontSelectPattern &rFontSelData, OUString& rMissingCodes) { vcl::font::FontSelectPattern aSubstituted(rFontSelData); - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + FontConfigManager& rMgr = FontConfigManager::get(); rMgr.Substitute(aSubstituted, rMissingCodes); return aSubstituted; } diff --git a/vcl/unx/generic/font/freetype_glyphcache.cxx b/vcl/unx/generic/font/freetype_glyphcache.cxx index fbc8192f0db8..a5b70c7b3f17 100644 --- a/vcl/unx/generic/font/freetype_glyphcache.cxx +++ b/vcl/unx/generic/font/freetype_glyphcache.cxx @@ -309,7 +309,7 @@ bool FreetypeFontList::AddFontFile(std::u16string_view rFileUrl, const OUString& if (m_aFontFileToFontId.contains(aFullPath)) return true; - std::vector aFonts = psp::PrintFontManager::get().addFontFile(aFullPath); + std::vector aFonts = FontConfigManager::get().addFontFile(aFullPath); if (aFonts.empty()) return false; @@ -338,7 +338,7 @@ void FreetypeFontList::RemoveFontFile(std::u16string_view rFileUrl) m_aFontFaceList.erase(nFontId); m_aFontFileToFontId.erase(it); - psp::PrintFontManager::removeFontFile(aFullPath); + FontConfigManager::removeFontFile(aFullPath); } const FreetypeFontFace* FreetypeFontList::FindFontFace(const OString& rFileName, int nFaceNum, @@ -498,7 +498,7 @@ namespace { std::unique_ptr GetFCFontOptions(const FontAttributes& rFontAttributes, int nSize) { - return psp::PrintFontManager::getFontOptions(rFontAttributes, nSize); + return FontConfigManager::getFontOptions(rFontAttributes, nSize); } } diff --git a/vcl/unx/generic/font/glyphcache.cxx b/vcl/unx/generic/font/glyphcache.cxx index b32895da452d..67d529443956 100644 --- a/vcl/unx/generic/font/glyphcache.cxx +++ b/vcl/unx/generic/font/glyphcache.cxx @@ -36,7 +36,7 @@ FreetypeFontList::FreetypeFontList() void FreetypeFontList::Init() { - for (const auto& rFont : psp::PrintFontManager::get().takeSystemFonts()) + for (const auto& rFont : FontConfigManager::get().takeSystemFonts()) { FontAttributes aDFA = rFont.m_aFontAttributes; aDFA.IncreaseQualityBy(4096); diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx b/vcl/unx/gtk3/salnativewidgets-gtk.cxx index 0a476a2e41c9..839e07581094 100644 --- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx @@ -2271,7 +2271,7 @@ vcl::Font pango_to_vcl(const PangoFontDescription* font, const css::lang::Locale #endif // match font to e.g. resolve "Sans" - bool bFound = psp::PrintFontManager::matchFont(aDFA, rLocale); + bool bFound = FontConfigManager::matchFont(aDFA, rLocale); #if OSL_DEBUG_LEVEL > 1 SAL_INFO("vcl.gtk3", "font match "