From 61bcbc8a14b9957968a5ff34cf75cf09c90ce588 Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Thu, 5 Jan 2012 11:54:44 +0000 Subject: [PATCH] bug 703100 - pt 2.4.1 - make gfxPangoFontGroup font-matching behavior more similar to generic gfxFontGroup version. r=roc --- gfx/thebes/gfxPangoFonts.cpp | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/gfx/thebes/gfxPangoFonts.cpp b/gfx/thebes/gfxPangoFonts.cpp index d0a9154c1ad..75db456055b 100644 --- a/gfx/thebes/gfxPangoFonts.cpp +++ b/gfx/thebes/gfxPangoFonts.cpp @@ -2048,28 +2048,23 @@ gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh, gfxFont *aPrevMatchedFont, PRUint8 *aMatchType) { - if (aPrevMatchedFont) { - PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh); - // If this character is a format character (including join-causers) - // or a variation selector, use the same font as the previous - // character, regardless of whether it supports the character. - // Otherwise the text run will be divided. - if ((category == HB_CATEGORY_CONTROL || - category == HB_CATEGORY_FORMAT || - gfxFontUtils::IsVarSelector(aCh))) { + // if this character is a join-control or the previous is a join-causer, + // use the same font as the previous range if we can + if (gfxFontUtils::IsJoinControl(aCh) || gfxFontUtils::IsJoinCauser(aPrevCh)) { + if (aPrevMatchedFont && aPrevMatchedFont->HasCharacter(aCh)) { return nsRefPtr(aPrevMatchedFont).forget(); } + } - // If the previous character is a space or a join-causer and the - // previous font supports this character, then use the same font. - // - // The fonts selected for spaces are usually ignored. Sticking with - // the same font avoids breaking the shaping run. - if (aCh == ' ' || - (gfxFontUtils::IsJoinCauser(aPrevCh) && - static_cast(aPrevMatchedFont)->GetGlyph(aCh))) { + // if this character is a variation selector, + // use the previous font regardless of whether it supports VS or not. + // otherwise the text run will be divided. + if (gfxFontUtils::IsVarSelector(aCh)) { + if (aPrevMatchedFont) { return nsRefPtr(aPrevMatchedFont).forget(); } + // VS alone. it's meaningless to search different fonts + return nsnull; } // The real fonts that fontconfig provides for generic/fallback families