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