2015-10-12 20:05:04 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Resources.h"
|
|
|
|
#include "SkTypeface.h"
|
|
|
|
#include "gm.h"
|
|
|
|
|
|
|
|
static void excercise_draw_pos_text(SkCanvas* canvas,
|
|
|
|
const char* text,
|
|
|
|
SkScalar x, SkScalar y,
|
|
|
|
const SkPaint& paint) {
|
|
|
|
size_t textLen = strlen(text);
|
|
|
|
SkAutoTArray<SkScalar> widths(SkToInt(textLen));
|
|
|
|
paint.getTextWidths(text, textLen, &widths[0]);
|
|
|
|
SkAutoTArray<SkPoint> pos(SkToInt(textLen));
|
|
|
|
for (int i = 0; i < SkToInt(textLen); ++i) {
|
|
|
|
pos[i].set(x, y);
|
|
|
|
x += widths[i];
|
|
|
|
}
|
|
|
|
canvas->drawPosText(text, textLen, &pos[0], paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_SIMPLE_GM(pdf_never_embed, canvas, 512, 512) {
|
|
|
|
SkPaint p;
|
|
|
|
p.setTextSize(60);
|
2016-05-12 17:09:30 +00:00
|
|
|
p.setTypeface(MakeResourceAsTypeface("fonts/Roboto2-Regular_NoEmbed.ttf"));
|
2015-10-12 20:05:04 +00:00
|
|
|
p.setAntiAlias(true);
|
|
|
|
|
2016-05-12 17:09:30 +00:00
|
|
|
if (!p.getTypeface()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-12 20:05:04 +00:00
|
|
|
const char text[] = "HELLO, WORLD!";
|
|
|
|
|
|
|
|
canvas->drawColor(SK_ColorWHITE);
|
|
|
|
excercise_draw_pos_text(canvas, text, 30, 90, p);
|
|
|
|
|
|
|
|
canvas->save();
|
|
|
|
canvas->rotate(45.0f);
|
|
|
|
p.setColor(0xF0800000);
|
|
|
|
excercise_draw_pos_text(canvas, text, 30, 45, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
canvas->save();
|
|
|
|
canvas->scale(1, 4.0);
|
|
|
|
p.setColor(0xF0008000);
|
|
|
|
excercise_draw_pos_text(canvas, text, 15, 70, p);
|
|
|
|
canvas->restore();
|
|
|
|
|
|
|
|
canvas->scale(1.0, 0.5);
|
|
|
|
p.setColor(0xF0000080);
|
2017-04-28 19:35:12 +00:00
|
|
|
canvas->drawString(text, 30, 700, p);
|
2015-10-12 20:05:04 +00:00
|
|
|
}
|
2018-03-09 17:16:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// should draw completely white.
|
|
|
|
DEF_SIMPLE_GM(pdf_crbug_772685, canvas, 612, 792) {
|
|
|
|
canvas->clipRect({-1, -1, 613, 793}, false);
|
|
|
|
canvas->translate(-571, 0);
|
|
|
|
canvas->scale(0.75, 0.75);
|
|
|
|
canvas->clipRect({-1, -1, 613, 793}, false);
|
|
|
|
canvas->translate(0, -816);
|
|
|
|
canvas->drawRect({0, 0, 1224, 1500}, SkPaint());
|
|
|
|
}
|
|
|
|
|