From 188bfcf7666f4d264329063fd9bf5c44e7734fd8 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Tue, 17 Jan 2012 18:26:38 +0000 Subject: if the y-max has neighbors (prev and next) with the same Y values, then the cross will be 0, but we can still know the direction by looking at the change in X Fixes the hypen in #7 of this bug http://code.google.com/p/chromium/issues/detail?id=109370 git-svn-id: http://skia.googlecode.com/svn/trunk@3049 2bbb7eff-a529-9590-31e7-b0007b416f81 --- gm/strokefill.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'gm/strokefill.cpp') diff --git a/gm/strokefill.cpp b/gm/strokefill.cpp index a37af806f4..75fa0087fb 100644 --- a/gm/strokefill.cpp +++ b/gm/strokefill.cpp @@ -27,24 +27,35 @@ protected: return make_isize(640, 480); } + static void show_bold(SkCanvas* canvas, const char text[], SkScalar x, + SkScalar y, const SkPaint& paint) { + size_t len = strlen(text); + SkPaint p(paint); + canvas->drawText(text, len, x, y, p); + p.setFakeBoldText(true); + canvas->drawText(text, len, x, y + SkIntToScalar(120), p); + } + virtual void onDraw(SkCanvas* canvas) { + SkScalar x = SkIntToScalar(100); + SkScalar y = SkIntToScalar(88); + SkPaint paint; - const char text[] = "Hello"; // "Hello"; - const size_t len = sizeof(text) - 1; paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(100)); -// SkTypeface* hira = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal); - SkTypeface* hira = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal); - paint.setTypeface(hira); - SkScalar x = SkIntToScalar(180); - SkScalar y = SkIntToScalar(88); - - canvas->drawText(text, len, x, y, paint); - paint.setFakeBoldText(true); - canvas->drawText(text, len, x, y + SkIntToScalar(100), paint); - paint.setStyle(SkPaint::kStrokeAndFill_Style); paint.setStrokeWidth(SkIntToScalar(5)); + SkTypeface* face = SkTypeface::CreateFromName("Papyrus", SkTypeface::kNormal); + SkSafeUnref(paint.setTypeface(face)); + show_bold(canvas, "Hello", x, y, paint); + + face = SkTypeface::CreateFromName("Hiragino Maru Gothic Pro", SkTypeface::kNormal); + SkSafeUnref(paint.setTypeface(face)); + const char hyphen[] = { 0xE3, 0x83, 0xBC, 0 }; + show_bold(canvas, hyphen, x + SkIntToScalar(300), y, paint); + + paint.setStyle(SkPaint::kStrokeAndFill_Style); + SkPath path; path.setFillType(SkPath::kWinding_FillType); path.addCircle(x, y + SkIntToScalar(200), SkIntToScalar(50), SkPath::kCW_Direction); -- cgit v1.2.3