2 * Copyright 2011 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #include "sk_tool_utils.h"
9 #include "SkTypeface.h"
13 class FontScalerGM : public GM {
16 this->setBGColor(0xFFFFFFFF);
21 SkString onShortName() override {
22 SkString name("fontscaler");
23 name.append(sk_tool_utils::major_platform_os_name());
27 SkISize onISize() override {
28 return SkISize::Make(1450, 750);
31 void onDraw(SkCanvas* canvas) override {
34 paint.setAntiAlias(true);
35 paint.setLCDRenderText(true);
36 //With freetype the default (normal hinting) can be really ugly.
37 //Most distros now set slight (vertical hinting only) in any event.
38 paint.setHinting(SkPaint::kSlight_Hinting);
40 const char* text = "Hamburgefons ooo mmm";
41 const size_t textLen = strlen(text);
43 for (int j = 0; j < 2; ++j) {
44 // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config.
45 for (int i = 0; i < 5; ++i) {
46 SkScalar x = SkIntToScalar(10);
47 SkScalar y = SkIntToScalar(20);
49 SkAutoCanvasRestore acr(canvas, true);
50 canvas->translate(SkIntToScalar(50 + i * 230),
52 canvas->rotate(SkIntToScalar(i * 5), x, y * 10);
58 r.set(x - SkIntToScalar(3), SkIntToScalar(15),
59 x - SkIntToScalar(1), SkIntToScalar(280));
60 canvas->drawRect(r, p);
63 for (int ps = 6; ps <= 22; ps++) {
64 paint.setTextSize(SkIntToScalar(ps));
65 canvas->drawText(text, textLen, x, y, paint);
66 y += paint.getFontMetrics(nullptr);
69 canvas->translate(0, SkIntToScalar(360));
70 paint.setSubpixelText(true);
78 //////////////////////////////////////////////////////////////////////////////
80 static GM* MyFactory(void*) { return new FontScalerGM; }
81 static GMRegistry reg(MyFactory);