TextBlobBuilder
- class TextBlobBuilder
Helper class for constructing
TextBlob
.Methods
Constructs empty
TextBlobBuilder
.Sets a new run with glyphs.
Sets a new run with glyphs and
Point
positions.Sets a new run with glyphs and positions along baseline.
Returns
TextBlob
built from runs of glyphs added by builder.
Methods
- TextBlobBuilder.__init__(self: skia.TextBlobBuilder) None
Constructs empty
TextBlobBuilder
.
- TextBlobBuilder.allocRun(self: skia.TextBlobBuilder, text: str, font: skia.Font, x: float, y: float, bounds: skia.Rect = None, encoding: skia.TextEncoding = skia.TextEncoding.kUTF8) None
Sets a new run with glyphs.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at (x, y), using font metrics to determine their relative placement.
bounds defines an optional bounding box, used to suppress drawing when
TextBlob
bounds does not intersectSurface
bounds. If bounds is nullptr,TextBlob
bounds is computed from (x, y) and RunBuffer::glyphs metrics.- Parameters:
text (str) – text for the run
x (float) – horizontal offset within the blob
y (float) – vertical offset within the blob
bounds (skia.Rect) – optional run bounding box
encoding (skia.TextEncoding) – specifies the encoding of the text array
- TextBlobBuilder.allocRunPos(self: skia.TextBlobBuilder, font: skia.Font, glyphs: list[int], positions: Iterable, bounds: skia.Rect = None) None
Sets a new run with glyphs and
Point
positions.Glyphs share metrics in font.
Glyphs are positioned using
Point
, using two scalar values for eachPoint
.bounds defines an optional bounding box, used to suppress drawing when
TextBlob
bounds does not intersectSurface
bounds. If bounds is nullptr,TextBlob
bounds is computed from RunBuffer::pos and RunBuffer::glyphs metrics.- Parameters:
glyphs (List[int]) – array of glyph IDs
positions (List[skia.Point]) – offsets within the blob
bounds (skia.Rect) – optional run bounding box
- TextBlobBuilder.allocRunPosH(self: skia.TextBlobBuilder, font: skia.Font, glyphs: list[int], xpos: Iterable, y: float, bounds: skia.Rect = None) None
Sets a new run with glyphs and positions along baseline.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at y, using x-axis positions.
bounds defines an optional bounding box, used to suppress drawing when
TextBlob
bounds does not intersectSurface
bounds. If bounds is nullptr,TextBlob
bounds is computed from y, RunBuffer::pos, and RunBuffer::glyphs metrics.
- TextBlobBuilder.allocRunRSXform(self: skia.TextBlobBuilder, font: skia.Font, glyphs: list[int], xforms: list[skia.RSXform]) None
- TextBlobBuilder.make(self: skia.TextBlobBuilder) skia.TextBlob
Returns
TextBlob
built from runs of glyphs added by builder.Returned
TextBlob
is immutable; it may be copied, but its contents may not be altered. Returns nullptr if no runs of glyphs were added by builder.Resets
TextBlobBuilder
to its initial empty state, allowing it to be reused to build a new set of runs.- Returns:
TextBlob
or nullptr