1 /*
2  * Copyright 2014 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "sk_tool_utils.h"
9 
10 #include "Resources.h"
11 #include "SkCommonFlags.h"
12 #include "SkFontMgr.h"
13 #include "SkFontStyle.h"
14 #include "SkMutex.h"
15 #include "SkOSFile.h"
16 #include "SkTestFontMgr.h"
17 #include "SkTypeface.h"
18 #include "SkUTF.h"
19 
20 namespace sk_tool_utils {
21 
emoji_typeface()22 sk_sp<SkTypeface> emoji_typeface() {
23     const char* filename;
24 #if defined(SK_BUILD_FOR_WIN)
25     filename = "fonts/colr.ttf";
26 #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
27     filename = "fonts/sbix.ttf";
28 #else
29     filename = "fonts/cbdt.ttf";
30 #endif
31     sk_sp<SkTypeface> typeface = MakeResourceAsTypeface(filename);
32     if (typeface) {
33         return typeface;
34     }
35     return SkTypeface::MakeFromName("Emoji", SkFontStyle());
36 }
37 
emoji_sample_text()38 const char* emoji_sample_text() {
39     return "\xF0\x9F\x98\x80" " " "\xE2\x99\xA2"; // �� ♢
40 }
create_font(const char * name,SkFontStyle style)41 static sk_sp<SkTypeface> create_font(const char* name, SkFontStyle style) {
42     static sk_sp<SkFontMgr> portableFontMgr = MakePortableFontMgr();
43     return portableFontMgr->legacyMakeTypeface(name, style);
44 }
45 
create_portable_typeface(const char * name,SkFontStyle style)46 sk_sp<SkTypeface> create_portable_typeface(const char* name, SkFontStyle style) {
47     return create_font(name, style);
48 }
49 }
50