document drawSimpleText
Bug: skia: Change-Id: I9c7135447b5ddcb3eb84581529fc442472e2ceda Reviewed-on: https://skia-review.googlesource.com/c/181664 Auto-Submit: Mike Reed <reed@google.com> Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
ded032c4c9
commit
cb268f6416
@ -3919,8 +3919,8 @@ void draw(SkCanvas* canvas) {
|
|||||||
#Line # draws text into Canvas ##
|
#Line # draws text into Canvas ##
|
||||||
##
|
##
|
||||||
|
|
||||||
#Method void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
#Method void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||||
const SkPaint& paint)
|
SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint)
|
||||||
#In Draw_Text
|
#In Draw_Text
|
||||||
#In Draw
|
#In Draw
|
||||||
#Line # draws text at (x, y), using font advance ##
|
#Line # draws text at (x, y), using font advance ##
|
||||||
@ -3929,27 +3929,26 @@ void draw(SkCanvas* canvas) {
|
|||||||
#Example
|
#Example
|
||||||
#Height 200
|
#Height 200
|
||||||
#Description
|
#Description
|
||||||
The same text is drawn varying Paint_Text_Size and varying
|
The same text is drawn varying Paint_Text_Size and varying
|
||||||
Matrix.
|
Matrix.
|
||||||
##
|
##
|
||||||
void draw(SkCanvas* canvas) {
|
void draw(SkCanvas* canvas) {
|
||||||
SkPaint paint;
|
SkPaint paint;
|
||||||
paint.setAntiAlias(true);
|
SkFont font;
|
||||||
float textSizes[] = { 12, 18, 24, 36 };
|
float textSizes[] = { 12, 18, 24, 36 };
|
||||||
for (auto size: textSizes ) {
|
for (auto size: textSizes ) {
|
||||||
paint.setTextSize(size);
|
font.setSize(size);
|
||||||
canvas->drawText("Aa", 2, 10, 20, paint);
|
canvas->drawText("Aa", 2, kUTF8_SkTextEncoding, 10, 20, font, paint);
|
||||||
canvas->translate(0, size * 2);
|
canvas->translate(0, size * 2);
|
||||||
}
|
}
|
||||||
paint.reset();
|
font.setSize(12);
|
||||||
paint.setAntiAlias(true);
|
|
||||||
float yPos = 20;
|
float yPos = 20;
|
||||||
for (auto size: textSizes ) {
|
for (auto size: textSizes ) {
|
||||||
float scale = size / 12.f;
|
float scale = size / 12.f;
|
||||||
canvas->resetMatrix();
|
canvas->resetMatrix();
|
||||||
canvas->translate(100, 0);
|
canvas->translate(100, 0);
|
||||||
canvas->scale(scale, scale);
|
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;
|
yPos += size * 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1848,7 +1848,8 @@ public:
|
|||||||
void experimental_DrawImageSetV1(const ImageSetEntry imageSet[], int cnt,
|
void experimental_DrawImageSetV1(const ImageSetEntry imageSet[], int cnt,
|
||||||
SkFilterQuality quality, SkBlendMode mode);
|
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
|
text meaning depends on SkTextEncoding; by default, text is encoded as
|
||||||
UTF-8.
|
UTF-8.
|
||||||
@ -1870,7 +1871,27 @@ public:
|
|||||||
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
void drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
|
||||||
const SkPaint& paint);
|
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,
|
void drawSimpleText(const void* text, size_t byteLength, SkTextEncoding encoding,
|
||||||
SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);
|
SkScalar x, SkScalar y, const SkFont& font, const SkPaint& paint);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user