Skip to content

Commit

Permalink
Bug 1407114 - part 4 - Handle fallback from styled to regular face if…
Browse files Browse the repository at this point in the history
… necessary when using font-families from preferences. r=jrmuizel
  • Loading branch information
jfkthame committed Oct 23, 2017
1 parent 3ea98ba commit 62f09f8
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions gfx/thebes/gfxTextRun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3389,7 +3389,9 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
for (j = 0; j < numPrefs; j++) {
// look up the appropriate face
gfxFontFamily *family = (*families)[j];
if (!family) continue;
if (!family) {
continue;
}

// if a pref font is used, it's likely to be used again in the same text run.
// the style doesn't change so the face lookup can be cached rather than calling
Expand All @@ -3401,8 +3403,12 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)

bool needsBold;
gfxFontEntry *fe = family->FindFontForStyle(mStyle, needsBold);
if (!fe) {
continue;
}

// if ch in cmap, create and return a gfxFont
if (fe && fe->HasCharacter(aCh)) {
if (fe->HasCharacter(aCh)) {
gfxFont* prefFont = fe->FindOrMakeFont(&mStyle, needsBold);
if (!prefFont) {
continue;
Expand All @@ -3414,6 +3420,21 @@ gfxFontGroup::WhichPrefFontSupportsChar(uint32_t aCh)
return prefFont;
}

// If we requested a styled font (bold and/or italic), and the char
// was not available, check the regular face as well.
if (!fe->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).
gfxFont* prefFont = FindFallbackFaceForChar(family, aCh);
if (prefFont) {
mLastPrefFamily = family;
mLastPrefFont = prefFont;
mLastPrefLang = charLang;
mLastPrefFirstFont = (i == 0 && j == 0);
return prefFont;
}
}
}
}

Expand Down

0 comments on commit 62f09f8

Please sign in to comment.