2018-08-10 17:09:13 +00:00
|
|
|
#Topic Text_Blob_Builder
|
|
|
|
#Alias Text_Blob_Builder_Reference ##
|
|
|
|
|
|
|
|
#Class SkTextBlobBuilder
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Code
|
2018-08-10 17:09:13 +00:00
|
|
|
#Populate
|
|
|
|
##
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
Helper class for constructing SkTextBlob.
|
2018-08-10 17:09:13 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#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 Paint_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 Paint_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()
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-08-10 17:09:13 +00:00
|
|
|
#Line # constructs with default values ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-08-10 17:09:13 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-30 00:33:51 +00:00
|
|
|
SkTextBlobBuilder builder;
|
|
|
|
sk_sp<SkTextBlob> blob = builder.make();
|
2018-08-10 17:09:13 +00:00
|
|
|
SkDebugf("blob " "%s" " nullptr", blob == nullptr ? "equals" : "does not equal");
|
|
|
|
#StdOut
|
|
|
|
blob equals nullptr
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso make SkTextBlob::MakeFromText
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method ~SkTextBlobBuilder()
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-08-10 17:09:13 +00:00
|
|
|
#Line # deletes storage ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-08-10 17:09:13 +00:00
|
|
|
|
|
|
|
#NoExample
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkTextBlobBuilder()
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method sk_sp<SkTextBlob> make()
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-08-10 17:09:13 +00:00
|
|
|
#Line # constructs Text_Blob from bulider ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-08-10 17:09:13 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-30 00:33:51 +00:00
|
|
|
SkTextBlobBuilder builder;
|
|
|
|
sk_sp<SkTextBlob> blob = builder.make();
|
|
|
|
SkDebugf("blob " "%s" " nullptr\n", blob == nullptr ? "equals" : "does not equal");
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
|
|
|
|
paint.textToGlyphs("x", 1, builder.allocRun(paint, 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
|
|
|
|
##
|
2018-08-10 17:09:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkTextBlob::MakeFromText
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-30 00:33:51 +00:00
|
|
|
#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 ##
|
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
#Populate
|
2018-10-30 00:33:51 +00:00
|
|
|
|
|
|
|
#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 ##
|
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
#Populate
|
2018-10-30 00:33:51 +00:00
|
|
|
|
|
|
|
#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);
|
2018-08-10 17:09:13 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso allocRunPos allocRun
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
#Method const RunBuffer& allocRunPos(const SkFont& font, int count,
|
|
|
|
const SkRect* bounds = nullptr)
|
2018-08-10 17:09:13 +00:00
|
|
|
#In Allocator
|
|
|
|
#Line # returns writable glyph and Point buffers ##
|
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
#Populate
|
2018-08-10 17:09:13 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 90
|
2018-10-30 00:33:51 +00:00
|
|
|
SkTextBlobBuilder builder;
|
2018-11-07 19:59:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkFont font;
|
2018-10-30 00:33:51 +00:00
|
|
|
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));
|
2018-11-07 19:59:03 +00:00
|
|
|
canvas->drawTextBlob(builder.make(), 20, 20, paint);
|
2018-10-30 00:33:51 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso allocRunPosH allocRun
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
2018-08-10 17:09:13 +00:00
|
|
|
#Class SkTextBlobBuilder ##
|
|
|
|
|
|
|
|
#Topic Text_Blob_Builder ##
|