Bug 1407114 - part 3 - Handle fallback from styled to regular face if necessary when checking the platform's common fallback fonts. r=jrmuizel

This commit is contained in:
Jonathan Kew 2017-10-23 22:31:57 +01:00
parent 6ade77d1f6
commit 3ea98ba522

View File

@ -615,17 +615,33 @@ gfxPlatformFontList::CommonFontFallback(uint32_t aCh, uint32_t aNextCh,
familyName.AppendASCII(fallbackFamily); familyName.AppendASCII(fallbackFamily);
gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName); gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName);
if (!fallback) if (!fallback) {
continue; continue;
}
gfxFontEntry *fontEntry; gfxFontEntry *fontEntry;
bool needsBold; // ignored in the system fallback case bool needsBold; // ignored in the system fallback case
// use first font in list that supports a given character // use first font in list that supports a given character
fontEntry = fallback->FindFontForStyle(*aMatchStyle, needsBold); fontEntry = fallback->FindFontForStyle(*aMatchStyle, needsBold);
if (fontEntry && fontEntry->HasCharacter(aCh)) { if (fontEntry) {
*aMatchedFamily = fallback; if (fontEntry->HasCharacter(aCh)) {
return fontEntry; *aMatchedFamily = fallback;
return fontEntry;
}
// If we requested a styled font (bold and/or italic), and the char
// was not available, check other faces of the family.
if (!fontEntry->IsNormalStyle()) {
// If style/weight/stretch was not Normal, see if we can
// fall back to a next-best face (e.g. Arial Black -> Bold,
// or Arial Narrow -> Regular).
GlobalFontMatch data(aCh, aMatchStyle);
fallback->SearchAllFontsForChar(&data);
if (data.mBestMatch) {
*aMatchedFamily = fallback;
return data.mBestMatch;
}
}
} }
} }