diff options
author | 2015-04-14 12:17:27 -0700 | |
---|---|---|
committer | 2015-04-14 12:17:27 -0700 | |
commit | 9e36c1a9306f052331550dab4728b9875127bfb5 (patch) | |
tree | dc081124538053c3d28376cb767527326da74d25 /tools/sk_tool_utils.cpp | |
parent | 8fe8fffdfa7464c6f7da773b8660a2043f4998e0 (diff) |
Start canonicalizing color for all A8 textblobs
BUG=skia:
Review URL: https://codereview.chromium.org/1076593002
Diffstat (limited to 'tools/sk_tool_utils.cpp')
-rw-r--r-- | tools/sk_tool_utils.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index c3e574a08e..1a88086a41 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -12,6 +12,7 @@ #include "SkCanvas.h" #include "SkShader.h" #include "SkTestScalerContext.h" +#include "SkTextBlob.h" DEFINE_bool(portableFonts, false, "Use portable fonts"); DEFINE_bool(resourceFonts, false, "Use resource fonts"); @@ -77,4 +78,20 @@ void draw_checkerboard(SkCanvas* canvas, SkColor c1, SkColor c2, int size) { canvas->drawPaint(paint); } +void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, const SkPaint& origPaint, + SkScalar x, SkScalar y) { + SkPaint paint(origPaint); + SkTDArray<uint16_t> glyphs; + + size_t len = strlen(text); + glyphs.append(paint.textToGlyphs(text, len, NULL)); + paint.textToGlyphs(text, len, glyphs.begin()); + + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); + const SkTextBlobBuilder::RunBuffer& run = builder->allocRun(paint, glyphs.count(), x, y, + NULL); + memcpy(run.glyphs, glyphs.begin(), glyphs.count() * sizeof(uint16_t)); +} + + } // namespace sk_tool_utils |