diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2010-09-29 17:53:56 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2010-09-29 17:53:56 -0400 |
commit | eb660a1b9ecbdae6535d521be545910adff4e9f2 (patch) | |
tree | 148e490c06c3f886a9bc87de5572710373dd484a | |
parent | 0adac7d98c6e3d1b01bc943f0d99d7f4141fe59f (diff) |
Ported fontconfig-cache-pre-substitution.diff from ooo-build.linux-build-fridrich-20100930
-rw-r--r-- | vcl/unx/source/gdi/salgdi3.cxx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx index b9ac7b629c..fc89fa7e19 100644 --- a/vcl/unx/source/gdi/salgdi3.cxx +++ b/vcl/unx/source/gdi/salgdi3.cxx @@ -1993,6 +1993,11 @@ class FcPreMatchSubstititution { public: bool FindFontSubstitute( ImplFontSelectData& ) const; + +private: + typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > + CachedFontMapType; + mutable CachedFontMapType maCachedFontMap; }; class FcGlyphFallbackSubstititution @@ -2188,12 +2193,20 @@ bool FcPreMatchSubstititution::FindFontSubstitute( ImplFontSelectData &rFontSelD || 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) ) return false; + CachedFontMapType::const_iterator itr = maCachedFontMap.find(rFontSelData.maTargetName); + if (itr != maCachedFontMap.end()) + { + // Cached substitution pair + rFontSelData.maSearchName = itr->second; + return true; + } + rtl::OUString aDummy; const ImplFontSelectData aOut = GetFcSubstitute( rFontSelData, aDummy ); - // TODO: cache the font substitution suggestion - // FC doing it would be preferable because it knows the invariables - // e.g. FC knows the FC rule that all Arial gets replaced by LiberationSans - // whereas we would have to check for every size or attribute + + maCachedFontMap.insert( + CachedFontMapType::value_type(rFontSelData.maTargetName, aOut.maSearchName)); + if( !aOut.maSearchName.Len() ) return false; |