diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 2cb5dceb484d..aef3e484b23c 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -615,17 +615,33 @@ gfxPlatformFontList::CommonFontFallback(uint32_t aCh, uint32_t aNextCh, familyName.AppendASCII(fallbackFamily); gfxFontFamily *fallback = FindFamilyByCanonicalName(familyName); - if (!fallback) + if (!fallback) { continue; + } gfxFontEntry *fontEntry; bool needsBold; // ignored in the system fallback case // use first font in list that supports a given character fontEntry = fallback->FindFontForStyle(*aMatchStyle, needsBold); - if (fontEntry && fontEntry->HasCharacter(aCh)) { - *aMatchedFamily = fallback; - return fontEntry; + if (fontEntry) { + if (fontEntry->HasCharacter(aCh)) { + *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; + } + } } }