Bug 1716433 - Create a pref to determine whether Windows font substitutes are applied always, or only as fallback for unavailable fonts. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D117890
This commit is contained in:
Jonathan Kew 2021-06-15 16:44:24 +00:00
parent 9d84e30617
commit 758d22f014
2 changed files with 28 additions and 11 deletions

View File

@ -1487,7 +1487,7 @@ void gfxDWriteFontList::InitSharedFontListForPlatform() {
"gfx.font_rendering.cleartype_params.force_gdi_classic_max_size",
mForceGDIClassicMaxFontSize);
mFontSubstitutes.Clear();
mSubstitutions.Clear();
mNonExistingFonts.Clear();
RefPtr<IDWriteFactory> factory = Factory::GetDWriteFactory();
@ -1894,12 +1894,16 @@ nsresult gfxDWriteFontList::GetFontSubstitutes() {
RemoveCharsetFromFontSubstitute(actualFontName);
BuildKeyNameFromFontName(actualFontName);
if (SharedFontList()) {
// Skip substitution if the original font is available, unless the option
// to apply substitutions unconditionally is enabled.
if (!StaticPrefs::gfx_windows_font_substitutes_always_AtStartup()) {
// Font substitutions are recorded for the canonical family names; we
// don't need FindFamily to consider localized aliases when searching.
if (SharedFontList()->FindFamily(substituteName,
/*aPrimaryNameOnly*/ true)) {
continue;
}
}
if (SharedFontList()->FindFamily(actualFontName,
/*aPrimaryNameOnly*/ true)) {
mSubstitutions.InsertOrUpdate(substituteName,
@ -1943,12 +1947,16 @@ void gfxDWriteFontList::GetDirectWriteSubstitutes() {
nsAutoCString substituteName(sub.aliasName);
BuildKeyNameFromFontName(substituteName);
if (SharedFontList()) {
// Skip substitution if the original font is available, unless the option
// to apply substitutions unconditionally is enabled.
if (!StaticPrefs::gfx_windows_font_substitutes_always_AtStartup()) {
// We don't need FindFamily to consider localized aliases when searching
// for the DirectWrite substitutes, we know the canonical names.
if (SharedFontList()->FindFamily(substituteName,
/*aPrimaryNameOnly*/ true)) {
continue;
}
}
nsAutoCString actualFontName(sub.actualName);
BuildKeyNameFromFontName(actualFontName);
if (SharedFontList()->FindFamily(actualFontName,

View File

@ -4636,6 +4636,15 @@
value: true
mirror: once
# [Windows] Whether registry FontSubstitutes entries are used unconditionally,
# or only if the original font is not available.
#if defined(XP_WIN)
- name: gfx.windows-font-substitutes.always
type: bool
value: false
mirror: once
#endif
- name: gfx.font-list-omt.enabled
type: bool
#if defined(XP_MACOSX)