skia2/gm/bigtext.cpp

57 lines
1.3 KiB
C++
Raw Normal View History

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "sk_tool_utils.h"
#include "SkCanvas.h"
#include "SkFont.h"
#include "SkPath.h"
/**
* Skia may draw from outlines when the size is very large, so we exercise that
* here.
*/
class BigTextGM : public skiagm::GM {
public:
BigTextGM() {}
protected:
SkString onShortName() override {
return SkString("bigtext");
}
SkISize onISize() override {
return SkISize::Make(640, 480);
}
void onDraw(SkCanvas* canvas) override {
SkPaint paint;
paint.setAntiAlias(true);
SkFont font(sk_tool_utils::create_portable_typeface(), 1500);
SkRect r;
(void)font.measureText("/", 1, kUTF8_SkTextEncoding, &r);
SkPoint pos = {
this->width()/2 - r.centerX(),
this->height()/2 - r.centerY()
};
paint.setColor(SK_ColorRED);
canvas->drawSimpleText("/", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
paint.setColor(SK_ColorBLUE);
canvas->drawSimpleText("\\", 1, kUTF8_SkTextEncoding, pos.fX, pos.fY, font, paint);
}
private:
typedef skiagm::GM INHERITED;
};
DEF_GM(return new BigTextGM;)