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

Side by Side Diff: gm/bigtext.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 | « dm/DM.cpp ('k') | gm/colortype.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 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 "SkPath.h" 10 #include "SkPath.h"
(...skipping 16 matching lines...) Expand all
27 return SkString("bigtext"); 27 return SkString("bigtext");
28 } 28 }
29 29
30 virtual SkISize onISize() SK_OVERRIDE { 30 virtual SkISize onISize() SK_OVERRIDE {
31 return SkISize::Make(640, 480); 31 return SkISize::Make(640, 480);
32 } 32 }
33 33
34 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 34 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
35 SkPaint paint; 35 SkPaint paint;
36 paint.setAntiAlias(true); 36 paint.setAntiAlias(true);
37 sk_tool_utils::set_portable_typeface(&paint);
37 paint.setTextSize(1500); 38 paint.setTextSize(1500);
38 39
39 SkRect r; 40 SkRect r;
40 (void)paint.measureText("/", 1, &r); 41 (void)paint.measureText("/", 1, &r);
41 SkPoint pos = { 42 SkPoint pos = {
42 this->width()/2 - r.centerX(), 43 this->width()/2 - r.centerX(),
43 this->height()/2 - r.centerY() 44 this->height()/2 - r.centerY()
44 }; 45 };
45 46
46 paint.setColor(SK_ColorRED); 47 paint.setColor(SK_ColorRED);
47 canvas->drawText("/", 1, pos.fX, pos.fY, paint); 48 canvas->drawText("/", 1, pos.fX, pos.fY, paint);
48 49
49 paint.setColor(SK_ColorBLUE); 50 paint.setColor(SK_ColorBLUE);
50 canvas->drawPosText("\\", 1, &pos, paint); 51 canvas->drawPosText("\\", 1, &pos, paint);
51 } 52 }
52 53
53 private: 54 private:
54 typedef skiagm::GM INHERITED; 55 typedef skiagm::GM INHERITED;
55 }; 56 };
56 57
57 DEF_GM( return SkNEW(BigTextGM); ) 58 DEF_GM( return SkNEW(BigTextGM); )
OLDNEW
« no previous file with comments | « dm/DM.cpp ('k') | gm/colortype.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698