2019-03-15 18:22:51 +00:00
|
|
|
// Copyright 2019 Google LLC.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tools/fiddle/examples.h"
|
2019-03-15 18:22:51 +00:00
|
|
|
// HASH=55f5e59350622c5e2834d1c85789f732
|
2019-03-18 20:06:34 +00:00
|
|
|
REG_FIDDLE(Canvas_drawText, 256, 200, false, 0) {
|
2019-03-15 18:22:51 +00:00
|
|
|
void draw(SkCanvas* canvas) {
|
|
|
|
SkPaint paint;
|
|
|
|
SkFont font;
|
|
|
|
float textSizes[] = { 12, 18, 24, 36 };
|
|
|
|
for (auto size: textSizes ) {
|
|
|
|
font.setSize(size);
|
|
|
|
canvas->drawString("Aa", 10, 20, font, paint);
|
|
|
|
canvas->translate(0, size * 2);
|
|
|
|
}
|
|
|
|
font = SkFont();
|
|
|
|
float yPos = 20;
|
|
|
|
for (auto size: textSizes ) {
|
|
|
|
float scale = size / 12.f;
|
|
|
|
canvas->resetMatrix();
|
|
|
|
canvas->translate(100, 0);
|
|
|
|
canvas->scale(scale, scale);
|
|
|
|
canvas->drawString("Aa", 10 / scale, yPos / scale, font, paint);
|
|
|
|
yPos += size * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // END FIDDLE
|