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

Side by Side Diff: gm/shadertext2.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/shadertext.cpp ('k') | gm/shadertext3.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 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkGradientShader.h" 9 #include "SkGradientShader.h"
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 localMatrices.top().fMatrix.setPerspY(+0.008f); 83 localMatrices.top().fMatrix.setPerspY(+0.008f);
84 localMatrices.top().fLabel = "Persp"; 84 localMatrices.top().fLabel = "Persp";
85 85
86 static SkBitmap bmp; 86 static SkBitmap bmp;
87 if (bmp.isNull()) { 87 if (bmp.isNull()) {
88 makebm(&bmp, kPointSize / 2, kPointSize / 2); 88 makebm(&bmp, kPointSize / 2, kPointSize / 2);
89 } 89 }
90 90
91 SkPaint fillPaint; 91 SkPaint fillPaint;
92 fillPaint.setAntiAlias(true); 92 fillPaint.setAntiAlias(true);
93 sk_tool_utils::set_portable_typeface(&fillPaint);
93 fillPaint.setTextSize(SkIntToScalar(kPointSize)); 94 fillPaint.setTextSize(SkIntToScalar(kPointSize));
94 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel); 95 fillPaint.setFilterLevel(SkPaint::kLow_FilterLevel);
95 96
96 SkPaint outlinePaint; 97 SkPaint outlinePaint;
97 outlinePaint.setAntiAlias(true); 98 outlinePaint.setAntiAlias(true);
99 sk_tool_utils::set_portable_typeface(&outlinePaint);
98 outlinePaint.setTextSize(SkIntToScalar(kPointSize)); 100 outlinePaint.setTextSize(SkIntToScalar(kPointSize));
99 outlinePaint.setStyle(SkPaint::kStroke_Style); 101 outlinePaint.setStyle(SkPaint::kStroke_Style);
100 outlinePaint.setStrokeWidth(0.f); 102 outlinePaint.setStrokeWidth(0.f);
101 103
102 SkScalar w = fillPaint.measureText(kText, kTextLen); 104 SkScalar w = fillPaint.measureText(kText, kTextLen);
103 static SkScalar kPadY = 0.5f * kPointSize; 105 static SkScalar kPadY = 0.5f * kPointSize;
104 static SkScalar kPadX = 1.5f * kPointSize; 106 static SkScalar kPadX = 1.5f * kPointSize;
105 107
106 SkPaint strokePaint(fillPaint); 108 SkPaint strokePaint(fillPaint);
107 strokePaint.setStyle(SkPaint::kStroke_Style); 109 strokePaint.setStyle(SkPaint::kStroke_Style);
108 strokePaint.setStrokeWidth(kPointSize * 0.1f); 110 strokePaint.setStrokeWidth(kPointSize * 0.1f);
109 111
110 SkPaint labelPaint; 112 SkPaint labelPaint;
111 labelPaint.setColor(0xff000000); 113 labelPaint.setColor(0xff000000);
112 labelPaint.setAntiAlias(true); 114 labelPaint.setAntiAlias(true);
115 sk_tool_utils::set_portable_typeface(&labelPaint);
113 labelPaint.setTextSize(12.f); 116 labelPaint.setTextSize(12.f);
114 117
115 canvas->translate(15.f, 15.f); 118 canvas->translate(15.f, 15.f);
116 canvas->drawBitmap(bmp, 0, 0); 119 canvas->drawBitmap(bmp, 0, 0);
117 canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f); 120 canvas->translate(0, bmp.height() + labelPaint.getTextSize() + 15.f);
118 121
119 static const char kLabelLabel[] = "localM / canvasM"; 122 static const char kLabelLabel[] = "localM / canvasM";
120 canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint); 123 canvas->drawText(kLabelLabel, strlen(kLabelLabel), 0, 0, labelPaint);
121 canvas->translate(0, 15.f); 124 canvas->translate(0, 15.f);
122 125
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 206
204 private: 207 private:
205 typedef GM INHERITED; 208 typedef GM INHERITED;
206 }; 209 };
207 210
208 /////////////////////////////////////////////////////////////////////////////// 211 ///////////////////////////////////////////////////////////////////////////////
209 212
210 static GM* MyFactory(void*) { return new ShaderText2GM; } 213 static GM* MyFactory(void*) { return new ShaderText2GM; }
211 static GMRegistry reg(MyFactory); 214 static GMRegistry reg(MyFactory);
212 } 215 }
OLDNEW
« no previous file with comments | « gm/shadertext.cpp ('k') | gm/shadertext3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698