Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "sk_tool_utils.h" | 8 #include "sk_tool_utils.h" |
| 9 #include "sk_tool_utils_flags.h" | 9 #include "sk_tool_utils_flags.h" |
| 10 | 10 |
| 11 #include "Resources.h" | 11 #include "Resources.h" |
| 12 #include "SkBitmap.h" | 12 #include "SkBitmap.h" |
| 13 #include "SkCanvas.h" | 13 #include "SkCanvas.h" |
| 14 #include "SkCommonFlags.h" | 14 #include "SkCommonFlags.h" |
| 15 #include "SkFontMgr.h" | |
| 16 #include "SkFontStyle.h" | |
| 15 #include "SkPoint3.h" | 17 #include "SkPoint3.h" |
| 16 #include "SkShader.h" | 18 #include "SkShader.h" |
| 17 #include "SkTestScalerContext.h" | 19 #include "SkTestScalerContext.h" |
| 18 #include "SkTextBlob.h" | 20 #include "SkTextBlob.h" |
| 19 | 21 |
| 20 DEFINE_bool(portableFonts, false, "Use portable fonts"); | 22 DEFINE_bool(portableFonts, false, "Use portable fonts"); |
| 21 | 23 |
| 22 namespace sk_tool_utils { | 24 namespace sk_tool_utils { |
| 23 | 25 |
| 24 /* these are the default fonts chosen by Chrome for serif, sans-serif, and monos pace */ | 26 /* these are the default fonts chosen by Chrome for serif, sans-serif, and monos pace */ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 } | 67 } |
| 66 | 68 |
| 67 const char* platform_os_emoji() { | 69 const char* platform_os_emoji() { |
| 68 const char* osName = platform_os_name(); | 70 const char* osName = platform_os_name(); |
| 69 if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu")) { | 71 if (!strcmp(osName, "Android") || !strcmp(osName, "Ubuntu")) { |
| 70 return "CBDT"; | 72 return "CBDT"; |
| 71 } | 73 } |
| 72 if (!strncmp(osName, "Mac", 3)) { | 74 if (!strncmp(osName, "Mac", 3)) { |
| 73 return "SBIX"; | 75 return "SBIX"; |
| 74 } | 76 } |
| 77 if (!strncmp(osName, "Win", 3)) { | |
| 78 return "COLR"; | |
| 79 } | |
| 75 return ""; | 80 return ""; |
| 76 } | 81 } |
| 77 | 82 |
| 78 sk_sp<SkTypeface> emoji_typeface() { | 83 sk_sp<SkTypeface> emoji_typeface() { |
| 79 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { | 84 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
| 80 return MakeResourceAsTypeface("/fonts/Funkster.ttf"); | 85 return MakeResourceAsTypeface("/fonts/Funkster.ttf"); |
| 81 } | 86 } |
| 82 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { | 87 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
| 83 return SkTypeface::MakeFromName("Apple Color Emoji", SkTypeface::kNormal ); | 88 return SkTypeface::MakeFromName("Apple Color Emoji", SkTypeface::kNormal ); |
| 84 } | 89 } |
| 90 if (!strcmp(sk_tool_utils::platform_os_emoji(), "COLR")) { | |
| 91 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | |
| 92 const char *colorEmojiFontName = "Segoe UI Emoji"; | |
| 93 sk_sp<SkTypeface> typeface(fm->matchFamilyStyle(colorEmojiFontName, SkFo ntStyle())); | |
| 94 if (typeface) { | |
| 95 return typeface; | |
| 96 } | |
| 97 sk_sp<SkTypeface> fallback(fm->matchFamilyStyleCharacter( | |
| 98 colorEmojiFontName, SkFontStyle(), nullptr /* bcp47 */, 0 /* bcp47Co unt */, | |
| 99 0x1f4b0 /* character: π° */)); | |
| 100 if (fallback) { | |
| 101 return fallback; | |
| 102 } | |
| 103 // If we don't have Segoe UI Emoji and can't find a fallback, try Segoe UI Symbol. | |
| 104 // Windows 7 does not have Segoe UI Emoji; Segoe UI Symbol has the (non - color) emoji. | |
| 105 return SkTypeface::MakeFromName("Segoe UI Symbol", SkTypeface::kNormal); | |
|
bungeman-skia
2016/05/31 19:19:58
This line conflicts with another change that just
Ilya Kulshin
2016/06/01 05:47:43
Done. Thanks for the headsup.
| |
| 106 } | |
| 85 return nullptr; | 107 return nullptr; |
| 86 } | 108 } |
| 87 | 109 |
| 88 const char* emoji_sample_text() { | 110 const char* emoji_sample_text() { |
| 89 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { | 111 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
| 90 return "Hamburgefons"; | 112 return "Hamburgefons"; |
| 91 } | 113 } |
| 92 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { | 114 if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX") || |
| 115 !strcmp(sk_tool_utils::platform_os_emoji(), "COLR")) | |
| 116 { | |
| 93 return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // π°π‘π | 117 return "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" // π°π‘π |
| 94 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // πͺππ | 118 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80" // πͺππ |
| 95 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // π»π©π· | 119 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93\xB7" // π»π©π· |
| 96 "\xF0\x9F\x93\xA6" // π¦ | 120 "\xF0\x9F\x93\xA6" // π¦ |
| 97 "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87\xA6"; // πΊπΈπ¦ | 121 "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87\xA6"; // πΊπΈπ¦ |
| 98 } | 122 } |
| 99 return ""; | 123 return ""; |
| 100 } | 124 } |
| 101 | 125 |
| 102 const char* platform_os_name() { | 126 const char* platform_os_name() { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 for (int y = 0; y < src.height(); ++y) { | 457 for (int y = 0; y < src.height(); ++y) { |
| 434 for (int x = 0; x < src.width(); ++x) { | 458 for (int x = 0; x < src.width(); ++x) { |
| 435 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); | 459 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); |
| 436 } | 460 } |
| 437 } | 461 } |
| 438 | 462 |
| 439 return dst; | 463 return dst; |
| 440 } | 464 } |
| 441 | 465 |
| 442 } // namespace sk_tool_utils | 466 } // namespace sk_tool_utils |
| OLD | NEW |