diff options
-rw-r--r-- | gm/coloremoji.cpp | 2 | ||||
-rw-r--r-- | gm/coloremoji_blendmodes.cpp | 2 | ||||
-rw-r--r-- | gm/dftext.cpp | 2 | ||||
-rw-r--r-- | gm/mixedtextblobs.cpp | 5 | ||||
-rw-r--r-- | tools/sk_tool_utils.cpp | 86 | ||||
-rw-r--r-- | tools/sk_tool_utils.h | 5 |
6 files changed, 36 insertions, 66 deletions
diff --git a/gm/coloremoji.cpp b/gm/coloremoji.cpp index 59db9a0fc2..f264e4ef7c 100644 --- a/gm/coloremoji.cpp +++ b/gm/coloremoji.cpp @@ -66,7 +66,7 @@ protected: SkString onShortName() override { SkString name("coloremoji"); - name.append(sk_tool_utils::platform_os_emoji()); + name.append(sk_tool_utils::platform_font_manager()); return name; } diff --git a/gm/coloremoji_blendmodes.cpp b/gm/coloremoji_blendmodes.cpp index b93c6b4e45..6cf891baef 100644 --- a/gm/coloremoji_blendmodes.cpp +++ b/gm/coloremoji_blendmodes.cpp @@ -47,7 +47,7 @@ protected: virtual SkString onShortName() override { SkString name("coloremoji_blendmodes"); - name.append(sk_tool_utils::platform_os_emoji()); + name.append(sk_tool_utils::platform_font_manager()); return name; } diff --git a/gm/dftext.cpp b/gm/dftext.cpp index 6067327b81..34c1f9a94e 100644 --- a/gm/dftext.cpp +++ b/gm/dftext.cpp @@ -26,7 +26,7 @@ protected: SkString onShortName() override { SkString name("dftext"); - name.append(sk_tool_utils::platform_os_emoji()); + name.append(sk_tool_utils::platform_font_manager()); return name; } diff --git a/gm/mixedtextblobs.cpp b/gm/mixedtextblobs.cpp index c7e3b2d742..887bd5bf17 100644 --- a/gm/mixedtextblobs.cpp +++ b/gm/mixedtextblobs.cpp @@ -99,9 +99,8 @@ protected: } SkString onShortName() override { - return SkStringPrintf("mixedtextblobs%s%s", - sk_tool_utils::platform_font_manager(), - sk_tool_utils::platform_os_emoji()); + return SkStringPrintf("mixedtextblobs%s", + sk_tool_utils::platform_font_manager()); } SkISize onISize() override { 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) { diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index 857ad5aa47..abf43323c5 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -47,11 +47,6 @@ namespace sk_tool_utils { const char* emoji_sample_text(); /** - * If the platform supports color emoji, return the type (i.e. "CBDT", "SBIX", ""). - */ - const char* platform_os_emoji(); - - /** * Returns a string describing the platform font manager, if we're using one, otherwise "". */ const char* platform_font_manager(); |