Changeset 245393 in webkit
- Timestamp:
- May 16, 2019 2:31:16 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r245392 r245393 1 2019-05-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [FreeType] Some character sequences with a variation selector are not rendered 4 https://bugs.webkit.org/show_bug.cgi?id=197838 5 6 Reviewed by Michael Catanzaro. 7 8 We get the invalid glyph instead. See http://mts.io/2015/04/21/unicode-symbol-render-text-emoji/. In the table at 9 the end the Emoji and Text columns are not correctly rendered. It happens also when copying an emoji from 10 GtkEmojiChooser and pasting in WebKit text field, because GTK appends U+FE0F to all emojis to force the emoji 11 style. We need to take into account the variation selector when checking if a font can render a combining 12 sequence, using FT_Face_GetCharVariantIndex to get the right glyph in case of variation character present. 13 14 * platform/graphics/Font.cpp: 15 (WebCore::Font::platformSupportsCodePoint const): Add optional variation parameter. 16 (WebCore::Font::canRenderCombiningCharacterSequence const): Take into account variation selector characters 17 * platform/graphics/Font.h: 18 * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: 19 (WebCore::FontCascade::fontForCombiningCharacterSequence const): Check variation selectors 0xFE0E and 0xFE0F to 20 decide whether to use the emoji or text style. 21 * platform/graphics/cocoa/FontCocoa.mm: 22 (WebCore::Font::platformSupportsCodePoint const): Return false when a variation character is passed so that 23 characters are checked individually. 24 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 25 (WebCore::Font::platformSupportsCodePoint const): Use FT_Face_GetCharVariantIndex when a variation character is 26 passed. 27 * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp: 28 (WebCore::harfBuzzFontFunctions): Do not return true when FT_Face_GetCharVariantIndex returns 0. 29 1 30 2019-05-16 Greg Hughes <ghughes@apple.com> 2 31 -
trunk/Source/WebCore/platform/graphics/Font.cpp
r245094 r245393 34 34 #include <pal/spi/cocoa/CoreTextSPI.h> 35 35 #endif 36 #include "CharacterProperties.h" 36 37 #include "FontCache.h" 37 38 #include "FontCascade.h" … … 642 643 } 643 644 644 bool Font::platformSupportsCodePoint(UChar32 character ) const645 { 646 return glyphForCharacter(character);645 bool Font::platformSupportsCodePoint(UChar32 character, Optional<UChar32> variation) const 646 { 647 return variation ? false : glyphForCharacter(character); 647 648 } 648 649 #endif … … 672 673 ASSERT(isMainThread()); 673 674 674 for (UChar32 codePoint : StringView(characters, length).codePoints()) { 675 auto codePoints = StringView(characters, length).codePoints(); 676 auto it = codePoints.begin(); 677 auto end = codePoints.end(); 678 while (it != end) { 679 auto codePoint = *it; 680 ++it; 681 682 if (it != end && isVariationSelector(*it)) { 683 if (!platformSupportsCodePoint(codePoint, *it)) { 684 // Try the characters individually. 685 if (!supportsCodePoint(codePoint) || !supportsCodePoint(*it)) 686 return false; 687 } 688 ++it; 689 continue; 690 } 691 675 692 if (!supportsCodePoint(codePoint)) 676 693 return false; -
trunk/Source/WebCore/platform/graphics/Font.h
r239822 r245393 176 176 Glyph glyphForCharacter(UChar32) const; 177 177 bool supportsCodePoint(UChar32) const; 178 bool platformSupportsCodePoint(UChar32 ) const;178 bool platformSupportsCodePoint(UChar32, Optional<UChar32> variation = WTF::nullopt) const; 179 179 180 180 RefPtr<Font> systemFallbackFontForCharacter(UChar32, const FontDescription&, IsForPlatformFont) const; -
trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
r243049 r245393 116 116 117 117 bool isEmoji = characterSequenceIsEmoji(iterator, character, clusterLength); 118 bool preferColoredFont = isEmoji; 119 // U+FE0E forces text style. 120 // U+FE0F forces emoji style. 121 if (characters[length - 1] == 0xFE0E) 122 preferColoredFont = false; 123 else if (characters[length - 1] == 0xFE0F) 124 preferColoredFont = true; 118 125 119 126 const Font* baseFont = glyphDataForCharacter(character, false, NormalVariant).font; 120 127 if (baseFont 121 128 && (clusterLength == length || baseFont->canRenderCombiningCharacterSequence(characters, length)) 122 && (! isEmoji|| baseFont->platformData().isColorBitmapFont()))129 && (!preferColoredFont || baseFont->platformData().isColorBitmapFont())) 123 130 return baseFont; 124 131 … … 128 135 continue; 129 136 130 if (fallbackFont->canRenderCombiningCharacterSequence(characters, length) && (! isEmoji|| fallbackFont->platformData().isColorBitmapFont()))137 if (fallbackFont->canRenderCombiningCharacterSequence(characters, length) && (!preferColoredFont || fallbackFont->platformData().isColorBitmapFont())) 131 138 return fallbackFont; 132 139 } 133 140 134 if (auto systemFallback = FontCache::singleton().systemFallbackForCharacters(m_fontDescription, baseFont, IsForPlatformFont::No, isEmoji ? FontCache::PreferColoredFont::Yes : FontCache::PreferColoredFont::No, characters, length)) { 135 if (systemFallback->canRenderCombiningCharacterSequence(characters, length) && (!isEmoji || systemFallback->platformData().isColorBitmapFont())) 141 if (auto systemFallback = FontCache::singleton().systemFallbackForCharacters(m_fontDescription, baseFont, IsForPlatformFont::No, preferColoredFont ? FontCache::PreferColoredFont::Yes : FontCache::PreferColoredFont::No, characters, length)) { 142 if (systemFallback->canRenderCombiningCharacterSequence(characters, length) && (!preferColoredFont || systemFallback->platformData().isColorBitmapFont())) 143 return systemFallback.get(); 144 145 // In case of emoji, if fallback font is colored try again without the variation selector character. 146 if (isEmoji && characters[length - 1] == 0xFE0F && systemFallback->platformData().isColorBitmapFont() && systemFallback->canRenderCombiningCharacterSequence(characters, length - 1)) 136 147 return systemFallback.get(); 137 148 } -
trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm
r239427 r245393 614 614 } 615 615 616 bool Font::platformSupportsCodePoint(UChar32 character) const 617 { 616 bool Font::platformSupportsCodePoint(UChar32 character, Optional<UChar32> variation) const 617 { 618 if (variation) 619 return false; 620 618 621 UniChar codeUnits[2]; 619 622 CGGlyph glyphs[2]; -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r243049 r245393 202 202 } 203 203 204 bool Font::platformSupportsCodePoint(UChar32 character ) const204 bool Font::platformSupportsCodePoint(UChar32 character, Optional<UChar32> variation) const 205 205 { 206 206 CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont()); 207 207 if (FT_Face face = cairoFtFaceLocker.ftFace()) 208 return !!FcFreeTypeCharIndex(face, character);208 return variation ? !!FT_Face_GetCharVariantIndex(face, character, variation.value()) : !!FcFreeTypeCharIndex(face, character); 209 209 210 210 return false; -
trunk/Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
r243602 r245393 79 79 if (FT_Face ftFace = cairoFtFaceLocker.ftFace()) { 80 80 *glyph = FT_Face_GetCharVariantIndex(ftFace, unicode, variation); 81 return true;81 return !!*glyph; 82 82 } 83 83 return false;
Note: See TracChangeset
for help on using the changeset viewer.