Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: gm/typeface.cpp

Issue 407183003: add portable and canonical font support for DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add atexit; rename to create_... Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gm/twopointradial.cpp ('k') | gm/variedtext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkString.h" 10 #include "SkString.h"
11 #include "SkTypeface.h" 11 #include "SkTypeface.h"
12 #include "SkTypes.h" 12 #include "SkTypes.h"
13 13
14 static const char* gFaces[] = { 14 static const char* gFaces[] = {
15 "Times Roman", 15 "Times Roman",
16 "Hiragino Maru Gothic Pro", 16 "Hiragino Maru Gothic Pro",
17 "Papyrus", 17 "Papyrus",
18 "Helvetica", 18 "Helvetica",
19 "Courier New" 19 "Courier New"
20 }; 20 };
21 21
22 class TypefaceGM : public skiagm::GM { 22 class TypefaceGM : public skiagm::GM {
23 public: 23 public:
24 TypefaceGM() { 24 TypefaceGM() {
25 fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)]; 25 fFaces = new SkTypeface*[SK_ARRAY_COUNT(gFaces)];
26 for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { 26 for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) {
27 fFaces[i] = SkTypeface::CreateFromName(gFaces[i], SkTypeface::kNorma l); 27 fFaces[i] = sk_tool_utils::create_portable_typeface(gFaces[i], SkTyp eface::kNormal);
28 } 28 }
29 } 29 }
30 30
31 virtual ~TypefaceGM() { 31 virtual ~TypefaceGM() {
32 for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) { 32 for (size_t i = 0; i < SK_ARRAY_COUNT(gFaces); i++) {
33 SkSafeUnref(fFaces[i]); 33 SkSafeUnref(fFaces[i]);
34 } 34 }
35 delete [] fFaces; 35 delete [] fFaces;
36 } 36 }
37 37
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles); 153 static const int gFaceStylesCount = SK_ARRAY_COUNT(gFaceStyles);
154 154
155 class TypefaceStylesGM : public skiagm::GM { 155 class TypefaceStylesGM : public skiagm::GM {
156 SkTypeface* fFaces[gFaceStylesCount]; 156 SkTypeface* fFaces[gFaceStylesCount];
157 bool fApplyKerning; 157 bool fApplyKerning;
158 158
159 public: 159 public:
160 TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) { 160 TypefaceStylesGM(bool applyKerning) : fApplyKerning(applyKerning) {
161 for (int i = 0; i < gFaceStylesCount; i++) { 161 for (int i = 0; i < gFaceStylesCount; i++) {
162 fFaces[i] = SkTypeface::CreateFromName(gFaceStyles[i].fName, 162 fFaces[i] = sk_tool_utils::create_portable_typeface(gFaceStyles[i].f Name,
163 gFaceStyles[i].fStyle); 163 gFaceStyles[i].fStyle);
164 } 164 }
165 } 165 }
166 166
167 virtual ~TypefaceStylesGM() { 167 virtual ~TypefaceStylesGM() {
168 for (int i = 0; i < gFaceStylesCount; i++) { 168 for (int i = 0; i < gFaceStylesCount; i++) {
169 SkSafeUnref(fFaces[i]); 169 SkSafeUnref(fFaces[i]);
170 } 170 }
171 } 171 }
172 172
173 protected: 173 protected:
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 private: 213 private:
214 typedef skiagm::GM INHERITED; 214 typedef skiagm::GM INHERITED;
215 }; 215 };
216 216
217 /////////////////////////////////////////////////////////////////////////////// 217 ///////////////////////////////////////////////////////////////////////////////
218 218
219 DEF_GM( return new TypefaceGM; ) 219 DEF_GM( return new TypefaceGM; )
220 DEF_GM( return new TypefaceStylesGM(false); ) 220 DEF_GM( return new TypefaceStylesGM(false); )
221 DEF_GM( return new TypefaceStylesGM(true); ) 221 DEF_GM( return new TypefaceStylesGM(true); )
OLDNEW
« no previous file with comments | « gm/twopointradial.cpp ('k') | gm/variedtext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698