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

Side by Side Diff: gm/pdf_never_embed.cpp

Issue 1401763002: SkPDF: fall back on paths for unembeddable fonts. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move fonts, no infinite loop Created 5 years, 2 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 | « no previous file | resources/fonts/Roboto2-Regular_NoEmbed.ttf » ('j') | tests/PDFPrimitivesTest.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Resources.h"
9 #include "SkTypeface.h"
10 #include "gm.h"
11
12 static void excercise_draw_pos_text(SkCanvas* canvas,
13 const char* text,
14 SkScalar x, SkScalar y,
15 const SkPaint& paint) {
16 size_t textLen = strlen(text);
17 SkAutoTArray<SkScalar> widths(SkToInt(textLen));
18 paint.getTextWidths(text, textLen, &widths[0]);
19 SkAutoTArray<SkPoint> pos(SkToInt(textLen));
20 for (int i = 0; i < SkToInt(textLen); ++i) {
21 pos[i].set(x, y);
22 x += widths[i];
23 }
24 canvas->drawPosText(text, textLen, &pos[0], paint);
25 }
26
27 DEF_SIMPLE_GM(pdf_never_embed, canvas, 512, 512) {
28 const char resource[] = "fonts/Roboto2-Regular_NoEmbed.ttf";
29 SkAutoTUnref<SkTypeface> typeface(GetResourceAsTypeface(resource));
30 if (!typeface) {
31 SkDebugf("Missing resource: %s", resource);
bungeman-skia 2015/10/12 19:26:30 GetResourceAsTypeface will already print SkDebugf
hal.canary 2015/10/12 19:48:24 Done.
32 return;
33 }
34 SkPaint p;
35 p.setTextSize(60);
36 p.setTypeface(typeface);
37 p.setAntiAlias(true);
38
39 const char text[] = "HELLO, WORLD!";
40
41 canvas->drawColor(SK_ColorWHITE);
42 excercise_draw_pos_text(canvas, text, 30, 90, p);
43
44 canvas->save();
45 canvas->rotate(45.0f);
46 p.setColor(0xF0800000);
47 excercise_draw_pos_text(canvas, text, 30, 45, p);
48 canvas->restore();
49
50 canvas->save();
51 canvas->scale(1, 4.0);
52 p.setColor(0xF0008000);
53 excercise_draw_pos_text(canvas, text, 15, 70, p);
54 canvas->restore();
55
56 canvas->scale(1.0, 0.5);
57 p.setColor(0xF0000080);
58 canvas->drawText(text, strlen(text), 30, 700, p);
59 }
OLDNEW
« no previous file with comments | « no previous file | resources/fonts/Roboto2-Regular_NoEmbed.ttf » ('j') | tests/PDFPrimitivesTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698