OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "gm.h" | 8 #include "gm.h" |
9 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 canvas->drawTextBlob(blob, 0, 0, paint); | 32 canvas->drawTextBlob(blob, 0, 0, paint); |
33 canvas->restore(); | 33 canvas->restore(); |
34 } | 34 } |
35 | 35 |
36 class MixedTextBlobsGM : public GM { | 36 class MixedTextBlobsGM : public GM { |
37 public: | 37 public: |
38 MixedTextBlobsGM() { } | 38 MixedTextBlobsGM() { } |
39 | 39 |
40 protected: | 40 protected: |
41 void onOnceBeforeDraw() override { | 41 void onOnceBeforeDraw() override { |
42 #ifndef SK_BUILD_FOR_MAC | 42 if (!strcmp(sk_tool_utils::platform_os_emoji(), "CBDT")) { |
43 fEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); | 43 fEmojiTypeface.reset(GetResourceAsTypeface("/fonts/Funkster.ttf")); |
44 fEmojiText = "Emoji!!!"; | 44 fEmojiText = "Emoji!!!"; |
45 #else | 45 } else if (!strcmp(sk_tool_utils::platform_os_emoji(), "SBIX")) { |
46 fEmojiTypeface.reset(SkTypeface::CreateFromName("Apple Color Emoji", SkT
ypeface::kNormal)); | 46 fEmojiTypeface.reset(SkTypeface::CreateFromName("Apple Color Emoji", |
47 fEmojiText = "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85" //
💰🏡🎅 | 47 SkTypeface::kNormal)
); |
48 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80"; /
/ 🍪🍕🚀 | 48 fEmojiText = "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E\x85
" // 💰🏡🎅 |
49 #endif | 49 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A\x80
"; // 🍪🍕🚀 |
| 50 } else { |
| 51 fEmojiTypeface.reset(NULL); |
| 52 fEmojiText = ""; |
| 53 } |
50 fReallyBigATypeface.reset(GetResourceAsTypeface("/fonts/ReallyBigA.ttf")
); | 54 fReallyBigATypeface.reset(GetResourceAsTypeface("/fonts/ReallyBigA.ttf")
); |
51 | 55 |
52 SkTextBlobBuilder builder; | 56 SkTextBlobBuilder builder; |
53 | 57 |
54 // make textblob | 58 // make textblob |
55 // Text so large we draw as paths | 59 // Text so large we draw as paths |
56 SkPaint paint; | 60 SkPaint paint; |
57 paint.setTextSize(385); | 61 paint.setTextSize(385); |
58 const char* text = "O"; | 62 const char* text = "O"; |
59 sk_tool_utils::set_portable_typeface(&paint); | 63 sk_tool_utils::set_portable_typeface(&paint); |
(...skipping 16 matching lines...) Expand all Loading... |
76 paint.setTextSize(32); | 80 paint.setTextSize(32); |
77 text = "LCD!!!!!"; | 81 text = "LCD!!!!!"; |
78 paint.setSubpixelText(true); | 82 paint.setSubpixelText(true); |
79 paint.setLCDRenderText(true); | 83 paint.setLCDRenderText(true); |
80 paint.measureText(text, strlen(text), &bounds); | 84 paint.measureText(text, strlen(text), &bounds); |
81 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bounds.
width() * 0.25f, | 85 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bounds.
width() * 0.25f, |
82 yOffset - bounds.height() * 0.5f); | 86 yOffset - bounds.height() * 0.5f); |
83 yOffset += bounds.height(); | 87 yOffset += bounds.height(); |
84 | 88 |
85 // color emoji | 89 // color emoji |
86 paint.setSubpixelText(false); | 90 if (fEmojiTypeface) { |
87 paint.setLCDRenderText(false); | 91 paint.setSubpixelText(false); |
88 paint.setTypeface(fEmojiTypeface); | 92 paint.setLCDRenderText(false); |
89 text = fEmojiText; | 93 paint.setTypeface(fEmojiTypeface); |
90 paint.measureText(text, strlen(text), &bounds); | 94 text = fEmojiText; |
91 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bounds.
width() * 0.3f, | 95 paint.measureText(text, strlen(text), &bounds); |
92 yOffset); | 96 sk_tool_utils::add_to_text_blob(&builder, text, paint, xOffset - bou
nds.width() * 0.3f, |
| 97 yOffset); |
| 98 } |
93 | 99 |
94 // Corrupted font | 100 // Corrupted font |
95 paint.setTextSize(12); | 101 paint.setTextSize(12); |
96 text = "aA"; | 102 text = "aA"; |
97 paint.setTypeface(fReallyBigATypeface); | 103 paint.setTypeface(fReallyBigATypeface); |
98 sk_tool_utils::add_to_text_blob(&builder, text, paint, corruptedAx, corr
uptedAy); | 104 sk_tool_utils::add_to_text_blob(&builder, text, paint, corruptedAx, corr
uptedAy); |
99 fBlob.reset(builder.build()); | 105 fBlob.reset(builder.build()); |
100 } | 106 } |
101 | 107 |
102 SkString onShortName() override { | 108 SkString onShortName() override { |
103 return SkString("mixedtextblobs"); | 109 SkString name("mixedtextblobs"); |
| 110 name.append(sk_tool_utils::platform_os_emoji()); |
| 111 return name; |
104 } | 112 } |
105 | 113 |
106 SkISize onISize() override { | 114 SkISize onISize() override { |
107 return SkISize::Make(kWidth, kHeight); | 115 return SkISize::Make(kWidth, kHeight); |
108 } | 116 } |
109 | 117 |
110 void onDraw(SkCanvas* canvas) override { | 118 void onDraw(SkCanvas* canvas) override { |
111 | 119 |
112 canvas->drawColor(SK_ColorGRAY); | 120 canvas->drawColor(SK_ColorGRAY); |
113 | 121 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 static const int kWidth = 1250; | 166 static const int kWidth = 1250; |
159 static const int kHeight = 700; | 167 static const int kHeight = 700; |
160 | 168 |
161 typedef GM INHERITED; | 169 typedef GM INHERITED; |
162 }; | 170 }; |
163 | 171 |
164 ////////////////////////////////////////////////////////////////////////////// | 172 ////////////////////////////////////////////////////////////////////////////// |
165 | 173 |
166 DEF_GM( return SkNEW(MixedTextBlobsGM); ) | 174 DEF_GM( return SkNEW(MixedTextBlobsGM); ) |
167 } | 175 } |
OLD | NEW |