Bug 1234418 - Not trust glyph run starts from a cluster start character. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 23 Dec 2015 11:01:37 +1100
changeset 317168 e49cb0de49a8b3c63c0947fd3d1072935746714e
parent 317167 f999a2018ff3f846a2bd338204284bab3fde4589
child 512261 21d72b35de81a9f6e303e9578d6ca83019ea3a50
push id8659
push userxquan@mozilla.com
push dateWed, 23 Dec 2015 00:01:58 +0000
bugs1234418
milestone46.0a1
Bug 1234418 - Not trust glyph run starts from a cluster start character.
gfx/thebes/gfxFont.cpp
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -1854,32 +1854,31 @@ gfxFont::DrawGlyphs(gfxShapedText       
 void
 gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
                            uint32_t aOffset, uint32_t aCount,
                            const EmphasisMarkDrawParams& aParams)
 {
     gfxFloat& inlineCoord = aParams.isVertical ? aPt->y : aPt->x;
     uint32_t markLength = aParams.mark->GetLength();
 
-    gfxFloat clusterStart = NAN;
+    gfxFloat clusterStart = -INFINITY;
     bool shouldDrawEmphasisMark = false;
     for (uint32_t i = 0, idx = aOffset; i < aCount; ++i, ++idx) {
         if (aParams.spacing) {
             inlineCoord += aParams.direction * aParams.spacing[i].mBefore;
         }
-        if (aShapedText->IsClusterStart(idx)) {
+        if (aShapedText->IsClusterStart(idx) || clusterStart == -INFINITY) {
             clusterStart = inlineCoord;
         }
         if (aShapedText->CharMayHaveEmphasisMark(idx)) {
             shouldDrawEmphasisMark = true;
         }
         inlineCoord += aParams.direction * aShapedText->GetAdvanceForGlyph(idx);
         if (shouldDrawEmphasisMark &&
             (i + 1 == aCount || aShapedText->IsClusterStart(idx + 1))) {
-            MOZ_ASSERT(!std::isnan(clusterStart), "Should have cluster start");
             gfxFloat clusterAdvance = inlineCoord - clusterStart;
             // Move the coord backward to get the needed start point.
             gfxFloat delta = (clusterAdvance + aParams.advance) / 2;
             inlineCoord -= delta;
             aParams.mark->Draw(aParams.context, *aPt, DrawMode::GLYPH_FILL,
                                0, markLength, nullptr, nullptr, nullptr);
             inlineCoord += delta;
             shouldDrawEmphasisMark = false;