Bug 705594. Add pref to force global cmap-based font fallback. r=roc

This commit is contained in:
John Daggett 2012-03-09 11:05:40 +09:00
parent 4c96369b89
commit e84c096093
5 changed files with 39 additions and 3 deletions

View File

@ -150,6 +150,7 @@ SRGBOverrideObserver::Observe(nsISupports *aSubject,
#define GFX_PREF_HARFBUZZ_SCRIPTS "gfx.font_rendering.harfbuzz.scripts"
#define HARFBUZZ_SCRIPTS_DEFAULT mozilla::unicode::SHAPING_DEFAULT
#define GFX_PREF_FALLBACK_USE_CMAPS "gfx.font_rendering.fallback.always_use_cmaps"
#ifdef MOZ_GRAPHITE
#define GFX_PREF_GRAPHITE_SHAPING "gfx.font_rendering.graphite.enabled"
@ -233,6 +234,8 @@ gfxPlatform::gfxPlatform()
mUseHarfBuzzScripts = UNINITIALIZED_VALUE;
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
mDownloadableFontsSanitize = UNINITIALIZED_VALUE;
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
#ifdef MOZ_GRAPHITE
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;
#endif
@ -682,6 +685,17 @@ gfxPlatform::SanitizeDownloadedFonts()
return mDownloadableFontsSanitize;
}
bool
gfxPlatform::UseCmapsDuringSystemFallback()
{
if (mFallbackUsesCmaps == UNINITIALIZED_VALUE) {
mFallbackUsesCmaps =
Preferences::GetBool(GFX_PREF_FALLBACK_USE_CMAPS, false);
}
return mFallbackUsesCmaps;
}
#ifdef MOZ_GRAPHITE
bool
gfxPlatform::UseGraphiteShaping()
@ -1360,6 +1374,8 @@ gfxPlatform::FontsPrefsChanged(const char *aPref)
mAllowDownloadableFonts = UNINITIALIZED_VALUE;
} else if (!strcmp(GFX_DOWNLOADABLE_FONTS_SANITIZE, aPref)) {
mDownloadableFontsSanitize = UNINITIALIZED_VALUE;
} else if (!strcmp(GFX_PREF_FALLBACK_USE_CMAPS, aPref)) {
mFallbackUsesCmaps = UNINITIALIZED_VALUE;
#ifdef MOZ_GRAPHITE
} else if (!strcmp(GFX_PREF_GRAPHITE_SHAPING, aPref)) {
mGraphiteShapingEnabled = UNINITIALIZED_VALUE;

View File

@ -319,6 +319,11 @@ public:
*/
virtual bool FontHintingEnabled() { return true; }
/**
* Whether to check all font cmaps during system font fallback
*/
bool UseCmapsDuringSystemFallback();
#ifdef MOZ_GRAPHITE
/**
* Whether to use the SIL Graphite rendering engine
@ -465,6 +470,10 @@ protected:
PRInt8 mBidiNumeralOption;
// whether to always search font cmaps globally
// when doing system font fallback
PRInt8 mFallbackUsesCmaps;
// which scripts should be shaped with harfbuzz
PRInt32 mUseHarfBuzzScripts;

View File

@ -666,10 +666,12 @@ gfxPlatformFontList::InitLoader()
mNumFamilies = mFontFamiliesToLoad.Length();
}
bool
bool
gfxPlatformFontList::RunLoader()
{
PRUint32 i, endIndex = (mStartIndex + mIncrement < mNumFamilies ? mStartIndex + mIncrement : mNumFamilies);
bool loadCmaps = !UsesSystemFallback() ||
gfxPlatform::GetPlatform()->UseCmapsDuringSystemFallback();
// for each font family, load in various font info
for (i = mStartIndex; i < endIndex; i++) {
@ -685,8 +687,10 @@ gfxPlatformFontList::RunLoader()
continue;
}
// load the cmaps
familyEntry->ReadAllCMAPs();
// load the cmaps if needed
if (loadCmaps) {
familyEntry->ReadAllCMAPs();
}
// read in face names
familyEntry->ReadFaceNames(this, mNeedFullnamePostscriptNames);

View File

@ -161,6 +161,10 @@ protected:
const gfxFontStyle* aMatchStyle,
PRUint32& aCmapCount);
// whether system-based font fallback is used or not
// if system fallback is used, no need to load all cmaps
virtual bool UsesSystemFallback() { return false; }
// separate initialization for reading in name tables, since this is expensive
void InitOtherFamilyNames();

View File

@ -203,6 +203,9 @@ pref("gfx.downloadable_fonts.enabled", true);
pref("gfx.downloadable_fonts.fallback_delay", 3000);
pref("gfx.downloadable_fonts.sanitize", true);
// whether to always search all font cmaps during system font fallback
pref("gfx.font_rendering.fallback.always_use_cmaps", false);
#ifdef MOZ_GRAPHITE
pref("gfx.font_rendering.graphite.enabled", false);
#endif