diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-07 15:53:00 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-08-07 15:53:00 +0000 |
commit | 7b4531f64cbd85d32a77ceab1bdec8335c5a7864 (patch) | |
tree | 0f1321ec42ca779f3b49944c13ef0ace46239e58 /gm/getpostextpath.cpp | |
parent | 46f935002c2b25331e552520dc7b1a912e12dfdc (diff) |
change SkTextToPathIter to allow continuation even when there is no path for
the current glyph. Fixes bug in getTextPath() if there are spaces in the text.
Update gm to add space-characters, so images will have to be rebaselined.
git-svn-id: http://skia.googlecode.com/svn/trunk@4979 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm/getpostextpath.cpp')
-rw-r--r-- | gm/getpostextpath.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/gm/getpostextpath.cpp b/gm/getpostextpath.cpp index f1b810cd20..4f32a41927 100644 --- a/gm/getpostextpath.cpp +++ b/gm/getpostextpath.cpp @@ -22,13 +22,30 @@ protected: SkISize onISize() { return skiagm::make_isize(480, 780); } + static void strokePath(SkCanvas* canvas, const SkPath& path) { + SkPaint paint; + paint.setAntiAlias(true); + paint.setColor(SK_ColorRED); + paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPath(path, paint); + } + virtual void onDraw(SkCanvas* canvas) { - const char* text = "Hamburgefons"; + // explicitly add spaces, to test a prev. bug + const char* text = "Ham bur ge fons"; size_t len = strlen(text); + SkPath path; SkPaint paint; paint.setAntiAlias(true); paint.setTextSize(SkIntToScalar(48)); + + canvas->translate(SkIntToScalar(10), SkIntToScalar(64)); + + canvas->drawText(text, len, 0, 0, paint); + paint.getTextPath(text, len, 0, 0, &path); + strokePath(canvas, path); + path.reset(); SkAutoTArray<SkPoint> pos(len); SkAutoTArray<SkScalar> widths(len); @@ -42,19 +59,16 @@ protected: x += widths[i]; } - canvas->drawPosText(text, len, &pos[0], paint); + canvas->translate(0, SkIntToScalar(64)); - SkPath path; - paint.setColor(SK_ColorRED); - paint.setStyle(SkPaint::kStroke_Style); + canvas->drawPosText(text, len, &pos[0], paint); paint.getPosTextPath(text, len, &pos[0], &path); - canvas->drawPath(path, paint); + strokePath(canvas, path); } }; ////////////////////////////////////////////////////////////////////////////// static skiagm::GM* F(void*) { return new GetPosTextPathGM; } - static skiagm::GMRegistry gR(F); |