slice GMs by native font platform, not by emoji format
Right now the native font platform implies what emoji formats are
supported, and we hope to support more than one per platform. Let's
get these formats out of the name.
As with most other font-y things, only the NativeFont bots are going to
get back anything interesting now. The others will see no emoji font
and an empty emoji sample text string.
I'm going to look at a pre-baked testing SkTypeface that serves as an
emoji font for the non-NativeFont bots next.
Change-Id: Ie1374fc0e988bfe20ae21208e2f7e0a66a68fcb1
Reviewed-on: https://skia-review.googlesource.com/71762
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index b23676f..5321513 100644
--- a/tools/sk_tool_utils.cpp
+++ b/tools/sk_tool_utils.cpp
@@ -22,10 +22,6 @@
namespace sk_tool_utils {
-static bool starts_with(const char* str, const char* prefix) {
- return 0 == strncmp(str, prefix, strlen(prefix));
-}
-
static const char* platform_os_name() {
for (int index = 0; index < FLAGS_key.count(); index += 2) {
if (!strcmp("os", FLAGS_key[index])) {
@@ -35,63 +31,43 @@
return "";
}
-const char* platform_os_emoji() {
- const char* osName = platform_os_name();
- if (starts_with(osName, "Android") ||
- starts_with(osName, "Ubuntu") ||
- starts_with(osName, "Debian")) {
- return "CBDT";
- }
- if (starts_with(osName, "Mac") || starts_with(osName, "iOS")) {
- return "SBIX";
- }
- if (starts_with(osName, "Win")) {
- return "COLR";
- }
- return "";
-}
-
sk_sp<SkTypeface> emoji_typeface() {
- if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) {
- return MakeResourceAsTypeface("/fonts/Funkster.ttf");
+#if defined(SK_BUILD_FOR_WIN)
+ sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
+ const char *colorEmojiFontName = "Segoe UI Emoji";
+ sk_sp<SkTypeface> typeface(fm->matchFamilyStyle(colorEmojiFontName, SkFontStyle()));
+ if (typeface) {
+ return typeface;
}
- if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) {
- return SkTypeface::MakeFromName("Apple Color Emoji", SkFontStyle());
+ sk_sp<SkTypeface> fallback(fm->matchFamilyStyleCharacter(
+ colorEmojiFontName, SkFontStyle(), nullptr /* bcp47 */, 0 /* bcp47Count */,
+ 0x1f4b0 /* character: π° */));
+ if (fallback) {
+ return fallback;
}
- 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;
- }
- sk_sp<SkTypeface> fallback(fm->matchFamilyStyleCharacter(
- colorEmojiFontName, SkFontStyle(), nullptr /* bcp47 */, 0 /* bcp47Count */,
- 0x1f4b0 /* character: π° */));
- 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", SkFontStyle());
- }
- return nullptr;
+ // 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", SkFontStyle());
+
+#elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+ return SkTypeface::MakeFromName("Apple Color Emoji", SkFontStyle());
+
+#else
+ return MakeResourceAsTypeface("/fonts/Funkster.ttf");
+
+#endif
}
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") ||
- !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" // π»π©π·
- "\xF0\x9F\x93\xA6" // π¦
- "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87\xA6"; // πΊπΈπ¦
- }
- return "";
+#if defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
+ 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" // π»π©π·
+ "\xF0\x9F\x93\xA6" // π¦
+ "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87\xA6"; // πΊπΈπ¦
+#else
+ return "Hamburgefons";
+#endif
}
static bool extra_config_contains(const char* substring) {