Debian Codegraph @

gm/text_scale_skew.cpp

raw
1 /*
2 * Copyright 2017 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 "gm/gm.h"
9 #include "include/core/SkCanvas.h"
10 #include "include/core/SkFont.h"
11 #include "include/core/SkPaint.h"
12 #include "include/utils/SkTextUtils.h"
13 #include "tools/fonts/FontToolUtils.h"
14
15 #include <initializer_list>
16
17 class SkCanvas;
18
19 static void draw_the_text(SkCanvas* canvas) {
20 SkPaint p;
21 p.setAntiAlias(true);
22 SkFont font = ToolUtils::DefaultPortableFont();
23 font.setSize(18.0f);
24 float y = 10.0f;
25 for (float scale : { 0.5f, 0.71f, 1.0f, 1.41f, 2.0f }) {
26 font.setScaleX(scale);
27 y += font.getSpacing();
28 float x = 50.0f;
29 for (float skew : { -0.5f, 0.0f, 0.5f }) {
30 font.setSkewX(skew);
31 SkTextUtils::DrawString(canvas, "Skia", x, y, font, p, SkTextUtils::kCenter_Align);
32 x += 78.0f;
33 }
34 }
35 }
36
37 // skbug.com/40038559
38 DEF_SIMPLE_GM(text_scale_skew, canvas, 256, 128) {
39 draw_the_text(canvas);
40 }
41
42 // make sure we apply matrices in the correct order inside scalercontext
43 DEF_SIMPLE_GM(text_scale_skew_rotate, canvas, 256, 128) {
44 canvas->rotate(30, 128, 64);
45
46 draw_the_text(canvas);
47 }