Bug 1234418 - Not trust glyph run starts from a cluster start character.
--- 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;