diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-09-03 16:15:18 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-09-03 17:01:38 +0100 |
commit | feddd3d87077abb2d5435804a9a4859286f6d86f (patch) | |
tree | fe5d61ee70ac4f940c33b61bdfca67bbf7b9a000 /vcl | |
parent | 402603793360fb058f84e2aa88d5fdcd6131334d (diff) |
Refetch fonts if new ones installed or old ones deinstalled
i.e. honour gtk-fontconfig-timestamp so that if we request a font from
packagekit to be installed, then we can auto-use it when it appears.
Change-Id: Id0d914a3f9cd589d9e8a87bf9be4b6e47de2e191
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/aqua/source/gdi/atsui/salgdi.cxx | 7 | ||||
-rw-r--r-- | vcl/aqua/source/gdi/coretext/salgdi.cxx | 7 | ||||
-rw-r--r-- | vcl/generic/fontmanager/fontconfig.cxx | 19 | ||||
-rw-r--r-- | vcl/generic/fontmanager/fontmanager.cxx | 4 | ||||
-rw-r--r-- | vcl/generic/glyphs/glyphcache.cxx | 7 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 5 | ||||
-rw-r--r-- | vcl/headless/svptext.cxx | 6 | ||||
-rw-r--r-- | vcl/inc/aqua/atsui/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/aqua/coretext/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/generic/genpspgraphics.h | 2 | ||||
-rw-r--r-- | vcl/inc/generic/glyphcache.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/ios/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/salgdi.h | 1 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/ios/source/gdi/salgdi.cxx | 7 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/generic/gdi/salgdi3.cxx | 6 | ||||
-rw-r--r-- | vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 11 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 5 |
21 files changed, 99 insertions, 6 deletions
diff --git a/vcl/aqua/source/gdi/atsui/salgdi.cxx b/vcl/aqua/source/gdi/atsui/salgdi.cxx index cd6824560842..561b96ce228a 100644 --- a/vcl/aqua/source/gdi/atsui/salgdi.cxx +++ b/vcl/aqua/source/gdi/atsui/salgdi.cxx @@ -528,6 +528,13 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) pSalData->mpFontList->AnnounceFonts( *pFontList ); } +void AquaSalGraphics::ClearDevFontList() +{ + SalData* pSalData = GetSalData(); + delete pSalData->mpFontList; + pSalData->mpFontList = NULL; +} + // ----------------------------------------------------------------------- bool AquaSalGraphics::AddTempDevFont( ImplDevFontList*, diff --git a/vcl/aqua/source/gdi/coretext/salgdi.cxx b/vcl/aqua/source/gdi/coretext/salgdi.cxx index 160cf18bf25b..0b8b77bf0b2f 100644 --- a/vcl/aqua/source/gdi/coretext/salgdi.cxx +++ b/vcl/aqua/source/gdi/coretext/salgdi.cxx @@ -78,6 +78,13 @@ void AquaSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) pSalData->mpFontList->AnnounceFonts( *pFontList ); } +void AquaSalGraphics::ClearDevFontList() +{ + SalData* pSalData = GetSalData(); + delete pSalData->mpFontList; + pSalData->mpFontList = NULL; +} + void AquaSalGraphics::GetDevFontSubstList( OutputDevice* ) { // nothing to do since there are no device-specific fonts on Aqua diff --git a/vcl/generic/fontmanager/fontconfig.cxx b/vcl/generic/fontmanager/fontconfig.cxx index 57a17c94f335..a98e52949e15 100644 --- a/vcl/generic/fontmanager/fontconfig.cxx +++ b/vcl/generic/fontmanager/fontconfig.cxx @@ -128,6 +128,8 @@ public: FcFontSet* getFontSet(); + void clear(); + public: FcResult LocalizedElementFromPattern(FcPattern* pPattern, FcChar8 **family, const char *elementtype, const char *elementlangtype); @@ -263,8 +265,7 @@ FcFontSet* FontCfgWrapper::getFontSet() FontCfgWrapper::~FontCfgWrapper() { - if( m_pOutlineSet ) - FcFontSetDestroy( m_pOutlineSet ); + clear(); //To-Do: get gtk vclplug smoketest to pass //FcFini(); } @@ -402,12 +403,24 @@ FcResult FontCfgWrapper::LocalizedElementFromPattern(FcPattern* pPattern, FcChar return eElementRes; } +void FontCfgWrapper::clear() +{ + m_aFontNameToLocalized.clear(); + m_aLocalizedToCanonical.clear(); + if( m_pOutlineSet ) + { + FcFontSetDestroy( m_pOutlineSet ); + m_pOutlineSet = NULL; + } +} + /* * PrintFontManager::initFontconfig */ void PrintFontManager::initFontconfig() { - FontCfgWrapper::get(); + FontCfgWrapper& rWrapper = FontCfgWrapper::get(); + rWrapper.clear(); } namespace diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 090cabbf107c..8199fc332d69 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -1673,7 +1673,9 @@ void PrintFontManager::initialize() #endif } - // initialize may be called twice in the future + // initialize can be called more than once, e.g. + // gtk-fontconfig-timestamp changes to reflect new font installed and + // PrintFontManager::initialize called again { for( ::boost::unordered_map< fontID, PrintFont* >::const_iterator it = m_aFonts.begin(); it != m_aFonts.end(); ++it ) delete (*it).second; diff --git a/vcl/generic/glyphs/glyphcache.cxx b/vcl/generic/glyphs/glyphcache.cxx index 923ca476895f..2ed37a79b14c 100644 --- a/vcl/generic/glyphs/glyphcache.cxx +++ b/vcl/generic/glyphs/glyphcache.cxx @@ -186,6 +186,13 @@ void GlyphCache::AnnounceFonts( ImplDevFontList* pList ) const mpFtManager->AnnounceFonts( pList ); } +void GlyphCache::ClearFontCache() +{ + InvalidateAllGlyphs(); + if (mpFtManager) + mpFtManager->ClearFontList(); +} + // ----------------------------------------------------------------------- ServerFont* GlyphCache::CacheFont( const FontSelectPattern& rFontSelData ) diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 78a6c1e046b6..c71103377ddb 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -912,6 +912,11 @@ void GenPspGraphics::GetDevFontList( ImplDevFontList *pList ) SalGenericInstance::RegisterFontSubstitutors( pList ); } +void GenPspGraphics::ClearDevFontCache() +{ + GlyphCache::GetInstance().ClearFontCache(); +} + void GenPspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) { const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName ); diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 5399a4ec751f..916c8e0a045d 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -362,6 +362,12 @@ void SvpSalGraphics::GetDevFontList( ImplDevFontList* pDevFontList ) ImplGetSVData()->maGDIData.mbNativeFontConfig = true; } +void SvpSalGraphics::ClearDevFontCache() +{ + GlyphCache& rGC = SvpGlyphCache::GetInstance(); + rGC.ClearFontCache(); +} + // --------------------------------------------------------------------------- void SvpSalGraphics::GetDevFontSubstList( OutputDevice* ) diff --git a/vcl/inc/aqua/atsui/salgdi.h b/vcl/inc/aqua/atsui/salgdi.h index 5827706f7f0e..7580f4f3ec1d 100644 --- a/vcl/inc/aqua/atsui/salgdi.h +++ b/vcl/inc/aqua/atsui/salgdi.h @@ -272,6 +272,8 @@ public: virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ); + // graphics must drop any cached font info + virtual void ClearDevFontCache(); // graphics should call ImplAddDevFontSubstitute on supplied // OutputDevice for all its device specific preferred font substitutions virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/inc/aqua/coretext/salgdi.h b/vcl/inc/aqua/coretext/salgdi.h index fb9f86318978..8786526e7722 100644 --- a/vcl/inc/aqua/coretext/salgdi.h +++ b/vcl/inc/aqua/coretext/salgdi.h @@ -201,6 +201,8 @@ public: virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ); + // graphics must drop any cached font info + virtual void ClearDevFontCache(); // graphics should call ImplAddDevFontSubstitute on supplied // OutputDevice for all its device specific preferred font substitutions virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index 177f09a20b46..3a7c0ce8794c 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -103,6 +103,8 @@ public: virtual const ImplFontCharMap* GetImplFontCharMap() const; virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; virtual void GetDevFontList( ImplDevFontList* ); + // graphics must drop any cached font info + virtual void ClearDevFontCache(); virtual void GetDevFontSubstList( OutputDevice* ); virtual bool AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL, const rtl::OUString& rFontName ); diff --git a/vcl/inc/generic/glyphcache.hxx b/vcl/inc/generic/glyphcache.hxx index 90551a6110e5..43189790d605 100644 --- a/vcl/inc/generic/glyphcache.hxx +++ b/vcl/inc/generic/glyphcache.hxx @@ -87,6 +87,7 @@ public: ServerFont* CacheFont( const FontSelectPattern& ); void UncacheFont( ServerFont& ); + void ClearFontCache(); void InvalidateAllGlyphs(); protected: diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index 9f2f9131025b..319e95de5d96 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -105,6 +105,7 @@ public: virtual const ImplFontCharMap* GetImplFontCharMap() const; virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; virtual void GetDevFontList( ImplDevFontList* ); + virtual void ClearDevFontCache(); virtual void GetDevFontSubstList( OutputDevice* ); virtual bool AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL, const rtl::OUString& rFontName ); virtual sal_Bool CreateFontSubset( const rtl::OUString& rToFile, diff --git a/vcl/inc/ios/salgdi.h b/vcl/inc/ios/salgdi.h index 1d9ef632dd79..9a2c044bc6ca 100644 --- a/vcl/inc/ios/salgdi.h +++ b/vcl/inc/ios/salgdi.h @@ -221,6 +221,8 @@ public: virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ); + // graphics must drop any cached font info + virtual void ClearDevFontCache(); // graphics should call ImplAddDevFontSubstitute on supplied // OutputDevice for all its device specific preferred font substitutions virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index 00e37e544279..43b00ff7d872 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -239,6 +239,8 @@ public: virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const = 0; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ) = 0; + // graphics must drop any cached font info + virtual void ClearDevFontCache() = 0; // graphics should call ImplAddDevFontSubstitute on supplied // OutputDevice for all its device specific preferred font substitutions virtual void GetDevFontSubstList( OutputDevice* ) = 0; diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 494a1dcd2783..8e539dbed962 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -243,6 +243,7 @@ public: virtual const ImplFontCharMap* GetImplFontCharMap() const; virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; virtual void GetDevFontList( ImplDevFontList* ); + virtual void ClearDevFontCache(); virtual void GetDevFontSubstList( OutputDevice* ); virtual bool AddTempDevFont( ImplDevFontList*, const rtl::OUString& rFileURL, const rtl::OUString& rFontName ); virtual sal_Bool CreateFontSubset( const rtl::OUString& rToFile, diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index f92849c898aa..ac451dfe8837 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -305,6 +305,8 @@ public: virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rGetFontCapabilities) const; // graphics must fill supplied font list virtual void GetDevFontList( ImplDevFontList* ); + // graphics must drop any cached font info + virtual void ClearDevFontCache(); // graphics should call ImplAddDevFontSubstitute on supplied // OutputDevice for all its device specific preferred font substitutions virtual void GetDevFontSubstList( OutputDevice* ); diff --git a/vcl/ios/source/gdi/salgdi.cxx b/vcl/ios/source/gdi/salgdi.cxx index 252508677448..ebf643091fca 100644 --- a/vcl/ios/source/gdi/salgdi.cxx +++ b/vcl/ios/source/gdi/salgdi.cxx @@ -104,6 +104,13 @@ void IosSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) pSalData->mpFontList->AnnounceFonts( *pFontList ); } +void IosSalGraphics::ClearDevFontList() +{ + SalData* pSalData = GetSalData(); + delete pSalData->mpFontList; + pSalData->mpFontList = NULL; +} + void IosSalGraphics::GetDevFontSubstList( OutputDevice* ) { // nothing to do since there are no device-specific fonts on Ios diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 226ec08b98f9..049b13eddcb3 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -299,8 +299,12 @@ void OutputDevice::ImplUpdateAllFontData( bool bNewFontLists ) if ( pFrame ) { if ( pFrame->ImplGetGraphics() ) + { // MT: Stupid typecast here and somewhere ((OutputDevice*)&aVDev)->, because bug in .NET2002 compiler. - ((OutputDevice*)pFrame)->mpGraphics->GetDevFontList( pFrame->mpWindowImpl->mpFrameData->mpFontList ); + OutputDevice *pDevice = (OutputDevice*)pFrame; + pDevice->mpGraphics->ClearDevFontCache(); + pDevice->mpGraphics->GetDevFontList(pFrame->mpWindowImpl->mpFrameData->mpFontList); + } } } } diff --git a/vcl/unx/generic/gdi/salgdi3.cxx b/vcl/unx/generic/gdi/salgdi3.cxx index 89e524e443c9..a532fc239e32 100644 --- a/vcl/unx/generic/gdi/salgdi3.cxx +++ b/vcl/unx/generic/gdi/salgdi3.cxx @@ -573,7 +573,11 @@ bool X11SalGraphics::AddTempDevFont( ImplDevFontList* pFontList, return true; } -// ---------------------------------------------------------------------------- +void X11SalGraphics::ClearDevFontCache() +{ + X11GlyphCache& rGC = X11GlyphCache::GetInstance(); + rGC.ClearFontCache(); +} void X11SalGraphics::GetDevFontList( ImplDevFontList *pList ) { diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 011e755a51a9..da3cc507ddc7 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -3699,6 +3699,17 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings ) GtkSettings* pSettings = gtk_widget_get_settings( m_pWindow ); StyleSettings aStyleSet = rSettings.GetStyleSettings(); + guint latest_fontconfig_timestamp = 0; + static guint our_fontconfig_timestamp = 0; + g_object_get( pSettings, "gtk-fontconfig-timestamp", &latest_fontconfig_timestamp, (char *)NULL ); + if (latest_fontconfig_timestamp != our_fontconfig_timestamp) + { + bool bFirstTime = our_fontconfig_timestamp == 0; + our_fontconfig_timestamp = latest_fontconfig_timestamp; + if (!bFirstTime) + psp::PrintFontManager::get().initialize(); + } + // get the widgets in place NWEnsureGTKMenu( m_nXScreen ); NWEnsureGTKMenubar( m_nXScreen ); diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index ebb1edc69b6d..c1407d2e4063 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -2282,6 +2282,11 @@ void WinSalGraphics::GetDevFontList( ImplDevFontList* pFontList ) pFontList->SetFallbackHook( &aSubstFallback ); } +void WinSalGraphics::ClearDevFontList() +{ + //anything to do here ? +} + // ---------------------------------------------------------------------------- void WinSalGraphics::GetDevFontSubstList( OutputDevice* ) |