From 483c772cfdd646fad3ae8aa187136191ae3babdc Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Tue, 20 Feb 2018 17:06:07 -0500 Subject: Add nativeFonts flag to Viewer. This moves DMFontMgr and several related files which are tightly related to fonts into tools/fonts, moves some flags around to prevent duplication, and adds the nativeFonts handling to Viewer. Change-Id: Id1bdad708a6b74319ac5ac9adfe21025db4ca0b2 Reviewed-on: https://skia-review.googlesource.com/108904 Commit-Queue: Ben Wagner Reviewed-by: Mike Klein --- tools/sk_tool_utils.cpp | 80 ------------------------------------------------- 1 file changed, 80 deletions(-) (limited to 'tools/sk_tool_utils.cpp') diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index f0672070f1..2eb8dba833 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -10,9 +10,6 @@ #include "Resources.h" #include "SkBitmap.h" #include "SkCanvas.h" -#include "SkCommonFlags.h" -#include "SkFontMgr.h" -#include "SkFontStyle.h" #include "SkImage.h" #include "SkPixelRef.h" #include "SkPM4f.h" @@ -24,75 +21,6 @@ namespace sk_tool_utils { -static const char* platform_os_name() { - for (int index = 0; index < FLAGS_key.count(); index += 2) { - if (!strcmp("os", FLAGS_key[index])) { - return FLAGS_key[index + 1]; - } - } - return ""; -} - -sk_sp emoji_typeface() { -#if defined(SK_BUILD_FOR_WIN) - sk_sp fm(SkFontMgr::RefDefault()); - const char *colorEmojiFontName = "Segoe UI Emoji"; - sk_sp typeface(fm->matchFamilyStyle(colorEmojiFontName, SkFontStyle())); - if (typeface) { - return typeface; - } - sk_sp 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()); - -#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 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) { - for (int index = 0; index < FLAGS_key.count(); index += 2) { - if (0 == strcmp("extra_config", FLAGS_key[index]) - && strstr(FLAGS_key[index + 1], substring)) { - return true; - } - } - return false; -} - -const char* platform_font_manager() { - if (extra_config_contains("GDI")) { - return "GDI"; - } - if (extra_config_contains("NativeFonts")){ - return platform_os_name(); - } - return ""; -} - - const char* alphatype_name(SkAlphaType at) { switch (at) { case kUnknown_SkAlphaType: return "Unknown"; @@ -128,14 +56,6 @@ SkColor color_to_565(SkColor color) { return SkPixel16ToColor(color16); } -sk_sp create_portable_typeface(const char* name, SkFontStyle style) { - return create_font(name, style); -} - -void set_portable_typeface(SkPaint* paint, const char* name, SkFontStyle style) { - paint->setTypeface(create_font(name, style)); -} - void write_pixels(SkCanvas* canvas, const SkBitmap& bitmap, int x, int y, SkColorType colorType, SkAlphaType alphaType) { SkBitmap tmp(bitmap); -- cgit v1.2.3