Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 870523003: Check for Unicode in Font before ICU call (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Test patch - Convert to NFC for if diacritical marks are present Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« Source/platform/fonts/SimpleFontData.cpp ('K') | « Source/platform/fonts/SimpleFontData.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698