TextBlobBuilder

class TextBlobBuilder

Helper class for constructing TextBlob.

Methods

__init__

Constructs empty TextBlobBuilder.

allocRun

Sets a new run with glyphs.

allocRunPos

Sets a new run with glyphs and Point positions.

allocRunPosH

Sets a new run with glyphs and positions along baseline.

allocRunRSXform

make

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 = <TextEncoding.kUTF8: 0>) 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 intersect Surface bounds. If bounds is nullptr, TextBlob bounds is computed from (x, y) and RunBuffer::glyphs metrics.

Parameters:
  • font (skia.Font) – Font used for this run

  • 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 each Point.

bounds defines an optional bounding box, used to suppress drawing when TextBlob bounds does not intersect Surface bounds. If bounds is nullptr, TextBlob bounds is computed from RunBuffer::pos and RunBuffer::glyphs metrics.

Parameters:
  • font (skia.Font) – Font used for this run

  • 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 intersect Surface bounds. If bounds is nullptr, TextBlob bounds is computed from y, RunBuffer::pos, and RunBuffer::glyphs metrics.

Parameters:
  • font (skia.Font) – Font used for this run

  • glyphs (List[int]) – array of glyph IDs

  • xpos (List[float]) – horizontal offsets within the blob

  • y (float) – vertical offset within the blob

  • bounds (skia.Rect) – optional run bounding box

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