diff options
author | caryclark <caryclark@google.com> | 2015-07-21 12:27:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-21 12:27:36 -0700 |
commit | c3dcb67f07173af1c17771965ab7254910d52ef3 (patch) | |
tree | 6ce7c2da52adcd3f547e0fedfb759de873afd098 /tools | |
parent | 654ad19fbd5a295c4bd3072dc8a7b88f212bbd49 (diff) |
make color emoji gm portable
R=bungeman@google.com
Review URL: https://codereview.chromium.org/1248703004
Diffstat (limited to 'tools')
-rw-r--r-- | tools/sk_tool_utils.cpp | 38 | ||||
-rw-r--r-- | tools/sk_tool_utils.h | 3 |
2 files changed, 40 insertions, 1 deletions
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index b06fcda3a6..b8b43f6fe7 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -1,4 +1,4 @@ -/* +ο»Ώ/* * Copyright 2014 Google Inc. * * Use of this source code is governed by a BSD-style license that can be @@ -8,6 +8,7 @@ #include "sk_tool_utils.h" #include "sk_tool_utils_flags.h" +#include "Resources.h" #include "SkBitmap.h" #include "SkCanvas.h" #include "SkCommonFlags.h" @@ -20,6 +21,41 @@ DEFINE_bool(resourceFonts, false, "Use resource fonts"); namespace sk_tool_utils { +const char* platform_os_emoji() { + const char* osName = platform_os_name(); + if (!strcmp(osName, "Android") || !strcmp(osName, "Unbuntu")) { + return "CBDT"; + } + if (!strncmp(osName, "Mac", 3)) { + return "SBIX"; + } + return ""; +} + +SkTypeface* emoji_typeface() { + if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { + return GetResourceAsTypeface("/fonts/Funkster.ttf"); + } + if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { + return SkTypeface::CreateFromName("Apple Color Emoji", SkTypeface::kNormal); + } + return NULL; +} + +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")) { + 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 ""; +} + const char* platform_os_name() { for (int index = 0; index < FLAGS_key.count(); index += 2) { if (!strcmp("os", FLAGS_key[index])) { diff --git a/tools/sk_tool_utils.h b/tools/sk_tool_utils.h index 864c33dd21..921ca2ad39 100644 --- a/tools/sk_tool_utils.h +++ b/tools/sk_tool_utils.h @@ -25,6 +25,9 @@ namespace sk_tool_utils { const char* colortype_name(SkColorType); SkColor color_to_565(SkColor color); + SkTypeface* emoji_typeface(); + const char* emoji_sample_text(); + const char* platform_os_emoji(); const char* platform_os_name(); const char* platform_extra_config(const char* config); |