OLD | NEW |
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" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 void onDraw(SkCanvas* canvas) override { | 129 void onDraw(SkCanvas* canvas) override { |
130 SkPaint paint; | 130 SkPaint paint; |
131 paint.setAntiAlias(true); | 131 paint.setAntiAlias(true); |
132 paint.setTextSize(SkIntToScalar(30)); | 132 paint.setTextSize(SkIntToScalar(30)); |
133 | 133 |
134 const char* text = fApplyKerning ? "Type AWAY" : "Hamburgefons"; | 134 const char* text = fApplyKerning ? "Type AWAY" : "Hamburgefons"; |
135 const size_t textLen = strlen(text); | 135 const size_t textLen = strlen(text); |
136 | 136 |
137 SkScalar x = SkIntToScalar(10); | 137 SkScalar x = SkIntToScalar(10); |
138 SkScalar dy = paint.getFontMetrics(NULL); | 138 SkScalar dy = paint.getFontMetrics(nullptr); |
139 SkScalar y = dy; | 139 SkScalar y = dy; |
140 | 140 |
141 if (fApplyKerning) { | 141 if (fApplyKerning) { |
142 paint.setSubpixelText(true); | 142 paint.setSubpixelText(true); |
143 } else { | 143 } else { |
144 paint.setLinearText(true); | 144 paint.setLinearText(true); |
145 } | 145 } |
146 for (int i = 0; i < gFaceStylesCount; i++) { | 146 for (int i = 0; i < gFaceStylesCount; i++) { |
147 paint.setTypeface(fFaces[i]); | 147 paint.setTypeface(fFaces[i]); |
148 canvas->drawText(text, textLen, x, y, paint); | 148 canvas->drawText(text, textLen, x, y, paint); |
149 if (fApplyKerning) { | 149 if (fApplyKerning) { |
150 drawKernText(canvas, text, textLen, x + 240, y, paint); | 150 drawKernText(canvas, text, textLen, x + 240, y, paint); |
151 } | 151 } |
152 y += dy; | 152 y += dy; |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 private: | 156 private: |
157 typedef skiagm::GM INHERITED; | 157 typedef skiagm::GM INHERITED; |
158 }; | 158 }; |
159 | 159 |
160 /////////////////////////////////////////////////////////////////////////////// | 160 /////////////////////////////////////////////////////////////////////////////// |
161 | 161 |
162 DEF_GM( return new TypefaceStylesGM(false); ) | 162 DEF_GM( return new TypefaceStylesGM(false); ) |
163 DEF_GM( return new TypefaceStylesGM(true); ) | 163 DEF_GM( return new TypefaceStylesGM(true); ) |
OLD | NEW |