Bug 1234418 - Not trust glyph run starts from a cluster start character. r=jfkthame

This commit is contained in:
Xidorn Quan 2015-12-29 09:48:37 +11:00
parent 055d6fade6
commit 0d34f11ff8

View File

@ -1859,13 +1859,13 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
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)) {
@ -1874,7 +1874,6 @@ gfxFont::DrawEmphasisMarks(gfxTextRun* aShapedText, gfxPoint* aPt,
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;