summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornoms <noms@chromium.org>2016-02-19 19:45:14 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-20 03:46:12 +0000
commit790992b74add808ad602fc366185bb126fe16474 (patch)
tree3a096e312efda5776e57699b8c8fac48c61a2112
parent1f3c80889f69f07edc3024c47f4ae41a19f3dd3b (diff)
downloadchromium_src-790992b74add808ad602fc366185bb126fe16474.zip
chromium_src-790992b74add808ad602fc366185bb126fe16474.tar.gz
chromium_src-790992b74add808ad602fc366185bb126fe16474.tar.bz2
[Mac] Render bold emoji
Due to https://bugs.chromium.org/p/skia/issues/detail?id=4904, Skia can't render bold emoji (since they have setFakeBoldText set). To workaround that, this CL makes sure that bold emoji never have syntheticBold set -- this is fine, since a bold emoji looks exactly like a normal weight emoji, so there won't be a difference. There are two places where this needs to be fixed: - FontCache::fallbackFontForCharacter, so that <h1>🍰</h1> is fine - FontCache::createFontPlatformData, so that <h1 style="font-family:AppleColorEmoji">🍰</h1> is fine I also added a bonus fallback test, since there was a Windows one, but not a Mac one. R=eae@chromium.org BUG=551843 TEST=fast/text/emoji-font-weight-mac.html Review URL: https://codereview.chromium.org/1711263003 Cr-Commit-Position: refs/heads/master@{#376619}
-rw-r--r--third_party/WebKit/LayoutTests/NeverFixTests4
-rw-r--r--third_party/WebKit/LayoutTests/TestExpectations2
-rw-r--r--third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac-expected.html11
-rw-r--r--third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac.html11
-rw-r--r--third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac-expected.html11
-rw-r--r--third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac.html11
-rw-r--r--third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm15
7 files changed, 63 insertions, 2 deletions
diff --git a/third_party/WebKit/LayoutTests/NeverFixTests b/third_party/WebKit/LayoutTests/NeverFixTests
index 8abb0e7..e69cf60 100644
--- a/third_party/WebKit/LayoutTests/NeverFixTests
+++ b/third_party/WebKit/LayoutTests/NeverFixTests
@@ -206,6 +206,10 @@ imported/csswg-test/css21/linebox/line-height-126.xht [ WontFix ]
# would let us differentiate test_shell and WebKit DumpTreeNode.
crbug.com/7482 [ Win Mac ] http/tests/misc/timer-vs-loading.html [ WontFix ]
+# On Linux bold emoji are already supported.
+crbug.com/551843 [ Linux ] fast/text/fallback-traits-fixup.html [ WontFix ]
+crbug.com/551843 [ Linux Win ] fast/text/emoji-font-weight-mac.html [ WontFix ]
+
# These tests are too slow with our MESA backend. We can re-enable when we have
# bots running tests on real hardware. Don't want to just delete these because they
# pass in the virtual test suite version.
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations
index 74962db..21845a5 100644
--- a/third_party/WebKit/LayoutTests/TestExpectations
+++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -1377,6 +1377,8 @@ crbug.com/571765 [ Linux Trusty Mac10.9 ] inspector/console/worker-eval-contains
crbug.com/571773 inspector/console/worker-exception-message-contains-stack.html [ Failure Timeout Crash Pass ]
+crbug.com/551843 fast/text/fallback-traits-fixup.html [ NeedsManualRebaseline ]
+
crbug.com/399951 http/tests/mime/javascript-mimetype-usecounters.html [ Pass Failure ]
crbug.com/572710 [ Debug ] inspector/extensions/extensions-sidebar.html [ Timeout Pass ]
diff --git a/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac-expected.html b/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac-expected.html
new file mode 100644
index 0000000..3001bdc
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac-expected.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>'GRINNING FACE WITH SMILING EYES' (U+1F601)</title>
+ </head>
+ <body>
+ <p style="font-family: Apple Color Emoji;">&#x1f601;😁😜</p>
+ <p>There should be three smiling emojis above.</p>
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac.html b/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac.html
new file mode 100644
index 0000000..3e330b4
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/text/emoji-font-fallback-mac.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>'GRINNING FACE WITH SMILING EYES' (U+1F601)</title>
+ </head>
+ <body>
+ <p>&#x1f601;😁😜</p>
+ <p>There should be three smiling emojis above.</p>
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac-expected.html b/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac-expected.html
new file mode 100644
index 0000000..0c895cc
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac-expected.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>'GRINNING FACE WITH SMILING EYES' (U+1F601)</title>
+ </head>
+ <body>
+ <h1 style="font-weight: normal; font-family: Apple Color Emoji;">&#x1f601;😁😜</h1>
+ <p>There should be three giant smiling emojis above.</p>
+ </body>
+</html>
diff --git a/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac.html b/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac.html
new file mode 100644
index 0000000..9c59089
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/text/emoji-font-weight-mac.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8" />
+ <title>'GRINNING FACE WITH SMILING EYES' (U+1F601)</title>
+ </head>
+ <body>
+ <h1 style="font-weight: bold;">&#x1f601;😁😜</h1>
+ <p>There should be three giant smiling emojis above.</p>
+ </body>
+</html>
diff --git a/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm b/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
index 629b7eb..28dacdb 100644
--- a/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
+++ b/third_party/WebKit/Source/platform/fonts/mac/FontCacheMac.mm
@@ -167,8 +167,14 @@ PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip
substituteFontTraits = [fontManager traitsOfFont:substituteFont];
substituteFontWeight = [fontManager weightOfFont:substituteFont];
+ // TODO(eae): Remove once skia supports bold emoji. See https://bugs.chromium.org/p/skia/issues/detail?id=4904
+ // Bold emoji look the same as normal emoji, so syntheticBold isn't needed.
+ bool syntheticBold = isAppKitFontWeightBold(weight) &&
+ !isAppKitFontWeightBold(substituteFontWeight) &&
+ ![substituteFont.familyName isEqual:@"Apple Color Emoji"];
+
FontPlatformData alternateFont(substituteFont, platformData.size(),
- isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(substituteFontWeight),
+ syntheticBold,
(traits & NSFontItalicTrait) && !(substituteFontTraits & NSFontItalicTrait),
platformData.orientation());
@@ -211,7 +217,12 @@ PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip
NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerFont];
NSInteger appKitWeight = toAppKitFontWeight(fontDescription.weight());
- bool syntheticBold = (isAppKitFontWeightBold(appKitWeight) && !isAppKitFontWeightBold(actualWeight)) || fontDescription.isSyntheticBold();
+
+ // TODO(eae): Remove once skia supports bold emoji. See https://bugs.chromium.org/p/skia/issues/detail?id=4904
+ // Bold emoji look the same as normal emoji, so syntheticBold isn't needed.
+ bool syntheticBold = [platformFont.familyName isEqual:@"Apple Color Emoji"] ? false :
+ (isAppKitFontWeightBold(appKitWeight) && !isAppKitFontWeightBold(actualWeight)) || fontDescription.isSyntheticBold();
+
bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait)) || fontDescription.isSyntheticItalic();
// FontPlatformData::typeface() is null in the case of Chromium out-of-process font loading failing.