diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 5fb97e9a6f..bdbf92dbb6 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -3919,8 +3919,8 @@ void draw(SkCanvas* canvas) { #Line # draws text into Canvas ## ## -#Method void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, - const SkPaint& paint) +#Method void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding, + SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint) #In Draw_Text #In Draw #Line # draws text at (x, y), using font advance ## @@ -3929,27 +3929,26 @@ void draw(SkCanvas* canvas) { #Example #Height 200 #Description - The same text is drawn varying Paint_Text_Size and varying - Matrix. +The same text is drawn varying Paint_Text_Size and varying +Matrix. ## void draw(SkCanvas* canvas) { SkPaint paint; - paint.setAntiAlias(true); + SkFont font; float textSizes[] = { 12, 18, 24, 36 }; for (auto size: textSizes ) { - paint.setTextSize(size); - canvas->drawText("Aa", 2, 10, 20, paint); + font.setSize(size); + canvas->drawText("Aa", 2, kUTF8_SkTextEncoding, 10, 20, font, paint); canvas->translate(0, size * 2); } - paint.reset(); - paint.setAntiAlias(true); + font.setSize(12); float yPos = 20; for (auto size: textSizes ) { float scale = size / 12.f; canvas->resetMatrix(); canvas->translate(100, 0); canvas->scale(scale, scale); - canvas->drawText("Aa", 2, 10 / scale, yPos / scale, paint); + canvas->drawText("Aa", 2, kUTF8_SkTextEncoding, 10 / scale, yPos / scale, font, paint); yPos += size * 2; } } diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 49aff57004..a6491e8eff 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -1848,7 +1848,8 @@ public: void experimental_DrawImageSetV1(const ImageSetEntry imageSet[], int cnt, SkFilterQuality quality, SkBlendMode mode); - /** Draws text, with origin at (x, y), using clip, SkMatrix, and SkPaint paint. + /** DEPRECATED. Use drawSimpleText or drawTextBlob. + Draws text, with origin at (x, y), using clip, SkMatrix, and SkPaint paint. text meaning depends on SkTextEncoding; by default, text is encoded as UTF-8. @@ -1870,7 +1871,27 @@ public: void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, const SkPaint& paint); - // Experimental + /** Draws text, with origin at (x, y), using clip, SkMatrix, and SkPaint paint. + + text meaning depends on SkTextEncoding; by default, text is encoded as + UTF-8. + + x and y meaning depends on SkPaint::Align and SkPaint vertical text; by default + text draws left to right, positioning the first glyph left side bearing at x + and its baseline at y. Text size is affected by SkMatrix and SkPaint text size. + + All elements of paint: SkPathEffect, SkMaskFilter, SkShader, + SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws + filled 12 point black glyphs. + + @param text character code points or glyphs drawn + @param byteLength byte length of text array + @param encoding text encoding used in the text array + @param x start of text on x-axis + @param y start of text on y-axis + @param font typeface, text size and so, used to describe the text + @param paint blend, color, and so on, used to draw + */ void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding, SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);