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