1 /* 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 8 #include "gm.h" 9 #include "sk_tool_utils.h" 10 #include "SkCanvas.h" 11 #include "SkPath.h" 12 13 /** 14 * Skia may draw from outlines when the size is very large, so we exercise that 15 * here. 16 */ 17 18 class BigTextGM : public skiagm::GM { 19 public: BigTextGM()20 BigTextGM() {} 21 22 protected: 23 onShortName()24 SkString onShortName() override { 25 return SkString("bigtext"); 26 } 27 onISize()28 SkISize onISize() override { 29 return SkISize::Make(640, 480); 30 } 31 onDraw(SkCanvas * canvas)32 void onDraw(SkCanvas* canvas) override { 33 SkPaint paint; 34 paint.setAntiAlias(true); 35 sk_tool_utils::set_portable_typeface(&paint); 36 paint.setTextSize(1500); 37 38 SkRect r; 39 (void)paint.measureText("/", 1, &r); 40 SkPoint pos = { 41 this->width()/2 - r.centerX(), 42 this->height()/2 - r.centerY() 43 }; 44 45 paint.setColor(SK_ColorRED); 46 canvas->drawString("/", pos.fX, pos.fY, paint); 47 48 paint.setColor(SK_ColorBLUE); 49 canvas->drawPosText("\\", 1, &pos, paint); 50 } 51 52 private: 53 typedef skiagm::GM INHERITED; 54 }; 55 56 DEF_GM(return new BigTextGM;) 57