diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2016-11-04 05:06:54 +0200 |
---|---|---|
committer | Khaled Hosny <khaledhosny@eglug.org> | 2016-11-04 05:13:03 +0200 |
commit | fb823544468150a2ef660095a511636be1bf6f9e (patch) | |
tree | 3a7bda105989d988347bf9c947e4f666e67462f5 /vcl/source/font | |
parent | a6ce5d391476e4b6a2cb2d92ff45548c1d75684b (diff) |
Font features are not a Graphite-only feature
We parse features appended to font names in CommonSalLayout as well, so
code that takes care of their presence (striping them when searching,
hashing, etc.) should not be dependent on the old Graphite support or it
will not work when old Graphite is disabled (e.g. on macOS).
Change-Id: If040782a86ec76d3743baf4d2b1d7a194e8e13f2
Diffstat (limited to 'vcl/source/font')
-rw-r--r-- | vcl/source/font/PhysicalFontCollection.cxx | 21 | ||||
-rw-r--r-- | vcl/source/font/fontcache.cxx | 11 | ||||
-rw-r--r-- | vcl/source/font/fontselect.cxx | 11 |
3 files changed, 12 insertions, 31 deletions
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx index 0f7449719fc9..716811b5af21 100644 --- a/vcl/source/font/PhysicalFontCollection.cxx +++ b/vcl/source/font/PhysicalFontCollection.cxx @@ -18,9 +18,6 @@ */ #include <config_graphite.h> -#if ENABLE_GRAPHITE -#include "graphite_features.hxx" -#endif #include <i18nlangtag/mslangid.hxx> #include <unotools/configmgr.hxx> #include <unotools/fontdefs.hxx> @@ -989,22 +986,18 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r rFSD.maTargetName = GetNextFontToken( rFSD.GetFamilyName(), nTokenPos ); aSearchName = rFSD.maTargetName; -#if ENABLE_GRAPHITE // Until features are properly supported, they are appended to the // font name, so we need to strip them off so the font is found. - sal_Int32 nFeat = aSearchName.indexOf(grutils::GrFeatureParser::FEAT_PREFIX); + sal_Int32 nFeat = aSearchName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX); OUString aOrigName = rFSD.maTargetName; OUString aBaseFontName = aSearchName.copy( 0, (nFeat != -1) ? nFeat : aSearchName.getLength() ); - if (nFeat != -1 && - -1 != aSearchName.indexOf(grutils::GrFeatureParser::FEAT_ID_VALUE_SEPARATOR, nFeat)) + if (nFeat != -1) { aSearchName = aBaseFontName; rFSD.maTargetName = aBaseFontName; } -#endif - aSearchName = GetEnglishSearchFontName( aSearchName ); ImplFontSubstitute( aSearchName ); // #114999# special emboldening for Ricoh fonts @@ -1035,10 +1028,9 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r } } -#if ENABLE_GRAPHITE // restore the features to make the font selection data unique rFSD.maTargetName = aOrigName; -#endif + // check if the current font name token or its substitute is valid PhysicalFontFamily* pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); if( pFoundData ) @@ -1047,10 +1039,9 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r // some systems provide special customization // e.g. they suggest "serif" as UI-font, but this name cannot be used directly // because the system wants to map it to another font first, e.g. "Helvetica" -#if ENABLE_GRAPHITE + // use the target name to search in the prematch hook rFSD.maTargetName = aBaseFontName; -#endif // Related: fdo#49271 RTF files often contain weird-ass // Win 3.1/Win95 style fontnames which attempt to put the @@ -1071,11 +1062,11 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r if( mpPreMatchHook->FindFontSubstitute( rFSD ) ) aSearchName = GetEnglishSearchFontName( aSearchName ); } -#if ENABLE_GRAPHITE + // the prematch hook uses the target name to search, but we now need // to restore the features to make the font selection data unique rFSD.maTargetName = aOrigName; -#endif + pFoundData = ImplFindFontFamilyBySearchName( aSearchName ); if( pFoundData ) return pFoundData; diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx index 4991b6d0d389..216283263931 100644 --- a/vcl/source/font/fontcache.cxx +++ b/vcl/source/font/fontcache.cxx @@ -24,11 +24,6 @@ #include "PhysicalFontFace.hxx" #include "PhysicalFontFamily.hxx" -#include <config_graphite.h> -#if ENABLE_GRAPHITE -#include "graphite_features.hxx" -#endif - size_t ImplFontCache::IFSD_Hash::operator()( const FontSelectPattern& rFSD ) const { return rFSD.hashCode(); @@ -73,14 +68,12 @@ bool ImplFontCache::IFSD_Equal::operator()(const FontSelectPattern& rA, const Fo return false; } -#if ENABLE_GRAPHITE // check for features - if ((rA.maTargetName.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + if ((rA.maTargetName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) != -1 || - rB.maTargetName.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + rB.maTargetName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) != -1) && rA.maTargetName != rB.maTargetName) return false; -#endif if (rA.mbEmbolden != rB.mbEmbolden) return false; diff --git a/vcl/source/font/fontselect.cxx b/vcl/source/font/fontselect.cxx index 3745f041b5dd..f4b4f77ca3a5 100644 --- a/vcl/source/font/fontselect.cxx +++ b/vcl/source/font/fontselect.cxx @@ -22,10 +22,9 @@ #include <PhysicalFontFace.hxx> #include "svdata.hxx" -#include <config_graphite.h> -#if ENABLE_GRAPHITE -#include "graphite_features.hxx" -#endif +// These mustn't conflict with font name lists which use ; and , +const char FontSelectPatternAttributes::FEAT_PREFIX = ':'; +const char FontSelectPatternAttributes::FEAT_SEPARATOR = '&'; FontSelectPattern::FontSelectPattern( const vcl::Font& rFont, const OUString& rSearchName, const Size& rSize, float fExactHeight) @@ -105,15 +104,13 @@ size_t FontSelectPatternAttributes::hashCode() const { // TODO: does it pay off to improve this hash function? size_t nHash; -#if ENABLE_GRAPHITE // check for features and generate a unique hash if necessary - if (maTargetName.indexOf(grutils::GrFeatureParser::FEAT_PREFIX) + if (maTargetName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) != -1) { nHash = maTargetName.hashCode(); } else -#endif { nHash = maSearchName.hashCode(); } |