From 032a35954c6ceb9ab76c728c7638408e0fc07972 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Thu, 14 Apr 2016 21:22:37 -0700 Subject: [PATCH] Don't do layout in hasGlyph for codepoint + vs In the case where the input is a base codepoint + a variation selector, the code currently checks hasVariationSelector and then does a layout, checking for a single glyph. However, HarfBuzz in some cases will change the VS into a space glyph, so hasGlyph will return false. This patch makes hasGlyph rely entirely on the hasVariationSelector method in the case of a base codepoint + a VS Bug: 27531970 Bug: 28182689 Change-Id: Id190c427149213509f2d779ec1aa330feb4b62d8 --- core/jni/android/graphics/Paint.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/jni/android/graphics/Paint.cpp b/core/jni/android/graphics/Paint.cpp index f46f45cc5e5d5..898cf77cb32dc 100644 --- a/core/jni/android/graphics/Paint.cpp +++ b/core/jni/android/graphics/Paint.cpp @@ -815,10 +815,15 @@ namespace PaintGlue { } if (prevCp != kStartOfString && - ((0xFE00 <= cp && cp <= 0xFE0F) || (0xE0100 <= cp && cp <= 0xE01EF)) && - !MinikinUtils::hasVariationSelector(typeface, prevCp, cp)) { - // No font has a glyph for the code point and variation selector pair. - return false; + ((0xFE00 <= cp && cp <= 0xFE0F) || (0xE0100 <= cp && cp <= 0xE01EF))) { + bool hasVS = MinikinUtils::hasVariationSelector(typeface, prevCp, cp); + if (!hasVS) { + // No font has a glyph for the code point and variation selector pair. + return false; + } else if (nChars == 1 && i + 1 == str.size()) { + // The string is just a codepoint and a VS, we have an authoritative answer + return true; + } } nChars++; prevCp = cp;