diff options
Diffstat (limited to 'docs/SkCanvas_Reference.bmh')
-rw-r--r-- | docs/SkCanvas_Reference.bmh | 44 |
1 files changed, 25 insertions, 19 deletions
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<const SkTextBlob> 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<const SkTextBlob> 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; |