Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
index a9de6cdb9864eebfa05e207a4246040f87d5456d..895bb6c77785f5c555e36a190bee8022ab77db0b 100644 |
--- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
+++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
@@ -212,6 +212,27 @@ |
return advanceSoFar - initialAdvance; |
} |
+static inline unsigned countGraphemesInCluster(const UChar* str, |
+ unsigned strLength, uint16_t startIndex, uint16_t endIndex) |
+{ |
+ if (startIndex > endIndex) { |
+ uint16_t tempIndex = startIndex; |
+ startIndex = endIndex; |
+ endIndex = tempIndex; |
+ } |
+ uint16_t length = endIndex - startIndex; |
+ ASSERT(static_cast<unsigned>(startIndex + length) <= strLength); |
+ TextBreakIterator* cursorPosIterator = cursorMovementIterator(&str[startIndex], length); |
+ |
+ int cursorPos = cursorPosIterator->current(); |
+ int numGraphemes = -1; |
+ while (0 <= cursorPos) { |
+ cursorPos = cursorPosIterator->next(); |
+ numGraphemes++; |
+ } |
+ return numGraphemes < 0 ? 0 : numGraphemes; |
+} |
+ |
static inline void addEmphasisMark(GlyphBuffer* buffer, |
const GlyphData* emphasisData, FloatPoint glyphCenter, |
float midGlyphOffset) |
@@ -289,7 +310,7 @@ |
else |
clusterEnd = isRunEnd ? run->m_startIndex + run->m_numCharacters + runOffset : run->glyphToCharacterIndex(i + 1) + runOffset; |
- graphemesInCluster = countCharactersAndGraphemesInCluster(textRun.characters16(), textRun.charactersLength(), clusterStart, clusterEnd).graphemes; |
+ graphemesInCluster = countGraphemesInCluster(textRun.characters16(), textRun.charactersLength(), clusterStart, clusterEnd); |
if (!graphemesInCluster || !clusterAdvance) |
continue; |