| Index: samplecode/SampleText.cpp
|
| diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp
|
| index 17456b2ee988e6cbfca5d02d6caa1fba434db5a3..bde8494c6b151e36253d6fd9f4e81c557348618a 100644
|
| --- a/samplecode/SampleText.cpp
|
| +++ b/samplecode/SampleText.cpp
|
| @@ -20,6 +20,7 @@
|
| #include "SkUtils.h"
|
| #include "SkColorPriv.h"
|
| #include "SkColorFilter.h"
|
| +#include "SkTextBlob.h"
|
| #include "SkTime.h"
|
| #include "SkTypeface.h"
|
| #include "SkXfermode.h"
|
| @@ -77,6 +78,13 @@ static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, SkSc
|
| const SkPaint& paint, SkScalar clickX) {
|
| SkPaint p(paint);
|
|
|
| + uint16_t glyphs[1000];
|
| + SkASSERT(length <= SK_ARRAY_COUNT(glyphs));
|
| + int glyphCount = paint.textToGlyphs(text, length, glyphs);
|
| + SkPaint glyphPaint = paint;
|
| + glyphPaint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
| + SkTextBlobBuilder blobBuilder;
|
| +
|
| #if 0
|
| canvas->drawText(text, length, x, y, paint);
|
| #else
|
| @@ -88,6 +96,11 @@ static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, SkSc
|
| pts[i].set(xpos, y), xpos += paint.getTextSize();
|
| }
|
| canvas->drawPosText(text, length, pts, paint);
|
| +
|
| + SkAutoTUnref<const SkTextBlob> blob(SkTextBlob::Create(
|
| + SkTextChunk::Create(glyphs, glyphCount, pts, glyphPaint)));
|
| + canvas->drawTextBlob(blob, SkPoint::Make(0, 400), glyphPaint);
|
| +
|
| }
|
| #endif
|
|
|
| @@ -95,6 +108,13 @@ static void DrawTheText(SkCanvas* canvas, const char text[], size_t length, SkSc
|
| x += SkIntToScalar(180);
|
| canvas->drawText(text, length, x, y, p);
|
|
|
| + {
|
| + glyphPaint.setSubpixelText(true);
|
| + SkAutoTUnref<const SkTextBlob> blob(SkTextBlob::Create(
|
| + SkTextChunk::Create(glyphs, glyphCount, glyphPaint)));
|
| + canvas->drawTextBlob(blob, SkPoint::Make(x, y + 400), glyphPaint);
|
| + }
|
| +
|
| #ifdef SK_DEBUG
|
| if (true) {
|
| p.setSubpixelText(false);
|
|
|