Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "gm/gm.h" |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 9 | #include "include/core/SkFont.h" |
| 10 | #include "include/core/SkPaint.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/utils/SkTextUtils.h" |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 12 | |
Ben Wagner | 7fde8e1 | 2019-05-01 17:28:53 -0400 | [diff] [blame] | 13 | #include <initializer_list> |
| 14 | |
| 15 | class SkCanvas; |
| 16 | |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 17 | // http://bug.skia.org/7315 |
| 18 | DEF_SIMPLE_GM(text_scale_skew, canvas, 256, 128) { |
| 19 | SkPaint p; |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 20 | p.setAntiAlias(true); |
Mike Reed | 9191913 | 2019-01-02 12:21:01 -0500 | [diff] [blame] | 21 | SkFont font; |
| 22 | font.setSize(18.0f); |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 23 | float y = 10.0f; |
| 24 | for (float scale : { 0.5f, 0.71f, 1.0f, 1.41f, 2.0f }) { |
Mike Reed | 9191913 | 2019-01-02 12:21:01 -0500 | [diff] [blame] | 25 | font.setScaleX(scale); |
| 26 | y += font.getSpacing(); |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 27 | float x = 50.0f; |
| 28 | for (float skew : { -0.5f, 0.0f, 0.5f }) { |
Mike Reed | 9191913 | 2019-01-02 12:21:01 -0500 | [diff] [blame] | 29 | font.setSkewX(skew); |
| 30 | SkTextUtils::DrawString(canvas, "Skia", x, y, font, p, SkTextUtils::kCenter_Align); |
Hal Canary | 9b491b2 | 2017-11-28 15:10:13 -0500 | [diff] [blame] | 31 | x += 78.0f; |
| 32 | } |
| 33 | } |
| 34 | } |