bug 716229 - don't switch fonts for non-printing control chars. r=roc
authorJonathan Kew <jfkthame@gmail.com>
Tue, 10 Jan 2012 20:40:30 +0000
changeset 85376 9c2ca2a79d79159fd470ee31763d439f1e884beb
parent 85375 018cfb14c03e95b679c793cfed1aeae941470771
child 85377 1da3bc5e4131746d99fe314e167e95f23af4c1c1
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs716229
milestone12.0a1
bug 716229 - don't switch fonts for non-printing control chars. r=roc
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxPangoFonts.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -3232,23 +3232,35 @@ gfxFontGroup::InitScriptRun(gfxContext *
 
 already_AddRefed<gfxFont>
 gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
                               PRInt32 aRunScript, gfxFont *aPrevMatchedFont,
                               PRUint8 *aMatchType)
 {
     nsRefPtr<gfxFont>    selectedFont;
 
-    // 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)) {
+    if (aPrevMatchedFont) {
+        // Don't switch fonts for control characters, regardless of
+        // whether they are present in the current font, as they won't
+        // actually be rendered (see bug 716229)
+        PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh);
+        if (category == HB_CATEGORY_CONTROL) {
             selectedFont = aPrevMatchedFont;
             return selectedFont.forget();
         }
+
+        // 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->HasCharacter(aCh)) {
+                selectedFont = aPrevMatchedFont;
+                return selectedFont.forget();
+            }
+        }
     }
 
     // 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) {
             selectedFont = aPrevMatchedFont;
--- a/gfx/thebes/gfxPangoFonts.cpp
+++ b/gfx/thebes/gfxPangoFonts.cpp
@@ -2043,22 +2043,33 @@ gfxPangoFontGroup::GetFontSet(PangoLangu
 }
 
 already_AddRefed<gfxFont>
 gfxPangoFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
                                    PRInt32 aRunScript,
                                    gfxFont *aPrevMatchedFont,
                                    PRUint8 *aMatchType)
 {
-    // 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)) {
+    if (aPrevMatchedFont) {
+        // Don't switch fonts for control characters, regardless of
+        // whether they are present in the current font, as they won't
+        // actually be rendered (see bug 716229)
+        PRUint8 category = gfxUnicodeProperties::GetGeneralCategory(aCh);
+        if (category == HB_CATEGORY_CONTROL) {
             return nsRefPtr<gfxFont>(aPrevMatchedFont).forget();
         }
+
+        // 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->HasCharacter(aCh)) {
+                return nsRefPtr<gfxFont>(aPrevMatchedFont).forget();
+            }
+        }
     }
 
     // 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<gfxFont>(aPrevMatchedFont).forget();