diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index dfe83a79e4a..daca44bd8fe 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -2235,19 +2235,17 @@ gfxFontGroup::InitTextRun(gfxContext *aContext, PRUint32 matchedLength = range.Length(); gfxFont *matchedFont = (range.font ? range.font.get() : nsnull); - // create the glyph run for this range - aTextRun->AddGlyphRun(matchedFont ? matchedFont : mainFont, - runStart, (matchedLength > 0)); if (matchedFont) { + // create the glyph run for this range + aTextRun->AddGlyphRun(matchedFont, runStart, (matchedLength > 0)); + // do glyph layout and record the resulting positioned glyphs - if (!matchedFont->InitTextRun(aContext, aTextRun, aString, - runStart, matchedLength, - aRunScript)) { - // glyph layout failed! treat as missing glyphs - matchedFont = nsnull; - } - } - if (!matchedFont) { + matchedFont->InitTextRun(aContext, aTextRun, aString, + runStart, matchedLength, aRunScript); + } else { + // create the glyph run before calling SetMissing Glyph + aTextRun->AddGlyphRun(mainFont, runStart, matchedLength); + for (PRUint32 index = runStart; index < runStart + matchedLength; index++) { // Record the char code so we can draw a box with the Unicode value if (NS_IS_HIGH_SURROGATE(aString[index]) &&