3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
10 /* Tests text rendering with LCD and subpixel rendering turned on and off.
18 class LcdTextGM : public GM {
21 const int pointSize = 36;
22 textHeight = SkIntToScalar(pointSize);
27 SkString onShortName() {
28 return SkString("lcdtext");
31 SkISize onISize() { return SkISize::Make(640, 480); }
33 virtual void onDraw(SkCanvas* canvas) {
36 drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderTrue"),
38 drawText(canvas, SkString("TEXT: SubpixelTrue LCDRenderFalse"),
40 drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderTrue"),
42 drawText(canvas, SkString("TEXT: SubpixelFalse LCDRenderFalse"),
46 void drawText(SkCanvas* canvas, const SkString& string,
47 bool subpixelTextEnabled, bool lcdRenderTextEnabled) {
49 paint.setColor(SK_ColorBLACK);
50 paint.setDither(true);
51 paint.setAntiAlias(true);
52 sk_tool_utils::set_portable_typeface(&paint);
53 paint.setSubpixelText(subpixelTextEnabled);
54 paint.setLCDRenderText(lcdRenderTextEnabled);
55 paint.setTextSize(textHeight);
57 canvas->drawText(string.c_str(), string.size(), 0, y, paint);
63 SkScalar y, textHeight;
66 ///////////////////////////////////////////////////////////////////////////////
68 static GM* MyFactory(void*) { return new LcdTextGM; }
69 static GMRegistry reg(MyFactory);