From 2377b52ee43b7824656e50731cf0fae89c9a0c4f Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 13 Jul 2011 14:06:19 +0000 Subject: [PATCH] add more angles, and test lineartext git-svn-id: http://skia.googlecode.com/svn/trunk@1844 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SampleFontScalerTest.cpp | 60 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/samplecode/SampleFontScalerTest.cpp b/samplecode/SampleFontScalerTest.cpp index 0b0d349..844a88b 100644 --- a/samplecode/SampleFontScalerTest.cpp +++ b/samplecode/SampleFontScalerTest.cpp @@ -57,6 +57,12 @@ protected: return this->INHERITED::onQuery(evt); } + static void rotate_about(SkCanvas* canvas, SkScalar degrees, SkScalar px, SkScalar py) { + canvas->translate(px, py); + canvas->rotate(degrees); + canvas->translate(-px, -py); + } + virtual void onDrawContent(SkCanvas* canvas) { SkPaint paint; @@ -74,35 +80,41 @@ protected: canvas->drawPath(path, paint); } - canvas->translate(200, 20); - canvas->rotate(30); - paint.setAntiAlias(true); paint.setLCDRenderText(true); SkSafeUnref(paint.setTypeface(SkTypeface::CreateFromName("Times Roman", SkTypeface::kNormal))); // const char* text = "abcdefghijklmnopqrstuvwxyz"; - const char* text = "HnHnHnHnHnHnHnHnH"; - size_t textLen = strlen(text); - - SkScalar x = SkIntToScalar(10); - SkScalar y = SkIntToScalar(20); - - { - SkPaint p; - p.setColor(SK_ColorRED); - SkRect r; - r.set(0, 0, x, y*20); - canvas->drawRect(r, p); - } - - int index = 0; - for (int ps = 9; ps <= 24; ps++) { - textLen = strlen(text); - paint.setTextSize(SkIntToScalar(ps)); - canvas->drawText(text, textLen, x, y, paint); - y += paint.getFontMetrics(NULL); - index += 1; + const char* text = "HnHnHnHnHnHnHnH"; + const size_t textLen = strlen(text); + + for (int j = 0; j < 2; ++j) { + for (int i = 0; i < 6; ++i) { + SkScalar x = SkIntToScalar(10); + SkScalar y = SkIntToScalar(20); + + SkAutoCanvasRestore acr(canvas, true); + canvas->translate(50 + i * 230, 20); + rotate_about(canvas, i * 7, x, y * 10); + + { + SkPaint p; + p.setAntiAlias(true); + SkRect r; + r.set(x-3, 15, x-1, 280); + canvas->drawRect(r, p); + } + + int index = 0; + for (int ps = 9; ps <= 24; ps++) { + paint.setTextSize(SkIntToScalar(ps)); + canvas->drawText(text, textLen, x, y, paint); + y += paint.getFontMetrics(NULL); + index += 1; + } + } + canvas->translate(0, 400); + paint.setLinearText(true); } } -- 2.7.4