From 3cd22cc543ba410f8b46b8b0ca22fb8580040472 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 1 Dec 2017 11:49:58 -0500 Subject: working on skimage working on skimage Docs-Preview: https://skia.org/?cl=76562 Bug: skia: Change-Id: I288d2a9bbbdf01bff9efd5f0a9d308d3c76391a4 Reviewed-on: https://skia-review.googlesource.com/76562 Reviewed-by: Cary Clark Commit-Queue: Cary Clark --- docs/SkCanvas_Reference.bmh | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'docs/SkCanvas_Reference.bmh') diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 55dc86ba35..efbf41f57e 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -5316,6 +5316,8 @@ Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, Subpixel_Text, and Paint_Vertical_Text. +Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. + Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob. @@ -5327,25 +5329,26 @@ Image_Filter, and Draw_Looper; apply to blob. #Example #Height 120 void draw(SkCanvas* canvas) { - SkTextBlobBuilder textBlobBuilder; - const char bunny[] = "/(^x^)\\"; - const int len = sizeof(bunny) - 1; - uint16_t glyphs[len]; - SkPaint paint; - paint.textToGlyphs(bunny, len, glyphs); - int runs[] = { 3, 1, 3 }; - SkPoint textPos = { 20, 100 }; - int glyphIndex = 0; - for (auto runLen : runs) { - paint.setTextSize(1 == runLen ? 20 : 50); - const SkTextBlobBuilder::RunBuffer& run = - textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY); - memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen); - textPos.fX += paint.measureText(&bunny[glyphIndex], runLen, nullptr); - glyphIndex += runLen; - } - sk_sp blob = textBlobBuilder.make(); - paint.reset(); + SkTextBlobBuilder textBlobBuilder; + const char bunny[] = "/(^x^)\\"; + const int len = sizeof(bunny) - 1; + uint16_t glyphs[len]; + SkPaint paint; + paint.textToGlyphs(bunny, len, glyphs); + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); + int runs[] = { 3, 1, 3 }; + SkPoint textPos = { 20, 100 }; + int glyphIndex = 0; + for (auto runLen : runs) { + paint.setTextSize(1 == runLen ? 20 : 50); + const SkTextBlobBuilder::RunBuffer& run = + textBlobBuilder.allocRun(paint, runLen, textPos.fX, textPos.fY); + memcpy(run.glyphs, &glyphs[glyphIndex], sizeof(glyphs[0]) * runLen); + textPos.fX += paint.measureText(&glyphs[glyphIndex], sizeof(glyphs[0]) * runLen, nullptr); + glyphIndex += runLen; + } + sk_sp blob = textBlobBuilder.make(); + paint.reset(); canvas->drawTextBlob(blob.get(), 0, 0, paint); } ## @@ -5366,6 +5369,8 @@ Paint_Text_Align, Paint_Hinting, Anti-alias, Paint_Fake_Bold, Font_Embedded_Bitmaps, Full_Hinting_Spacing, LCD_Text, Linear_Text, Subpixel_Text, and Paint_Vertical_Text. +Paint_Text_Encoding must be set to SkPaint::kGlyphID_TextEncoding. + Elements of paint: Path_Effect, Rasterizer, Mask_Filter, Shader, Color_Filter, Image_Filter, and Draw_Looper; apply to blob. @@ -5385,6 +5390,7 @@ Paint attributes related to text, like text size, have no effect on paint passed SkPaint paint; paint.setTextSize(50); paint.setColor(SK_ColorRED); + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); const SkTextBlobBuilder::RunBuffer& run = textBlobBuilder.allocRun(paint, 1, 20, 100); run.glyphs[0] = 20; -- cgit v1.2.3