| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "gm.h" | 7 #include "gm.h" |
| 8 #include "Resources.h" | 8 #include "Resources.h" |
| 9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| 11 #include "SkSurface.h" | 11 #include "SkSurface.h" |
| 12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
| 13 | 13 |
| 14 class DFTextGM : public skiagm::GM { | 14 class DFTextGM : public skiagm::GM { |
| 15 public: | 15 public: |
| 16 DFTextGM() { | 16 DFTextGM() { |
| 17 this->setBGColor(0xFFFFFFFF); | 17 this->setBGColor(0xFFFFFFFF); |
| 18 fTypeface = NULL; | 18 fTypeface = NULL; |
| 19 } | 19 } |
| 20 | 20 |
| 21 virtual ~DFTextGM() { | 21 virtual ~DFTextGM() { |
| 22 SkSafeUnref(fTypeface); | 22 SkSafeUnref(fTypeface); |
| 23 } | 23 } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 void onOnceBeforeDraw() override { | 26 void onOnceBeforeDraw() override { |
| 27 SkString filename = GetResourcePath("/Funkster.ttf"); | 27 fTypeface = GetResourceAsTypeface("/fonts/Funkster.ttf"); |
| 28 SkAutoTDelete<SkFILEStream> stream(new SkFILEStream(filename.c_str())); | |
| 29 if (!stream->isValid()) { | |
| 30 SkDebugf("Could not find Funkster.ttf, please set --resourcePath cor
rectly.\n"); | |
| 31 return; | |
| 32 } | |
| 33 | |
| 34 fTypeface = SkTypeface::CreateFromStream(stream.detach()); | |
| 35 } | 28 } |
| 36 | 29 |
| 37 SkString onShortName() override { | 30 SkString onShortName() override { |
| 38 return SkString("dftext"); | 31 return SkString("dftext"); |
| 39 } | 32 } |
| 40 | 33 |
| 41 SkISize onISize() override { | 34 SkISize onISize() override { |
| 42 return SkISize::Make(1024, 768); | 35 return SkISize::Make(1024, 768); |
| 43 } | 36 } |
| 44 | 37 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 #endif | 227 #endif |
| 235 } | 228 } |
| 236 | 229 |
| 237 private: | 230 private: |
| 238 SkTypeface* fTypeface; | 231 SkTypeface* fTypeface; |
| 239 | 232 |
| 240 typedef skiagm::GM INHERITED; | 233 typedef skiagm::GM INHERITED; |
| 241 }; | 234 }; |
| 242 | 235 |
| 243 DEF_GM( return SkNEW(DFTextGM); ) | 236 DEF_GM( return SkNEW(DFTextGM); ) |
| OLD | NEW |