1c23557b6e
replace SkPaint::kGlyphID_TextEncoding with kGlyphID_SkTextEncoding NOTRY=true TBR=reed@google.com Docs-Preview: https://skia.org/?cl=175340 Bug: skia: Change-Id: I5835bf2d45969b727d9c895d34d7adb7c15b251c Reviewed-on: https://skia-review.googlesource.com/c/175340 Commit-Queue: Cary Clark <caryclark@skia.org> Auto-Submit: Cary Clark <caryclark@skia.org> Reviewed-by: Cary Clark <caryclark@skia.org>
203 lines
5.2 KiB
Plaintext
203 lines
5.2 KiB
Plaintext
#Topic Text_Blob_Builder
|
|
#Alias Text_Blob_Builder_Reference ##
|
|
|
|
#Class SkTextBlobBuilder
|
|
|
|
#Code
|
|
#Populate
|
|
##
|
|
|
|
Helper class for constructing SkTextBlob.
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Struct RunBuffer
|
|
#Line # storage for Glyphs and Glyph positions ##
|
|
|
|
#Code
|
|
struct RunBuffer {
|
|
SkGlyphID* glyphs;
|
|
SkScalar* pos;
|
|
char* utf8text;
|
|
uint32_t* clusters;
|
|
};
|
|
##
|
|
|
|
RunBuffer supplies storage for Glyphs and positions within a run.
|
|
|
|
A run is a sequence of Glyphs sharing Font_Metrics and positioning.
|
|
Each run may position its Glyphs in one of three ways:
|
|
by specifying where the first Glyph is drawn, and allowing Font_Metrics to
|
|
determine the advance to subsequent Glyphs; by specifying a baseline, and
|
|
the position on that baseline for each Glyph in run; or by providing Point
|
|
array, one per Glyph.
|
|
|
|
#Member SkGlyphID* glyphs
|
|
#Line # storage for Glyphs in run ##
|
|
glyphs points to memory for one or more Glyphs. glyphs memory must be
|
|
written to by the caller.
|
|
##
|
|
|
|
#Member SkScalar* pos
|
|
#Line # storage for positions in run ##
|
|
pos points to memory for Glyph positions. Depending on how RunBuffer
|
|
is allocated, pos may point to zero bytes per Glyph, one Scalar per Glyph,
|
|
or one Point per Glyph.
|
|
##
|
|
|
|
#Member char* utf8text
|
|
#Line # reserved for future use ##
|
|
Reserved for future use. utf8text should not be read or written.
|
|
##
|
|
|
|
#Member uint32_t* clusters
|
|
#Line # reserved for future use ##
|
|
Reserved for future use. clusters should not be read or written.
|
|
##
|
|
|
|
#SeeAlso allocRun allocRunPos allocRunPosH
|
|
|
|
#Struct RunBuffer ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method SkTextBlobBuilder()
|
|
#In Constructors
|
|
#Line # constructs with default values ##
|
|
#Populate
|
|
|
|
#Example
|
|
SkTextBlobBuilder builder;
|
|
sk_sp<SkTextBlob> blob = builder.make();
|
|
SkDebugf("blob " "%s" " nullptr", blob == nullptr ? "equals" : "does not equal");
|
|
#StdOut
|
|
blob equals nullptr
|
|
##
|
|
##
|
|
|
|
#SeeAlso make SkTextBlob::MakeFromText
|
|
|
|
#Method ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method ~SkTextBlobBuilder()
|
|
#In Constructors
|
|
#Line # deletes storage ##
|
|
#Populate
|
|
|
|
#NoExample
|
|
##
|
|
|
|
#SeeAlso SkTextBlobBuilder()
|
|
|
|
#Method ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method sk_sp<SkTextBlob> make()
|
|
#In Constructors
|
|
#Line # constructs Text_Blob from bulider ##
|
|
#Populate
|
|
|
|
#Example
|
|
SkTextBlobBuilder builder;
|
|
sk_sp<SkTextBlob> blob = builder.make();
|
|
SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
|
|
SkPaint paint;
|
|
paint.setTextEncoding(kGlyphID_SkTextEncoding);
|
|
SkFont font;
|
|
paint.textToGlyphs("x", 1, builder.allocRun(font, 1, 20, 20).glyphs);
|
|
blob = builder.make();
|
|
SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
|
|
blob = builder.make();
|
|
SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
|
|
#StdOut
|
|
blob equals nullptr
|
|
blob does not equal nullptr
|
|
blob equals nullptr
|
|
##
|
|
##
|
|
|
|
#SeeAlso SkTextBlob::MakeFromText
|
|
|
|
#Method ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method const RunBuffer& allocRun(const SkFont& font, int count, SkScalar x, SkScalar y,
|
|
const SkRect* bounds = nullptr)
|
|
#In Allocator
|
|
#Line # returns writable glyph buffer at Point ##
|
|
|
|
#Populate
|
|
|
|
#Example
|
|
#Height 60
|
|
SkTextBlobBuilder builder;
|
|
SkFont font;
|
|
SkPaint paint;
|
|
const SkTextBlobBuilder::RunBuffer& run = builder.allocRun(font, 5, 20, 20);
|
|
paint.textToGlyphs("hello", 5, run.glyphs);
|
|
canvas->drawRect({20, 20, 30, 30}, paint);
|
|
canvas->drawTextBlob(builder.make(), 20, 20, paint);
|
|
##
|
|
|
|
#SeeAlso allocRunPosH allocRunPos
|
|
|
|
#Method ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method const RunBuffer& allocRunPosH(const SkFont& font, int count, SkScalar y,
|
|
const SkRect* bounds = nullptr)
|
|
#In Allocator
|
|
#Line # returns writable glyph and x-axis position buffers ##
|
|
|
|
#Populate
|
|
|
|
#Example
|
|
#Height 60
|
|
SkTextBlobBuilder builder;
|
|
SkPaint paint;
|
|
SkFont font;
|
|
const SkTextBlobBuilder::RunBuffer& run = builder.allocRunPosH(font, 5, 20);
|
|
paint.textToGlyphs("hello", 5, run.glyphs);
|
|
SkScalar positions[] = {0, 10, 20, 40, 80};
|
|
memcpy(run.pos, positions, sizeof(positions));
|
|
canvas->drawTextBlob(builder.make(), 20, 20, paint);
|
|
##
|
|
|
|
#SeeAlso allocRunPos allocRun
|
|
|
|
#Method ##
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
#Method const RunBuffer& allocRunPos(const SkFont& font, int count,
|
|
const SkRect* bounds = nullptr)
|
|
#In Allocator
|
|
#Line # returns writable glyph and Point buffers ##
|
|
|
|
#Populate
|
|
|
|
#Example
|
|
#Height 90
|
|
SkTextBlobBuilder builder;
|
|
SkPaint paint;
|
|
SkFont font;
|
|
const SkTextBlobBuilder::RunBuffer& run = builder.allocRunPos(font, 5);
|
|
paint.textToGlyphs("hello", 5, run.glyphs);
|
|
SkPoint positions[] = {{0, 0}, {10, 10}, {20, 20}, {40, 40}, {80, 80}};
|
|
memcpy(run.pos, positions, sizeof(positions));
|
|
canvas->drawTextBlob(builder.make(), 20, 20, paint);
|
|
##
|
|
|
|
#SeeAlso allocRunPosH allocRun
|
|
|
|
#Method ##
|
|
|
|
#Class SkTextBlobBuilder ##
|
|
|
|
#Topic Text_Blob_Builder ##
|