ronnie
2022-10-23 68f5ca84d926736535296469a2d3fcbea06ca8a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#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 ##