Chromium Code Reviews| Index: tools/sk_tool_utils.cpp |
| diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp |
| index 7343ce4744e661bd5a08600fb58df0d202c6d253..fd53e98ea51020b459ca9d202f9dc74cc5cadf5f 100644 |
| --- a/tools/sk_tool_utils.cpp |
| +++ b/tools/sk_tool_utils.cpp |
| @@ -12,6 +12,8 @@ |
| #include "SkBitmap.h" |
| #include "SkCanvas.h" |
| #include "SkCommonFlags.h" |
| +#include "SkFontMgr.h" |
| +#include "SkFontStyle.h" |
| #include "SkPoint3.h" |
| #include "SkShader.h" |
| #include "SkTestScalerContext.h" |
| @@ -72,6 +74,9 @@ const char* platform_os_emoji() { |
| if (!strncmp(osName, "Mac", 3)) { |
| return "SBIX"; |
| } |
| + if (!strncmp(osName, "Win", 3)) { |
| + return "COLR"; |
| + } |
| return ""; |
| } |
| @@ -82,6 +87,23 @@ sk_sp<SkTypeface> emoji_typeface() { |
| if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
| return SkTypeface::MakeFromName("Apple Color Emoji", SkTypeface::kNormal); |
| } |
| + if (!strcmp(sk_tool_utils::platform_os_emoji(), "COLR")) { |
| + sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| + const char *colorEmojiFontName = "Segoe UI Emoji"; |
| + sk_sp<SkTypeface> typeface(fm->matchFamilyStyle(colorEmojiFontName, SkFontStyle())); |
| + if (typeface) { |
| + return typeface; |
| + } |
| + const char *bcp47 = "en-us"; |
|
bungeman-skia
2016/05/27 12:51:39
en-US
Windows may or may not care. Also, I think
Ilya Kulshin
2016/05/28 02:59:46
Switched to nullptr/0.
|
| + sk_sp<SkTypeface> fallback(fm->matchFamilyStyleCharacter( |
|
bungeman-skia
2016/05/27 12:51:39
Note that matchFamilyStyleCharacter was never impl
Ilya Kulshin
2016/05/28 02:59:46
Acknowledged.
|
| + colorEmojiFontName, SkFontStyle(), &bcp47, 1 /* bcp47Count */, 0x1f4b0 /* character: 💰 */)); |
|
bungeman-skia
2016/05/27 12:51:39
nit: this line is a bit long (Skia uses 100 charac
Ilya Kulshin
2016/05/28 02:59:46
Done.
|
| + if (fallback) { |
| + return fallback; |
| + } |
| + // If we don't have Segoe UI Emoji and can't find a fallback, try Segoe UI Symbol. |
| + // Windows 7 does not have Segoe UI Emoji; Segoe UI Symbol has the (non - color) emoji. |
| + return SkTypeface::MakeFromName("Segoe UI Symbol", SkTypeface::kNormal); |
| + } |
| return nullptr; |
| } |
| @@ -89,7 +111,9 @@ const char* emoji_sample_text() { |
| if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
| return "Hamburgefons"; |
| } |
| - if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
| + if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX") || |
| + !strcmp(sk_tool_utils::platform_os_emoji(), "COLR")) |
| + { |
| return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // 💰🏡🎅 |
| "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // 🍪🍕🚀 |
| "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // 🚻💩📷 |