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 "SkTypeface.h"
12 class FontScalerGM : public GM {
15 this->setBGColor(0xFFFFFFFF);
20 SkString onShortName() override {
21 SkString name("fontscaler");
22 name.append(sk_tool_utils::major_platform_os_name());
26 SkISize onISize() override {
27 return SkISize::Make(1450, 750);
30 void onDraw(SkCanvas* canvas) override {
33 paint.setAntiAlias(true);
34 paint.setLCDRenderText(true);
35 //With freetype the default (normal hinting) can be really ugly.
36 //Most distros now set slight (vertical hinting only) in any event.
37 paint.setHinting(SkPaint::kSlight_Hinting);
39 const char* text = "Hamburgefons ooo mmm";
40 const size_t textLen = strlen(text);
42 for (int j = 0; j < 2; ++j) {
43 // This used to do 6 iterations but it causes the N4 to crash in the MSAA4 config.
44 for (int i = 0; i < 5; ++i) {
45 SkScalar x = SkIntToScalar(10);
46 SkScalar y = SkIntToScalar(20);
48 SkAutoCanvasRestore acr(canvas, true);
49 canvas->translate(SkIntToScalar(50 + i * 230),
51 canvas->rotate(SkIntToScalar(i * 5), x, y * 10);
57 r.set(x - SkIntToScalar(3), SkIntToScalar(15),
58 x - SkIntToScalar(1), SkIntToScalar(280));
59 canvas->drawRect(r, p);
62 for (int ps = 6; ps <= 22; ps++) {
63 paint.setTextSize(SkIntToScalar(ps));
64 canvas->drawText(text, textLen, x, y, paint);
65 y += paint.getFontMetrics(nullptr);
68 canvas->translate(0, SkIntToScalar(360));
69 paint.setSubpixelText(true);
77 //////////////////////////////////////////////////////////////////////////////
79 static GM* MyFactory(void*) { return new FontScalerGM; }
80 static GMRegistry reg(MyFactory);