bug 619511 - don't let font fallback on ZWJ propagate to following character. r=jdaggett a=joe
authorJonathan Kew <jfkthame@gmail.com>
Thu, 13 Jan 2011 10:58:26 +0000
changeset 60435 70d10ef482f33bb1b1a5962887b2d88b61a0744c
parent 60434 8e3576dbc2f86e94ee91fed764ee5b023a59ffe1
child 60436 92e1764dc18047585a467600985bde2ea4d4d5a9
push id17990
push userjkew@mozilla.com
push dateThu, 13 Jan 2011 12:51:32 +0000
treeherdermozilla-central@70d10ef482f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett, joe
bugs619511
milestone2.0b10pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 619511 - don't let font fallback on ZWJ propagate to following character. r=jdaggett a=joe
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2539,50 +2539,58 @@ void gfxFontGroup::ComputeRanges(nsTArra
 
     aRanges.Clear();
 
     if (len == 0) {
         return;
     }
 
     PRUint32 prevCh = 0;
+    gfxFont *prevFont = nsnull;
+
     for (PRUint32 i = 0; i < len; i++) {
 
         const PRUint32 origI = i; // save off in case we increase for surrogate
 
         // set up current ch
         PRUint32 ch = str[i];
         if ((i+1 < len) && NS_IS_HIGH_SURROGATE(ch) && NS_IS_LOW_SURROGATE(str[i+1])) {
             i++;
             ch = SURROGATE_TO_UCS4(ch, str[i]);
         }
 
         // find the font for this char
         nsRefPtr<gfxFont> font =
-            FindFontForChar(ch, prevCh, aRunScript,
-                            (aRanges.Length() == 0) ?
-                            nsnull : aRanges[aRanges.Length() - 1].font.get());
+            FindFontForChar(ch, prevCh, aRunScript, prevFont);
 
         prevCh = ch;
 
         if (aRanges.Length() == 0) {
             // first char ==> make a new range
             gfxTextRange r(0,1);
             r.font = font;
             aRanges.AppendElement(r);
+            prevFont = font;
         } else {
             // if font has changed, make a new range
             gfxTextRange& prevRange = aRanges[aRanges.Length() - 1];
             if (prevRange.font != font) {
                 // close out the previous range
                 prevRange.end = origI;
 
                 gfxTextRange r(origI, i+1);
                 r.font = font;
                 aRanges.AppendElement(r);
+
+                // update prevFont for the next match, *unless* we switched
+                // fonts on a ZWJ, in which case propagating the changed font
+                // is probably not a good idea (see bug 619511)
+                if (!gfxFontUtils::IsJoinCauser(ch)) {
+                    prevFont = font;
+                }
             }
         }
     }
     aRanges[aRanges.Length()-1].end = len;
 }
 
 gfxUserFontSet* 
 gfxFontGroup::GetUserFontSet()