From 785ffb9b41118bc63a9a580de34e66b648fc65ca Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Thu, 6 Nov 2008 02:02:51 -0800 Subject: [PATCH] Detect clusters in Indic scripts where an initial RA is reordered after the following consonant and vowel. Bug 428317, r=roc --- gfx/thebes/src/gfxAtsuiFonts.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/gfx/thebes/src/gfxAtsuiFonts.cpp b/gfx/thebes/src/gfxAtsuiFonts.cpp index e6f01df99e3..86bb74a0aab 100644 --- a/gfx/thebes/src/gfxAtsuiFonts.cpp +++ b/gfx/thebes/src/gfxAtsuiFonts.cpp @@ -1227,16 +1227,26 @@ PostLayoutCallback(ATSULineRef aLine, gfxTextRun *aRun, while (glyphCount < numGlyphs) { ATSLayoutRecord *glyph = &glyphRecords[glyphIndex + direction*glyphCount]; PRUint32 glyphOffset = glyph->originalOffset; + PRUint32 nextIndex = isRTL ? glyphIndex - 1 : glyphIndex + 1; + PRUint32 nextOffset; + if (nextIndex >= 0 && nextIndex < numGlyphs) { + ATSLayoutRecord *nextGlyph = &glyphRecords[nextIndex + direction*glyphCount]; + nextOffset = nextGlyph->originalOffset; + } + else + nextOffset = glyphOffset; allFlags |= glyph->flags; - if (glyphOffset <= lastOffset) { + if (glyphOffset <= lastOffset || nextOffset <= lastOffset) { // Always add the current glyph to the ligature group if it's for the same // character as a character whose glyph is already in the group, // or an earlier character. The latter can happen because ATSUI - // sometimes visually reorders glyphs; e.g. DEVANAGARI VOWEL I - // can have its glyph displayed before the glyph for the consonant that's - // it's logically after (even though this is all left-to-right text). - // In this case we need to make sure the glyph for the consonant - // is added to the group containing the vowel. + // sometimes visually reorders glyphs. One case of this is that DEVANAGARI + // VOWEL I can have its glyph displayed before the glyph for the consonant + // that it's logically after (even though this is all left-to-right text). + // Another case is that a sequence of RA; VIRAMA; ; is + // reordered to ; ; RA; VIRAMA. + // In these cases we need to make sure that the whole sequence of glyphs is + // processed as a single cluster. } else { // We could be at the end of a character group if (glyph->glyphID != ATSUI_SPECIAL_GLYPH_ID) {