blob: e491d10adddd564d0b0897b3855cdf02c128500a [file] [log] [blame]
reed@google.com5a649022013-06-05 18:00:30 +00001/*
2 * Copyright 2013 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 Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
9#include "include/core/SkCanvas.h"
Ben Wagner6a34f3a2019-05-01 10:59:30 -040010#include "include/core/SkColor.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050011#include "include/core/SkFont.h"
Ben Wagner6a34f3a2019-05-01 10:59:30 -040012#include "include/core/SkFontTypes.h"
13#include "include/core/SkPaint.h"
14#include "include/core/SkPoint.h"
15#include "include/core/SkRect.h"
16#include "include/core/SkSize.h"
17#include "include/core/SkString.h"
18#include "include/core/SkTypeface.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050019#include "tools/ToolUtils.h"
reed@google.com5a649022013-06-05 18:00:30 +000020
21/**
22 * Skia may draw from outlines when the size is very large, so we exercise that
23 * here.
24*/
25
26class BigTextGM : public skiagm::GM {
27public:
28 BigTextGM() {}
29
30protected:
commit-bot@chromium.orga90c6802014-04-30 13:20:45 +000031
mtklein36352bf2015-03-25 18:17:31 -070032 SkString onShortName() override {
reed@google.com5a649022013-06-05 18:00:30 +000033 return SkString("bigtext");
34 }
35
mtklein36352bf2015-03-25 18:17:31 -070036 SkISize onISize() override {
reed@google.com5a649022013-06-05 18:00:30 +000037 return SkISize::Make(640, 480);
38 }
39
mtklein36352bf2015-03-25 18:17:31 -070040 void onDraw(SkCanvas* canvas) override {
reed@google.com5a649022013-06-05 18:00:30 +000041 SkPaint paint;
42 paint.setAntiAlias(true);
Mike Kleinea3f0142019-03-20 11:12:10 -050043 SkFont font(ToolUtils::create_portable_typeface(), 1500);
reed@google.com5a649022013-06-05 18:00:30 +000044
45 SkRect r;
Ben Wagner51e15a62019-05-07 15:38:46 -040046 (void)font.measureText("/", 1, SkTextEncoding::kUTF8, &r);
reed@google.com5a649022013-06-05 18:00:30 +000047 SkPoint pos = {
48 this->width()/2 - r.centerX(),
49 this->height()/2 - r.centerY()
50 };
51
52 paint.setColor(SK_ColorRED);
Ben Wagner51e15a62019-05-07 15:38:46 -040053 canvas->drawSimpleText("/", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
skia.committer@gmail.comc5fd0932013-06-06 07:01:37 +000054
reed@google.com5a649022013-06-05 18:00:30 +000055 paint.setColor(SK_ColorBLUE);
Ben Wagner51e15a62019-05-07 15:38:46 -040056 canvas->drawSimpleText("\\", 1, SkTextEncoding::kUTF8, pos.fX, pos.fY, font, paint);
reed@google.com5a649022013-06-05 18:00:30 +000057 }
58
59private:
60 typedef skiagm::GM INHERITED;
61};
62
halcanary385fe4d2015-08-26 13:07:48 -070063DEF_GM(return new BigTextGM;)