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

Side by Side Diff: gm/texteffects.cpp

Issue 1818043002: SkTypeface::MakeFromName to take SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Android fix + nit fix Created 4 years, 6 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/textblobrandomfont.cpp ('k') | gm/typeface.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 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkBlurMask.h" 9 #include "SkBlurMask.h"
10 #include "SkBlurMaskFilter.h" 10 #include "SkBlurMaskFilter.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 } 262 }
263 263
264 DEF_SIMPLE_GM(fancyunderline, canvas, 900, 1350) { 264 DEF_SIMPLE_GM(fancyunderline, canvas, 900, 1350) {
265 SkPaint paint; 265 SkPaint paint;
266 paint.setAntiAlias(true); 266 paint.setAntiAlias(true);
267 const char* fam[] = { "sans-serif", "serif", "monospace" }; 267 const char* fam[] = { "sans-serif", "serif", "monospace" };
268 const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ"; 268 const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ";
269 SkPoint textPt = { 10, 80 }; 269 SkPoint textPt = { 10, 80 };
270 for (int font = 0; font < 3; ++font) { 270 for (int font = 0; font < 3; ++font) {
271 sk_tool_utils::set_portable_typeface(&paint, fam[font], SkTypeface::kNor mal); 271 sk_tool_utils::set_portable_typeface(&paint, fam[font]);
272 for (SkScalar textSize = 100; textSize > 10; textSize -= 20) { 272 for (SkScalar textSize = 100; textSize > 10; textSize -= 20) {
273 paint.setTextSize(textSize); 273 paint.setTextSize(textSize);
274 const SkScalar uWidth = textSize / 15; 274 const SkScalar uWidth = textSize / 15;
275 paint.setStrokeWidth(uWidth); 275 paint.setStrokeWidth(uWidth);
276 paint.setStyle(SkPaint::kFill_Style); 276 paint.setStyle(SkPaint::kFill_Style);
277 canvas->drawText(test, sizeof(test) - 1, textPt.fX, textPt.fY, paint ); 277 canvas->drawText(test, sizeof(test) - 1, textPt.fX, textPt.fY, paint );
278 278
279 SkTDArray<SkScalar> intersections; 279 SkTDArray<SkScalar> intersections;
280 find_intercepts(test, sizeof(test) - 1, textPt.fX, textPt.fY, paint, uWidth, 280 find_intercepts(test, sizeof(test) - 1, textPt.fX, textPt.fY, paint, uWidth,
281 &intersections); 281 &intersections);
(...skipping 23 matching lines...) Expand all
305 } 305 }
306 } 306 }
307 307
308 DEF_SIMPLE_GM(fancyposunderline, canvas, 900, 1350) { 308 DEF_SIMPLE_GM(fancyposunderline, canvas, 900, 1350) {
309 SkPaint paint; 309 SkPaint paint;
310 paint.setAntiAlias(true); 310 paint.setAntiAlias(true);
311 const char* fam[] = { "sans-serif", "serif", "monospace" }; 311 const char* fam[] = { "sans-serif", "serif", "monospace" };
312 const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ"; 312 const char test[] = "aAjJgGyY_|{-(~[,]qQ}pP}zZ";
313 SkPoint textPt = { 10, 80 }; 313 SkPoint textPt = { 10, 80 };
314 for (int font = 0; font < 3; ++font) { 314 for (int font = 0; font < 3; ++font) {
315 sk_tool_utils::set_portable_typeface(&paint, fam[font], SkTypeface::kNor mal); 315 sk_tool_utils::set_portable_typeface(&paint, fam[font]);
316 for (SkScalar textSize = 100; textSize > 10; textSize -= 20) { 316 for (SkScalar textSize = 100; textSize > 10; textSize -= 20) {
317 paint.setTextSize(textSize); 317 paint.setTextSize(textSize);
318 const SkScalar uWidth = textSize / 15; 318 const SkScalar uWidth = textSize / 15;
319 paint.setStrokeWidth(uWidth); 319 paint.setStrokeWidth(uWidth);
320 paint.setStyle(SkPaint::kFill_Style); 320 paint.setStyle(SkPaint::kFill_Style);
321 int widthCount = paint.getTextWidths(test, sizeof(test) - 1, nullptr ); 321 int widthCount = paint.getTextWidths(test, sizeof(test) - 1, nullptr );
322 SkTDArray<SkScalar> widths; 322 SkTDArray<SkScalar> widths;
323 widths.setCount(widthCount); 323 widths.setCount(widthCount);
324 (void) paint.getTextWidths(test, sizeof(test) - 1, widths.begin()); 324 (void) paint.getTextWidths(test, sizeof(test) - 1, widths.begin());
325 SkTDArray<SkPoint> pos; 325 SkTDArray<SkPoint> pos;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 380
381 SkScalar start = textPt.fX; 381 SkScalar start = textPt.fX;
382 SkScalar end = posX; 382 SkScalar end = posX;
383 SkScalar uPos = pos[0].fY + uWidth; 383 SkScalar uPos = pos[0].fY + uWidth;
384 SkPath underline = create_underline(intersections, start, end, uPos, uWi dth, textSize); 384 SkPath underline = create_underline(intersections, start, end, uPos, uWi dth, textSize);
385 paint.setStyle(SkPaint::kStroke_Style); 385 paint.setStyle(SkPaint::kStroke_Style);
386 canvas->drawPath(underline, paint); 386 canvas->drawPath(underline, paint);
387 canvas->translate(0, textSize * 1.3f); 387 canvas->translate(0, textSize * 1.3f);
388 } 388 }
389 } 389 }
OLDNEW
« no previous file with comments | « gm/textblobrandomfont.cpp ('k') | gm/typeface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698