WebKit Bugzilla
Attachment 358890 Details for
Bug 177040
: [FreeType] Support emoji modifiers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
wc-ft-emojis.diff (text/plain), 9.44 KB, created by
Carlos Garcia Campos
on 2019-01-11 04:57:17 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Garcia Campos
Created:
2019-01-11 04:57:17 PST
Size:
9.44 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 583c14a29fe..dde073e3449 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2019-01-11 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [FreeType] Support emoji modifiers >+ https://bugs.webkit.org/show_bug.cgi?id=177040 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Mark several emoji tests as passing now. >+ >+ * platform/gtk/TestExpectations: >+ > 2019-01-10 Devin Rousso <drousso@apple.com> > > Web Inspector: Audit: allow audits to be enabled/disabled >diff --git a/LayoutTests/platform/gtk/TestExpectations b/LayoutTests/platform/gtk/TestExpectations >index 9a856452a92..d43148c7425 100644 >--- a/LayoutTests/platform/gtk/TestExpectations >+++ b/LayoutTests/platform/gtk/TestExpectations >@@ -3780,6 +3780,12 @@ fast/text/emoji-gender-2-6.html [ Pass ] > fast/text/emoji-gender-2-7.html [ Pass ] > fast/text/emoji-gender-2-8.html [ Pass ] > fast/text/emoji-gender-2-9.html [ Pass ] >+fast/text/emoji-gender-3.html [ Pass ] >+fast/text/emoji-gender-4.html [ Pass ] >+fast/text/emoji-gender-5.html [ Pass ] >+fast/text/emoji-gender-6.html [ Pass ] >+fast/text/emoji-gender-8.html [ Pass ] >+fast/text/emoji-gender-9.html [ Pass ] > fast/text/emoji-gender.html [ Pass ] > fast/text/emoji-gender-fe0f-3.html [ Pass ] > fast/text/emoji-gender-fe0f-4.html [ Pass ] >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 76b62769033..076f8643aab 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,23 @@ >+2019-01-11 Carlos Garcia Campos <cgarcia@igalia.com> >+ >+ [FreeType] Support emoji modifiers >+ https://bugs.webkit.org/show_bug.cgi?id=177040 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The problem only happens with emojis having the zero with joiner (U+200D) in the sequence. The sequence is >+ broken because createAndFillGlyphPage() in Font.cpp overwrites zero with joiner with zero width space (U+200B), >+ but the emoji font actually supports zero with joiner. This patch moves the control characters override from >+ createAndFillGlyphPage() to GlyphPage::fill() only for FreeType based ports. This way we can do the override >+ only for the cases where the code point is not supported by the font. >+ >+ * platform/graphics/Font.cpp: >+ (WebCore::overrideControlCharacters): Helper function to override the control characters. >+ (WebCore::createAndFillGlyphPage): Call overrideControlCharacters() only when not using FreeType. >+ * platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp: >+ (WebCore::GlyphPage::fill): Use zero width space as fallback when the font doesn't support characters with >+ Default_Ignorable Unicode property. >+ > 2019-01-10 Myles C. Maxfield <mmaxfield@apple.com> > > [WHLSL] Include the standard library >diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp >index d03c25f62f8..b6c116423fb 100644 >--- a/Source/WebCore/platform/graphics/Font.cpp >+++ b/Source/WebCore/platform/graphics/Font.cpp >@@ -263,6 +263,50 @@ static Optional<size_t> codePointSupportIndex(UChar32 codePoint) > return result; > } > >+#if !USE(FREETYPE) >+static void overrideControlCharacters(Vector<UChar>& buffer, unsigned start, unsigned end) >+{ >+ auto overwriteCodePoints = [&](unsigned minimum, unsigned maximum, UChar newCodePoint) { >+ unsigned begin = std::max(start, minimum); >+ unsigned complete = std::min(end, maximum); >+ for (unsigned i = begin; i < complete; ++i) { >+ ASSERT(codePointSupportIndex(i)); >+ buffer[i - start] = newCodePoint; >+ } >+ }; >+ >+ auto overwriteCodePoint = [&](UChar codePoint, UChar newCodePoint) { >+ ASSERT(codePointSupportIndex(codePoint)); >+ if (codePoint >= start && codePoint < end) >+ buffer[codePoint - start] = newCodePoint; >+ }; >+ >+ // Code points 0x0 - 0x20 and 0x7F - 0xA0 are control character and shouldn't render. Map them to ZERO WIDTH SPACE. >+ overwriteCodePoints(0x0, 0x20, zeroWidthSpace); >+ overwriteCodePoints(0x7F, 0xA0, zeroWidthSpace); >+ overwriteCodePoint(softHyphen, zeroWidthSpace); >+ overwriteCodePoint('\n', space); >+ overwriteCodePoint('\t', space); >+ overwriteCodePoint(noBreakSpace, space); >+ overwriteCodePoint(narrowNoBreakSpace, zeroWidthSpace); >+ overwriteCodePoint(leftToRightMark, zeroWidthSpace); >+ overwriteCodePoint(rightToLeftMark, zeroWidthSpace); >+ overwriteCodePoint(leftToRightEmbed, zeroWidthSpace); >+ overwriteCodePoint(rightToLeftEmbed, zeroWidthSpace); >+ overwriteCodePoint(leftToRightOverride, zeroWidthSpace); >+ overwriteCodePoint(rightToLeftOverride, zeroWidthSpace); >+ overwriteCodePoint(leftToRightIsolate, zeroWidthSpace); >+ overwriteCodePoint(rightToLeftIsolate, zeroWidthSpace); >+ overwriteCodePoint(zeroWidthNonJoiner, zeroWidthSpace); >+ overwriteCodePoint(zeroWidthJoiner, zeroWidthSpace); >+ overwriteCodePoint(popDirectionalFormatting, zeroWidthSpace); >+ overwriteCodePoint(popDirectionalIsolate, zeroWidthSpace); >+ overwriteCodePoint(firstStrongIsolate, zeroWidthSpace); >+ overwriteCodePoint(objectReplacementCharacter, zeroWidthSpace); >+ overwriteCodePoint(zeroWidthNoBreakSpace, zeroWidthSpace); >+} >+#endif >+ > static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font& font) > { > #if PLATFORM(IOS_FAMILY) >@@ -276,7 +320,6 @@ static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font& > unsigned glyphPageSize = GlyphPage::sizeForPageNumber(pageNumber); > > unsigned start = GlyphPage::startingCodePointInPageNumber(pageNumber); >- unsigned end = start + glyphPageSize; > Vector<UChar> buffer(glyphPageSize * 2 + 2); > unsigned bufferLength; > // Fill in a buffer with the entire "page" of characters that we want to look up glyphs for. >@@ -285,44 +328,9 @@ static RefPtr<GlyphPage> createAndFillGlyphPage(unsigned pageNumber, const Font& > for (unsigned i = 0; i < bufferLength; i++) > buffer[i] = start + i; > >- // Code points 0x0 - 0x20 and 0x7F - 0xA0 are control character and shouldn't render. Map them to ZERO WIDTH SPACE. >- auto overwriteCodePoints = [&](unsigned minimum, unsigned maximum, UChar newCodePoint) { >- unsigned begin = std::max(start, minimum); >- unsigned complete = std::min(end, maximum); >- for (unsigned i = begin; i < complete; ++i) { >- ASSERT(codePointSupportIndex(i)); >- buffer[i - start] = newCodePoint; >- } >- }; >- >- auto overwriteCodePoint = [&](UChar codePoint, UChar newCodePoint) { >- ASSERT(codePointSupportIndex(codePoint)); >- if (codePoint >= start && codePoint < end) >- buffer[codePoint - start] = newCodePoint; >- }; >- >- overwriteCodePoints(0x0, 0x20, zeroWidthSpace); >- overwriteCodePoints(0x7F, 0xA0, zeroWidthSpace); >- overwriteCodePoint(softHyphen, zeroWidthSpace); >- overwriteCodePoint('\n', space); >- overwriteCodePoint('\t', space); >- overwriteCodePoint(noBreakSpace, space); >- overwriteCodePoint(narrowNoBreakSpace, zeroWidthSpace); >- overwriteCodePoint(leftToRightMark, zeroWidthSpace); >- overwriteCodePoint(rightToLeftMark, zeroWidthSpace); >- overwriteCodePoint(leftToRightEmbed, zeroWidthSpace); >- overwriteCodePoint(rightToLeftEmbed, zeroWidthSpace); >- overwriteCodePoint(leftToRightOverride, zeroWidthSpace); >- overwriteCodePoint(rightToLeftOverride, zeroWidthSpace); >- overwriteCodePoint(leftToRightIsolate, zeroWidthSpace); >- overwriteCodePoint(rightToLeftIsolate, zeroWidthSpace); >- overwriteCodePoint(zeroWidthNonJoiner, zeroWidthSpace); >- overwriteCodePoint(zeroWidthJoiner, zeroWidthSpace); >- overwriteCodePoint(popDirectionalFormatting, zeroWidthSpace); >- overwriteCodePoint(popDirectionalIsolate, zeroWidthSpace); >- overwriteCodePoint(firstStrongIsolate, zeroWidthSpace); >- overwriteCodePoint(objectReplacementCharacter, zeroWidthSpace); >- overwriteCodePoint(zeroWidthNoBreakSpace, zeroWidthSpace); >+#if !USE(FREETYPE) >+ overrideControlCharacters(buffer, start, start + glyphPageSize); >+#endif > } else { > bufferLength = glyphPageSize * 2; > for (unsigned i = 0; i < glyphPageSize; i++) { >diff --git a/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp b/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp >index caa4b8de796..dcdd26ded50 100644 >--- a/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp >+++ b/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp >@@ -33,6 +33,7 @@ > > #include "CairoUtilities.h" > #include "Font.h" >+#include "FontCascade.h" > #include "UTF16UChar32Iterator.h" > #include <cairo-ft.h> > #include <cairo.h> >@@ -58,7 +59,11 @@ bool GlyphPage::fill(UChar* buffer, unsigned bufferLength) > if (character == iterator.end()) > break; > >- Glyph glyph = FcFreeTypeCharIndex(face, character); >+ Glyph glyph = FcFreeTypeCharIndex(face, FontCascade::treatAsSpace(character) ? space : character); >+ // If the font doesn't support a Default_Ignorable character, replace it with zero with space. >+ if (!glyph && u_hasBinaryProperty(character, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)) >+ glyph = FcFreeTypeCharIndex(face, zeroWidthSpace); >+ > if (!glyph) > setGlyphForIndex(i, 0); > else {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
mmaxfield
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 177040
: 358890