2 * Copyright 2015 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
9 #include "SkTypeface.h"
12 static void excercise_draw_pos_text(SkCanvas* canvas,
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) {
24 canvas->drawPosText(text, textLen, &pos[0], paint);
27 DEF_SIMPLE_GM(pdf_never_embed, canvas, 512, 512) {
30 p.setTypeface(MakeResourceAsTypeface("fonts/Roboto2-Regular_NoEmbed.ttf"));
33 if (!p.getTypeface()) {
37 const char text[] = "HELLO, WORLD!";
39 canvas->drawColor(SK_ColorWHITE);
40 excercise_draw_pos_text(canvas, text, 30, 90, p);
43 canvas->rotate(45.0f);
44 p.setColor(0xF0800000);
45 excercise_draw_pos_text(canvas, text, 30, 45, p);
49 canvas->scale(1, 4.0);
50 p.setColor(0xF0008000);
51 excercise_draw_pos_text(canvas, text, 15, 70, p);
54 canvas->scale(1.0, 0.5);
55 p.setColor(0xF0000080);
56 canvas->drawString(text, 30, 700, p);