diff options
author | Khaled Hosny <khaled@libreoffice.org> | 2023-08-01 12:32:15 +0000 |
---|---|---|
committer | خالد حسني <khaled@libreoffice.org> | 2023-08-02 11:57:26 +0200 |
commit | b3911f617d6af1e4fa7a3ed47ff6b85502d8066b (patch) | |
tree | afb3e14b0827763b5618cb7eec27a0211afea28d | |
parent | 5a683f2d7c59bbb9ad93172f8dcf43e9efa56053 (diff) |
vcl: Fold two static method into their only call site
Change-Id: Ifa943bd658892d4fcf8e47a6abfa245fbcaa78a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155161
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
-rw-r--r-- | vcl/inc/unx/genpspgraphics.h | 6 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/freetypetextrender.cxx | 66 | ||||
-rw-r--r-- | vcl/unx/generic/print/genpspgraphics.cxx | 67 |
3 files changed, 60 insertions, 79 deletions
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h index 16cb2bd9d9d2..81734cd9988f 100644 --- a/vcl/inc/unx/genpspgraphics.h +++ b/vcl/inc/unx/genpspgraphics.h @@ -64,12 +64,6 @@ public: // helper methods static FontAttributes Info2FontAttributes(const psp::FastPrintFontInfo&); - // helper methods for sharing with FreeTypeTextRenderImpl - static void GetDevFontListHelper(vcl::font::PhysicalFontCollection*); - static bool AddTempDevFontHelper(vcl::font::PhysicalFontCollection* pFontCollection, - std::u16string_view rFileURL, - const OUString& rFontName); - // override all pure virtual methods virtual SalGraphicsImpl* GetImpl() const override { diff --git a/vcl/unx/generic/gdi/freetypetextrender.cxx b/vcl/unx/generic/gdi/freetypetextrender.cxx index 3a6891c7f8a8..e8eb6c4febab 100644 --- a/vcl/unx/generic/gdi/freetypetextrender.cxx +++ b/vcl/unx/generic/gdi/freetypetextrender.cxx @@ -93,11 +93,38 @@ FreeTypeTextRenderImpl::SetTextColor( Color nColor ) } } -bool FreeTypeTextRenderImpl::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCollection, - const OUString& rFileURL, - const OUString& rFontName ) +bool FreeTypeTextRenderImpl::AddTempDevFont(vcl::font::PhysicalFontCollection* pFontCollection, + const OUString& rFileURL, const OUString& rFontName) { - return GenPspGraphics::AddTempDevFontHelper(pFontCollection, rFileURL, rFontName); + // inform PSP font manager + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + std::vector<psp::fontID> aFontIds = rMgr.addFontFile(rFileURL); + if (aFontIds.empty()) + return false; + + FreetypeManager& rFreetypeManager = FreetypeManager::get(); + for (auto const& elem : aFontIds) + { + // prepare font data + psp::FastPrintFontInfo aInfo; + rMgr.getFontFastInfo(elem, aInfo); + if (!rFontName.isEmpty()) + aInfo.m_aFamilyName = rFontName; + + // inform glyph cache of new font + FontAttributes aDFA = GenPspGraphics::Info2FontAttributes(aInfo); + aDFA.IncreaseQualityBy(5800); + + int nFaceNum = rMgr.getFontFaceNumber(aInfo.m_nID); + int nVariantNum = rMgr.getFontFaceVariation(aInfo.m_nID); + + const OString& rFileName = rMgr.getFontFileSysPath(aInfo.m_nID); + rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); + } + + // announce new font to device's font list + rFreetypeManager.AnnounceFonts(pFontCollection); + return true; } void FreeTypeTextRenderImpl::ClearDevFontCache() @@ -105,9 +132,36 @@ void FreeTypeTextRenderImpl::ClearDevFontCache() FreetypeManager::get().ClearFontCache(); } -void FreeTypeTextRenderImpl::GetDevFontList( vcl::font::PhysicalFontCollection* pFontCollection ) +void FreeTypeTextRenderImpl::GetDevFontList(vcl::font::PhysicalFontCollection* pFontCollection) { - GenPspGraphics::GetDevFontListHelper(pFontCollection); + // prepare the FreetypeManager using psprint's font infos + FreetypeManager& rFreetypeManager = FreetypeManager::get(); + + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + ::std::vector<psp::fontID> aList; + psp::FastPrintFontInfo aInfo; + rMgr.getFontList(aList); + for (auto const& elem : aList) + { + if (!rMgr.getFontFastInfo(elem, aInfo)) + continue; + + // normalize face number to the FreetypeManager + int nFaceNum = rMgr.getFontFaceNumber(aInfo.m_nID); + int nVariantNum = rMgr.getFontFaceVariation(aInfo.m_nID); + + // inform FreetypeManager about this font provided by the PsPrint subsystem + FontAttributes aDFA = GenPspGraphics::Info2FontAttributes(aInfo); + aDFA.IncreaseQualityBy(4096); + const OString& rFileName = rMgr.getFontFileSysPath(aInfo.m_nID); + rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); + } + + // announce glyphcache fonts + rFreetypeManager.AnnounceFonts(pFontCollection); + + // register platform specific font substitutions if available + SalGenericInstance::RegisterFontSubstitutors(pFontCollection); } void FreeTypeTextRenderImpl::GetFontMetric( FontMetricDataRef& rxFontMetric, int nFallbackLevel ) diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx index a8f253629de7..9f08cf11b5f2 100644 --- a/vcl/unx/generic/print/genpspgraphics.cxx +++ b/vcl/unx/generic/print/genpspgraphics.cxx @@ -111,41 +111,6 @@ void GenPspGraphics::SetTextColor( Color nColor ) m_aTextRenderImpl.SetTextColor(nColor); } -bool GenPspGraphics::AddTempDevFontHelper( vcl::font::PhysicalFontCollection* pFontCollection, - std::u16string_view rFileURL, - const OUString& rFontName) -{ - // inform PSP font manager - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - std::vector<psp::fontID> aFontIds = rMgr.addFontFile( rFileURL ); - if( aFontIds.empty() ) - return false; - - FreetypeManager& rFreetypeManager = FreetypeManager::get(); - for (auto const& elem : aFontIds) - { - // prepare font data - psp::FastPrintFontInfo aInfo; - rMgr.getFontFastInfo( elem, aInfo ); - if (!rFontName.isEmpty()) - aInfo.m_aFamilyName = rFontName; - - // inform glyph cache of new font - FontAttributes aDFA = Info2FontAttributes( aInfo ); - aDFA.IncreaseQualityBy( 5800 ); - - int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); - int nVariantNum = rMgr.getFontFaceVariation( aInfo.m_nID ); - - const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); - } - - // announce new font to device's font list - rFreetypeManager.AnnounceFonts(pFontCollection); - return true; -} - bool GenPspGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCollection, const OUString& rFileURL, const OUString& rFontName ) @@ -153,38 +118,6 @@ bool GenPspGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCol return m_aTextRenderImpl.AddTempDevFont(pFontCollection, rFileURL, rFontName); } -void GenPspGraphics::GetDevFontListHelper( vcl::font::PhysicalFontCollection *pFontCollection ) -{ - // prepare the FreetypeManager using psprint's font infos - FreetypeManager& rFreetypeManager = FreetypeManager::get(); - - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - ::std::vector< psp::fontID > aList; - psp::FastPrintFontInfo aInfo; - rMgr.getFontList( aList ); - for (auto const& elem : aList) - { - if( !rMgr.getFontFastInfo( elem, aInfo ) ) - continue; - - // normalize face number to the FreetypeManager - int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); - int nVariantNum = rMgr.getFontFaceVariation( aInfo.m_nID ); - - // inform FreetypeManager about this font provided by the PsPrint subsystem - FontAttributes aDFA = Info2FontAttributes( aInfo ); - aDFA.IncreaseQualityBy( 4096 ); - const OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); - rFreetypeManager.AddFontFile(rFileName, nFaceNum, nVariantNum, aInfo.m_nID, aDFA); - } - - // announce glyphcache fonts - rFreetypeManager.AnnounceFonts(pFontCollection); - - // register platform specific font substitutions if available - SalGenericInstance::RegisterFontSubstitutors( pFontCollection ); -} - void GenPspGraphics::GetDevFontList( vcl::font::PhysicalFontCollection *pFontCollection ) { m_aTextRenderImpl.GetDevFontList(pFontCollection); |