Chromium Code Reviews| Index: Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
| diff --git a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
| index a90b9252c8752960a9b220d2bf0cb1a36bc95377..41edd0ad321964cad35a903bdd3bf3d00d594d9a 100644 |
| --- a/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
| +++ b/Source/platform/fonts/shaping/HarfBuzzShaper.cpp |
| @@ -359,6 +359,29 @@ static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest |
| source = run.characters16(); |
| } |
| + // Convert to NFC form if the text has diacritical marks. |
| + icu::UnicodeString normalizedString; |
| + UErrorCode errorICU = U_ZERO_ERROR; |
| + |
| + for (unsigned i = 0; i < (unsigned)run.length(); ++i) { |
|
eae
2015/02/10 15:40:12
Here and elsewhere, use static_cast instead of C-s
h.joshi
2015/02/17 03:44:47
Done.
|
| + UChar ch = source[i]; |
|
eae
2015/02/10 15:40:12
Only used once, no need for local variable.
h.joshi
2015/02/17 03:44:47
Done.
|
| + if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) { |
| + icu::Normalizer::normalize(icu::UnicodeString(source, |
| + run.length()), UNORM_NFC, 0 /* no options */, |
| + normalizedString, errorICU); |
| + if (U_FAILURE(errorICU)) |
| + normalizedString.remove(); |
| + break; |
| + } |
| + } |
| + |
| + if (normalizedString.isEmpty()) { |
| + length = (unsigned)run.length(); |
| + } else { |
| + length = (unsigned)normalizedString.length(); |
| + source = normalizedString.getBuffer(); |
| + } |
| + |
| *destinationLength = 0; |
| while (position < length) { |
| UChar32 character; |
| @@ -564,12 +587,21 @@ static inline int handleMultipleUChar( |
| const UChar* markCharactersEnd, |
| const UChar* normalizedBufferEnd) |
| { |
| + ASSERT(currentFontData); |
| if (U_GET_GC_MASK(character) & U_GC_M_MASK) { |
| + /* If current font does not have Unicode, we should not go further. |
| + Blink will fallback to some other font to display this Unicode. |
| + */ |
| + if (!currentFontData->fontHasGlyphForCharacter(character)) |
| + return 0; |
| + |
| int markLength = clusterLength; |
| while (markCharactersEnd < normalizedBufferEnd) { |
| UChar32 nextCharacter; |
| int nextCharacterLength = 0; |
| U16_NEXT(markCharactersEnd, nextCharacterLength, normalizedBufferEnd - markCharactersEnd, nextCharacter); |
| + if (!currentFontData->fontHasGlyphForCharacter(nextCharacter)) |
| + return 0; |
| if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK)) |
| break; |
| markLength += nextCharacterLength; |