| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 class ColorEmojiGM : public GM { | 47 class ColorEmojiGM : public GM { |
| 48 public: | 48 public: |
| 49 ColorEmojiGM() : fCBDT_CBLC_Typeface(NULL), fSBIX_Typeface(NULL) { } | 49 ColorEmojiGM() : fCBDT_CBLC_Typeface(NULL), fSBIX_Typeface(NULL) { } |
| 50 | 50 |
| 51 protected: | 51 protected: |
| 52 struct EmojiFont { | 52 struct EmojiFont { |
| 53 SkTypeface* typeface; | 53 SkTypeface* typeface; |
| 54 const char* text; | 54 const char* text; |
| 55 } emojiFonts[2]; | 55 } emojiFonts[2]; |
| 56 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 56 virtual void onOnceBeforeDraw() override { |
| 57 SkString filename = GetResourcePath("/Funkster.ttf"); | 57 SkString filename = GetResourcePath("/Funkster.ttf"); |
| 58 SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(filename.c_str())); | 58 SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(filename.c_str())); |
| 59 if (stream->isValid()) { | 59 if (stream->isValid()) { |
| 60 fCBDT_CBLC_Typeface.reset(SkTypeface::CreateFromStream(stream.detach
())); | 60 fCBDT_CBLC_Typeface.reset(SkTypeface::CreateFromStream(stream.detach
())); |
| 61 emojiFonts[0].typeface = fCBDT_CBLC_Typeface; | 61 emojiFonts[0].typeface = fCBDT_CBLC_Typeface; |
| 62 } else { | 62 } else { |
| 63 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); | 63 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); |
| 64 emojiFonts[0].typeface = NULL; | 64 emojiFonts[0].typeface = NULL; |
| 65 } | 65 } |
| 66 emojiFonts[0].text = "hamburgerfons"; | 66 emojiFonts[0].text = "hamburgerfons"; |
| 67 | 67 |
| 68 fSBIX_Typeface.reset(SkTypeface::CreateFromName("Apple Color Emoji", SkT
ypeface::kNormal)); | 68 fSBIX_Typeface.reset(SkTypeface::CreateFromName("Apple Color Emoji", SkT
ypeface::kNormal)); |
| 69 emojiFonts[1].typeface = fSBIX_Typeface; | 69 emojiFonts[1].typeface = fSBIX_Typeface; |
| 70 emojiFonts[1].text = "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E
\x85" // π°π‘π
| 70 emojiFonts[1].text = "\xF0\x9F\x92\xB0" "\xF0\x9F\x8F\xA1" "\xF0\x9F\x8E
\x85" // π°π‘π
|
| 71 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A
\x80" // πͺππ | 71 "\xF0\x9F\x8D\xAA" "\xF0\x9F\x8D\x95" "\xF0\x9F\x9A
\x80" // πͺππ |
| 72 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93
\xB7" // π»π©π· | 72 "\xF0\x9F\x9A\xBB" "\xF0\x9F\x92\xA9" "\xF0\x9F\x93
\xB7" // π»π©π· |
| 73 "\xF0\x9F\x93\xA6" // π¦ | 73 "\xF0\x9F\x93\xA6" // π¦ |
| 74 "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87
\xA6"; // πΊπΈπ¦ | 74 "\xF0\x9F\x87\xBA" "\xF0\x9F\x87\xB8" "\xF0\x9F\x87
\xA6"; // πΊπΈπ¦ |
| 75 } | 75 } |
| 76 | 76 |
| 77 SkString onShortName() SK_OVERRIDE { | 77 SkString onShortName() override { |
| 78 return SkString("coloremoji"); | 78 return SkString("coloremoji"); |
| 79 } | 79 } |
| 80 | 80 |
| 81 SkISize onISize() SK_OVERRIDE { | 81 SkISize onISize() override { |
| 82 return SkISize::Make(650, 900); | 82 return SkISize::Make(650, 900); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 85 void onDraw(SkCanvas* canvas) override { |
| 86 | 86 |
| 87 canvas->drawColor(SK_ColorGRAY); | 87 canvas->drawColor(SK_ColorGRAY); |
| 88 | 88 |
| 89 for (size_t i = 0; i < SK_ARRAY_COUNT(emojiFonts); ++i) { | 89 for (size_t i = 0; i < SK_ARRAY_COUNT(emojiFonts); ++i) { |
| 90 SkPaint paint; | 90 SkPaint paint; |
| 91 paint.setTypeface(emojiFonts[i].typeface); | 91 paint.setTypeface(emojiFonts[i].typeface); |
| 92 const char* text = emojiFonts[i].text; | 92 const char* text = emojiFonts[i].text; |
| 93 | 93 |
| 94 // draw text at different point sizes | 94 // draw text at different point sizes |
| 95 const int textSize[] = { 10, 30, 50, }; | 95 const int textSize[] = { 10, 30, 50, }; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 typedef GM INHERITED; | 178 typedef GM INHERITED; |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 ////////////////////////////////////////////////////////////////////////////// | 181 ////////////////////////////////////////////////////////////////////////////// |
| 182 | 182 |
| 183 static GM* MyFactory(void*) { return new ColorEmojiGM; } | 183 static GM* MyFactory(void*) { return new ColorEmojiGM; } |
| 184 static GMRegistry reg(MyFactory); | 184 static GMRegistry reg(MyFactory); |
| 185 | 185 |
| 186 } | 186 } |
| OLD | NEW |