Changeset 239822 in webkit
- Timestamp:
- Jan 10, 2019 2:03:53 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r239821 r239822 1 2019-01-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [FreeType] Color emoji not properly supported 4 https://bugs.webkit.org/show_bug.cgi?id=191976 5 6 Reviewed by Michael Catanzaro. 7 8 Add new test to ensure we fallback to noto color emoji for emojis. 9 10 * platform/gtk/fonts/font-emoji-system-fallback-expected.html: Added. 11 * platform/gtk/fonts/font-emoji-system-fallback.html: Added. 12 1 13 2019-01-10 cathie chen <cathiechen@igalia.com> 2 14 -
trunk/Source/WTF/ChangeLog
r239813 r239822 1 2019-01-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [FreeType] Color emoji not properly supported 4 https://bugs.webkit.org/show_bug.cgi?id=191976 5 6 Reviewed by Michael Catanzaro. 7 8 Add a name for combining enclosing keycap character. 9 10 * wtf/unicode/CharacterNames.h: 11 1 12 2019-01-09 Carlos Eduardo Ramalho <cadubentzen@gmail.com> and Fujii Hironori <Hironori.Fujii@sony.com> 2 13 -
trunk/Source/WTF/wtf/unicode/CharacterNames.h
r237099 r239822 47 47 const UChar bullseye = 0x25CE; 48 48 const UChar carriageReturn = 0x000D; 49 const UChar combiningEnclosingKeycap = 0x20E3; 49 50 const UChar ethiopicPrefaceColon = 0x1366; 50 51 const UChar ethiopicWordspace = 0x1361; … … 115 116 using WTF::Unicode::bullseye; 116 117 using WTF::Unicode::carriageReturn; 118 using WTF::Unicode::combiningEnclosingKeycap; 117 119 using WTF::Unicode::ethiopicPrefaceColon; 118 120 using WTF::Unicode::ethiopicWordspace; -
trunk/Source/WebCore/ChangeLog
r239820 r239822 1 2019-01-10 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [FreeType] Color emoji not properly supported 4 https://bugs.webkit.org/show_bug.cgi?id=191976 5 6 Reviewed by Michael Catanzaro. 7 8 Always try to fallback to a colored font for emojis. 9 10 Test: platform/gtk/fonts/font-emoji-system-fallback.html 11 12 * platform/graphics/ComplexTextController.cpp: 13 (WebCore::advanceByCombiningCharacterSequence): Group regional indicators in pairs. 14 * platform/graphics/Font.cpp: 15 (WebCore::CharacterFallbackMapKey::CharacterFallbackMapKey): 16 (WebCore::Font::systemFallbackFontForCharacter const): Pass PreferColoredFont::No to FontCache::systemFallbackForCharacters. 17 * platform/graphics/Font.h: Add IsForPlatformFont enum to replace the bool parameter in systemFallbackFontForCharacter(). 18 * platform/graphics/FontCache.h: 19 * platform/graphics/FontCascadeFonts.cpp: 20 (WebCore::FontCascadeFonts::glyphDataForSystemFallback): 21 * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: 22 (WebCore::characterSequenceIsEmoji): Check whether the character sequence is an emoji. 23 (WebCore::FontCascade::fontForCombiningCharacterSequence const): In case of emojis try to fallback to a colored 24 font even if base font can render the emoji in black and white. 25 * platform/graphics/cocoa/FontCacheCoreText.cpp: 26 (WebCore::FontCache::systemFallbackForCharacters): Add PreferColoredFont parameter that is ignored. 27 * platform/graphics/freetype/FontCacheFreeType.cpp: 28 (WebCore::FontCache::systemFallbackForCharacters): Add PreferColoredFont parameter. 29 * platform/graphics/freetype/FontPlatformDataFreeType.cpp: 30 (WebCore::FontPlatformData::FontPlatformData): Initialize m_isColorBitmapFont. 31 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 32 (WebCore::Font::variantCapsSupportsCharacterForSynthesis const): Moved from cross-platform file. 33 (WebCore::Font::platformSupportsCodePoint const): Add freetype implementation. 34 * platform/graphics/win/FontCacheWin.cpp: 35 (WebCore::FontCache::systemFallbackForCharacters): Add PreferColoredFont parameter that is ignored. 36 * platform/text/CharacterProperties.h: 37 (WebCore::isEmojiKeycapBase): 38 (WebCore::isEmojiRegionalIndicator): 39 (WebCore::isEmojiWithPresentationByDefault): 40 (WebCore::isEmojiModifierBase): 41 1 42 2019-01-09 Antoine Quint <graouts@apple.com> 2 43 -
trunk/Source/WebCore/platform/graphics/ComplexTextController.cpp
r239461 r239822 287 287 bool sawEmojiGroupCandidate = isEmojiGroupCandidate(baseCharacter); 288 288 bool sawJoiner = false; 289 bool sawRegionalIndicator = isEmojiRegionalIndicator(baseCharacter); 289 290 while (iterator < end) { 290 291 UChar32 nextCharacter; … … 296 297 if (isVariationSelector(nextCharacter) || isEmojiFitzpatrickModifier(nextCharacter)) 297 298 shouldContinue = true; 299 300 if (sawRegionalIndicator && isEmojiRegionalIndicator(nextCharacter)) { 301 shouldContinue = true; 302 sawRegionalIndicator = false; 303 } 298 304 299 305 if (sawJoiner && isEmojiGroupCandidate(nextCharacter)) -
trunk/Source/WebCore/platform/graphics/Font.cpp
r239427 r239822 503 503 } 504 504 505 CharacterFallbackMapKey(const AtomicString& locale, UChar32 character, boolisForPlatformFont)505 CharacterFallbackMapKey(const AtomicString& locale, UChar32 character, IsForPlatformFont isForPlatformFont) 506 506 : locale(locale) 507 507 , character(character) 508 , isForPlatformFont(isForPlatformFont )508 , isForPlatformFont(isForPlatformFont == IsForPlatformFont::Yes) 509 509 { 510 510 } … … 561 561 } 562 562 563 RefPtr<Font> Font::systemFallbackFontForCharacter(UChar32 character, const FontDescription& description, boolisForPlatformFont) const563 RefPtr<Font> Font::systemFallbackFontForCharacter(UChar32 character, const FontDescription& description, IsForPlatformFont isForPlatformFont) const 564 564 { 565 565 auto fontAddResult = systemFallbackCache().add(this, CharacterFallbackMap()); … … 567 567 if (!character) { 568 568 UChar codeUnit = 0; 569 return FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, &codeUnit, 1);569 return FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, FontCache::PreferColoredFont::No, &codeUnit, 1); 570 570 } 571 571 … … 587 587 } 588 588 589 fallbackFont = FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, codeUnits, codeUnitsLength).get();589 fallbackFont = FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, FontCache::PreferColoredFont::No, codeUnits, codeUnitsLength).get(); 590 590 if (fallbackFont) 591 591 fallbackFont->m_isUsedInSystemFallbackCache = true; … … 613 613 } 614 614 615 #if !PLATFORM(COCOA) 615 #if !PLATFORM(COCOA) && !USE(FREETYPE) 616 616 bool Font::variantCapsSupportsCharacterForSynthesis(FontVariantCaps fontVariantCaps, UChar32) const 617 617 { -
trunk/Source/WebCore/platform/graphics/Font.h
r239427 r239822 66 66 enum FontVariant { AutoVariant, NormalVariant, SmallCapsVariant, EmphasisMarkVariant, BrokenIdeographVariant }; 67 67 enum Pitch { UnknownPitch, FixedPitch, VariablePitch }; 68 enum class IsForPlatformFont : uint8_t { No, Yes }; 68 69 69 70 class Font : public RefCounted<Font> { … … 177 178 bool platformSupportsCodePoint(UChar32) const; 178 179 179 RefPtr<Font> systemFallbackFontForCharacter(UChar32, const FontDescription&, bool isForPlatformFont) const;180 RefPtr<Font> systemFallbackFontForCharacter(UChar32, const FontDescription&, IsForPlatformFont) const; 180 181 181 182 const GlyphPage* glyphPage(unsigned pageNumber) const; -
trunk/Source/WebCore/platform/graphics/FontCache.h
r239461 r239822 61 61 class OpenTypeVerticalData; 62 62 class Font; 63 enum class IsForPlatformFont : uint8_t; 63 64 64 65 #if PLATFORM(WIN) … … 191 192 192 193 // These methods are implemented by the platform. 193 RefPtr<Font> systemFallbackForCharacters(const FontDescription&, const Font* originalFontData, bool isPlatformFont, const UChar* characters, unsigned length); 194 enum class PreferColoredFont : uint8_t { No, Yes }; 195 RefPtr<Font> systemFallbackForCharacters(const FontDescription&, const Font* originalFontData, IsForPlatformFont, PreferColoredFont, const UChar* characters, unsigned length); 194 196 Vector<String> systemFontFamilies(); 195 197 void platformInit(); -
trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp
r233851 r239822 346 346 font = &realizeFallbackRangesAt(description, 0).fontForFirstRange(); 347 347 348 auto systemFallbackFont = font->systemFallbackFontForCharacter(character, description, m_isForPlatformFont );348 auto systemFallbackFont = font->systemFallbackFontForCharacter(character, description, m_isForPlatformFont ? IsForPlatformFont::Yes : IsForPlatformFont::No); 349 349 if (!systemFallbackFont) 350 350 return GlyphData(); -
trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
r235935 r239822 30 30 #if USE(CAIRO) 31 31 32 #include "CharacterProperties.h" 32 33 #include "FontCache.h" 33 34 #include "SurrogatePairAwareTextIterator.h" … … 43 44 bool FontCascade::canExpandAroundIdeographsInComplexText() 44 45 { 46 return false; 47 } 48 49 static bool characterSequenceIsEmoji(const Vector<UChar, 4>& normalizedCharacters, int32_t normalizedLength) 50 { 51 UChar32 character; 52 unsigned clusterLength = 0; 53 SurrogatePairAwareTextIterator iterator(normalizedCharacters.data(), 0, normalizedLength, normalizedLength); 54 if (!iterator.consume(character, clusterLength)) 55 return false; 56 57 if (isEmojiKeycapBase(character)) { 58 iterator.advance(clusterLength); 59 UChar32 nextCharacter; 60 if (!iterator.consume(nextCharacter, clusterLength)) 61 return false; 62 63 if (nextCharacter == combiningEnclosingKeycap) 64 return true; 65 66 // Variation selector 16. 67 if (nextCharacter == 0xFE0F) { 68 iterator.advance(clusterLength); 69 if (!iterator.consume(nextCharacter, clusterLength)) 70 return false; 71 72 if (nextCharacter == combiningEnclosingKeycap) 73 return true; 74 } 75 76 return false; 77 } 78 79 // Regional indicator. 80 if (isEmojiRegionalIndicator(character)) { 81 iterator.advance(clusterLength); 82 UChar32 nextCharacter; 83 if (!iterator.consume(nextCharacter, clusterLength)) 84 return false; 85 86 if (isEmojiRegionalIndicator(nextCharacter)) 87 return true; 88 89 return false; 90 } 91 92 if (character == combiningEnclosingKeycap) 93 return true; 94 95 if (isEmojiWithPresentationByDefault(character) 96 || isEmojiModifierBase(character) 97 || isEmojiFitzpatrickModifier(character)) 98 return true; 99 45 100 return false; 46 101 } … … 62 117 return nullptr; 63 118 119 bool isEmoji = characterSequenceIsEmoji(normalizedCharacters, normalizedLength); 120 64 121 const Font* baseFont = glyphDataForCharacter(character, false, NormalVariant).font; 65 if (baseFont && (static_cast<int32_t>(clusterLength) == normalizedLength || baseFont->canRenderCombiningCharacterSequence(characters, length))) 122 if (baseFont 123 && (static_cast<int32_t>(clusterLength) == normalizedLength || baseFont->canRenderCombiningCharacterSequence(characters, length)) 124 && (!isEmoji || baseFont->platformData().isColorBitmapFont())) 66 125 return baseFont; 67 126 … … 71 130 continue; 72 131 73 if (fallbackFont->canRenderCombiningCharacterSequence(characters, length) )132 if (fallbackFont->canRenderCombiningCharacterSequence(characters, length) && (!isEmoji || fallbackFont->platformData().isColorBitmapFont())) 74 133 return fallbackFont; 75 134 } 76 135 77 if (auto systemFallback = FontCache::singleton().systemFallbackForCharacters(m_fontDescription, baseFont, false, characters, length)) {78 if (systemFallback->canRenderCombiningCharacterSequence(characters, length) )136 if (auto systemFallback = FontCache::singleton().systemFallbackForCharacters(m_fontDescription, baseFont, IsForPlatformFont::No, isEmoji ? FontCache::PreferColoredFont::Yes : FontCache::PreferColoredFont::No, characters, length)) { 137 if (systemFallback->canRenderCombiningCharacterSequence(characters, length) && (!isEmoji || systemFallback->platformData().isColorBitmapFont())) 79 138 return systemFallback.get(); 80 139 } -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r239461 r239822 1355 1355 } 1356 1356 1357 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, bool isPlatformFont, const UChar* characters, unsigned length)1357 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, IsForPlatformFont isForPlatformFont, PreferColoredFont, const UChar* characters, unsigned length) 1358 1358 { 1359 1359 #if PLATFORM(IOS_FAMILY) … … 1384 1384 1385 1385 bool syntheticBold, syntheticOblique; 1386 std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(substituteFont, description, is PlatformFont).boldObliquePair();1386 std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(substituteFont, description, isForPlatformFont == IsForPlatformFont::Yes).boldObliquePair(); 1387 1387 1388 1388 FontPlatformData alternateFont(substituteFont, platformData.size(), syntheticBold, syntheticOblique, platformData.orientation(), platformData.widthVariant(), platformData.textRenderingMode()); -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r239768 r239822 119 119 } 120 120 121 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font*, bool, const UChar* characters, unsigned length)121 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font*, IsForPlatformFont, PreferColoredFont preferColoredFont, const UChar* characters, unsigned length) 122 122 { 123 123 FcUniquePtr<FcCharSet> fontConfigCharSet(FcCharSetCreate()); … … 133 133 134 134 FcPatternAddBool(pattern.get(), FC_SCALABLE, FcTrue); 135 if (preferColoredFont == PreferColoredFont::Yes) 136 FcPatternAddBool(pattern.get(), FC_COLOR, FcTrue); 135 137 136 138 if (!configurePatternForFontDescription(pattern.get(), description)) -
trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
r239554 r239822 33 33 #include <fontconfig/fcfreetype.h> 34 34 #include <ft2build.h> 35 #include FT_FREETYPE_H 35 36 #include FT_TRUETYPE_TABLES_H 36 37 #include <hb-ft.h> … … 118 119 119 120 buildScaledFont(fontFace); 121 122 #ifdef FT_HAS_COLOR 123 CairoFtFaceLocker cairoFtFaceLocker(m_scaledFont.get()); 124 if (FT_Face ftFace = cairoFtFaceLocker.ftFace()) 125 m_isColorBitmapFont = FT_HAS_COLOR(ftFace); 126 #endif 120 127 } 121 128 -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r239427 r239822 189 189 } 190 190 191 } 191 bool Font::variantCapsSupportsCharacterForSynthesis(FontVariantCaps fontVariantCaps, UChar32) const 192 { 193 switch (fontVariantCaps) { 194 case FontVariantCaps::Small: 195 case FontVariantCaps::Petite: 196 case FontVariantCaps::AllSmall: 197 case FontVariantCaps::AllPetite: 198 return false; 199 default: 200 // Synthesis only supports the variant-caps values listed above. 201 return true; 202 } 203 } 204 205 bool Font::platformSupportsCodePoint(UChar32 character) const 206 { 207 CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont()); 208 if (FT_Face face = cairoFtFaceLocker.ftFace()) 209 return !!FcFreeTypeCharIndex(face, character); 210 211 return false; 212 } 213 214 } -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r239092 r239822 212 212 } 213 213 214 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, bool, const UChar* characters, unsigned length)214 RefPtr<Font> FontCache::systemFallbackForCharacters(const FontDescription& description, const Font* originalFontData, IsForPlatformFont, PreferColoredFont, const UChar* characters, unsigned length) 215 215 { 216 216 UChar character = characters[0]; -
trunk/Source/WebCore/platform/text/CharacterProperties.h
r213616 r239822 77 77 } 78 78 79 inline bool isEmojiKeycapBase(UChar32 character) 80 { 81 return (character >= '0' && character <= '9') || character == '#' || character == '*'; 79 82 } 83 84 inline bool isEmojiRegionalIndicator(UChar32 character) 85 { 86 return character >= 0x1F1E6 && character <= 0x1F1FF; 87 } 88 89 inline bool isEmojiWithPresentationByDefault(UChar32 character) 90 { 91 #if U_ICU_VERSION_MAJOR_NUM >= 57 92 return u_hasBinaryProperty(character, UCHAR_EMOJI_PRESENTATION); 93 #else 94 UNUSED_PARAM(character); 95 return false; 96 #endif 97 } 98 99 inline bool isEmojiModifierBase(UChar32 character) 100 { 101 #if U_ICU_VERSION_MAJOR_NUM >= 57 102 return u_hasBinaryProperty(character, UCHAR_EMOJI_MODIFIER_BASE); 103 #else 104 UNUSED_PARAM(character); 105 return false; 106 #endif 107 } 108 109 }
Note: See TracChangeset
for help on using the changeset viewer.