aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/sk_tool_utils.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-11-15 10:42:46 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-15 16:52:56 +0000
commitf436fbc4229f95aaa59d0cd54750ed4d14e65169 (patch)
tree855557b9a1b8380ea647e7b53deb28ef4baf2bd7 /tools/sk_tool_utils.cpp
parent09b8c91b696925c6c6a25c35173f2da27abf0fbe (diff)
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>
Diffstat (limited to 'tools/sk_tool_utils.cpp')
-rw-r--r--tools/sk_tool_utils.cpp86
1 files changed, 31 insertions, 55 deletions
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp
index b23676fc94..5321513a17 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 @@ static const char* platform_os_name() {
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) {