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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 fName.set("fontmgr_iter"); | 61 fName.set("fontmgr_iter"); |
62 if (fontMgr) { | 62 if (fontMgr) { |
63 fName.append("_factory"); | 63 fName.append("_factory"); |
64 fFM.reset(fontMgr); | 64 fFM.reset(fontMgr); |
65 } else { | 65 } else { |
66 fFM.reset(SkFontMgr::RefDefault()); | 66 fFM.reset(SkFontMgr::RefDefault()); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 protected: | 70 protected: |
71 SkString onShortName() SK_OVERRIDE { | 71 SkString onShortName() override { |
72 return fName; | 72 return fName; |
73 } | 73 } |
74 | 74 |
75 SkISize onISize() SK_OVERRIDE { | 75 SkISize onISize() override { |
76 return SkISize::Make(1536, 768); | 76 return SkISize::Make(1536, 768); |
77 } | 77 } |
78 | 78 |
79 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 79 void onDraw(SkCanvas* canvas) override { |
80 SkScalar y = 20; | 80 SkScalar y = 20; |
81 SkPaint paint; | 81 SkPaint paint; |
82 paint.setAntiAlias(true); | 82 paint.setAntiAlias(true); |
83 paint.setLCDRenderText(true); | 83 paint.setLCDRenderText(true); |
84 paint.setSubpixelText(true); | 84 paint.setSubpixelText(true); |
85 paint.setTextSize(17); | 85 paint.setTextSize(17); |
86 | 86 |
87 SkFontMgr* fm = fFM; | 87 SkFontMgr* fm = fFM; |
88 int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); | 88 int count = SkMin32(fm->countFamilies(), MAX_FAMILIES); |
89 | 89 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 class FontMgrMatchGM : public skiagm::GM { | 124 class FontMgrMatchGM : public skiagm::GM { |
125 SkAutoTUnref<SkFontMgr> fFM; | 125 SkAutoTUnref<SkFontMgr> fFM; |
126 | 126 |
127 public: | 127 public: |
128 FontMgrMatchGM() : fFM(SkFontMgr::RefDefault()) { | 128 FontMgrMatchGM() : fFM(SkFontMgr::RefDefault()) { |
129 SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); | 129 SkGraphics::SetFontCacheLimit(16 * 1024 * 1024); |
130 } | 130 } |
131 | 131 |
132 protected: | 132 protected: |
133 SkString onShortName() SK_OVERRIDE { | 133 SkString onShortName() override { |
134 return SkString("fontmgr_match"); | 134 return SkString("fontmgr_match"); |
135 } | 135 } |
136 | 136 |
137 SkISize onISize() SK_OVERRIDE { | 137 SkISize onISize() override { |
138 return SkISize::Make(640, 1024); | 138 return SkISize::Make(640, 1024); |
139 } | 139 } |
140 | 140 |
141 void iterateFamily(SkCanvas* canvas, const SkPaint& paint, | 141 void iterateFamily(SkCanvas* canvas, const SkPaint& paint, |
142 SkFontStyleSet* fset) { | 142 SkFontStyleSet* fset) { |
143 SkPaint p(paint); | 143 SkPaint p(paint); |
144 SkScalar y = 0; | 144 SkScalar y = 0; |
145 | 145 |
146 for (int j = 0; j < fset->count(); ++j) { | 146 for (int j = 0; j < fset->count(); ++j) { |
147 SkString sname; | 147 SkString sname; |
(...skipping 21 matching lines...) Expand all Loading... |
169 SkString str; | 169 SkString str; |
170 str.printf("request [%d %d]", fs.weight(), fs.width()); | 170 str.printf("request [%d %d]", fs.weight(), fs.width()); |
171 p.setTypeface(face)->unref(); | 171 p.setTypeface(face)->unref(); |
172 (void)drawString(canvas, str, 0, y, p); | 172 (void)drawString(canvas, str, 0, y, p); |
173 y += 24; | 173 y += 24; |
174 } | 174 } |
175 } | 175 } |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 179 void onDraw(SkCanvas* canvas) override { |
180 SkPaint paint; | 180 SkPaint paint; |
181 paint.setAntiAlias(true); | 181 paint.setAntiAlias(true); |
182 paint.setLCDRenderText(true); | 182 paint.setLCDRenderText(true); |
183 paint.setSubpixelText(true); | 183 paint.setSubpixelText(true); |
184 paint.setTextSize(17); | 184 paint.setTextSize(17); |
185 | 185 |
186 static const char* gNames[] = { | 186 static const char* gNames[] = { |
187 "Helvetica Neue", "Arial" | 187 "Helvetica Neue", "Arial" |
188 }; | 188 }; |
189 | 189 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 230 } |
231 | 231 |
232 SkRect r = paint.getFontBounds(); | 232 SkRect r = paint.getFontBounds(); |
233 r.offset(x, y); | 233 r.offset(x, y); |
234 SkPaint p(paint); | 234 SkPaint p(paint); |
235 p.setColor(boundsColor); | 235 p.setColor(boundsColor); |
236 canvas->drawRect(r, p); | 236 canvas->drawRect(r, p); |
237 } | 237 } |
238 | 238 |
239 protected: | 239 protected: |
240 SkString onShortName() SK_OVERRIDE { | 240 SkString onShortName() override { |
241 return fName; | 241 return fName; |
242 } | 242 } |
243 | 243 |
244 SkISize onISize() SK_OVERRIDE { | 244 SkISize onISize() override { |
245 return SkISize::Make(1024, 850); | 245 return SkISize::Make(1024, 850); |
246 } | 246 } |
247 | 247 |
248 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 248 void onDraw(SkCanvas* canvas) override { |
249 SkPaint paint; | 249 SkPaint paint; |
250 paint.setAntiAlias(true); | 250 paint.setAntiAlias(true); |
251 paint.setSubpixelText(true); | 251 paint.setSubpixelText(true); |
252 paint.setTextSize(100); | 252 paint.setTextSize(100); |
253 paint.setStyle(SkPaint::kStroke_Style); | 253 paint.setStyle(SkPaint::kStroke_Style); |
254 paint.setTextScaleX(fScaleX); | 254 paint.setTextScaleX(fScaleX); |
255 paint.setTextSkewX(fSkewX); | 255 paint.setTextSkewX(fSkewX); |
256 | 256 |
257 const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE }; | 257 const SkColor boundsColors[2] = { SK_ColorRED, SK_ColorBLUE }; |
258 | 258 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 DEF_GM( return SkNEW(FontMgrGM); ) | 296 DEF_GM( return SkNEW(FontMgrGM); ) |
297 DEF_GM( return SkNEW(FontMgrMatchGM); ) | 297 DEF_GM( return SkNEW(FontMgrMatchGM); ) |
298 DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, 0)); ) | 298 DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, 0)); ) |
299 DEF_GM( return SkNEW(FontMgrBoundsGM(0.75, 0)); ) | 299 DEF_GM( return SkNEW(FontMgrBoundsGM(0.75, 0)); ) |
300 DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, -0.25)); ) | 300 DEF_GM( return SkNEW(FontMgrBoundsGM(1.0, -0.25)); ) |
301 | 301 |
302 #ifdef SK_BUILD_FOR_WIN | 302 #ifdef SK_BUILD_FOR_WIN |
303 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) | 303 DEF_GM( return SkNEW_ARGS(FontMgrGM, (SkFontMgr_New_DirectWrite())); ) |
304 #endif | 304 #endif |
OLD | NEW |