Skia
2D Graphics Library
SkTextBlobBuilder Class Reference

#include <SkTextBlob.h>

Classes

struct  RunBuffer
 

Public Member Functions

 SkTextBlobBuilder ()
 Constructs empty SkTextBlobBuilder. More...
 
 ~SkTextBlobBuilder ()
 Deletes data allocated internally by SkTextBlobBuilder. More...
 
sk_sp< SkTextBlobmake ()
 Returns SkTextBlob built from runs of glyphs added by builder. More...
 
const RunBufferallocRun (const SkFont &font, int count, SkScalar x, SkScalar y, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs. More...
 
const RunBufferallocRunPosH (const SkFont &font, int count, SkScalar y, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs and positions along baseline. More...
 
const RunBufferallocRunPos (const SkFont &font, int count, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs and SkPoint positions. More...
 
const RunBufferallocRunRSXform (const SkFont &font, int count)
 

Friends

class SkTextBlobPriv
 
class SkTextBlobBuilderPriv
 

Detailed Description

Helper class for constructing SkTextBlob.

Constructor & Destructor Documentation

◆ SkTextBlobBuilder()

SkTextBlobBuilder::SkTextBlobBuilder ( )

◆ ~SkTextBlobBuilder()

SkTextBlobBuilder::~SkTextBlobBuilder ( )

Deletes data allocated internally by SkTextBlobBuilder.

Member Function Documentation

◆ allocRun()

const RunBuffer& SkTextBlobBuilder::allocRun ( const SkFont font,
int  count,
SkScalar  x,
SkScalar  y,
const SkRect bounds = nullptr 
)

Returns run with storage for glyphs.

Caller must write count glyphs to RunBuffer::glyphs before next call to SkTextBlobBuilder.

RunBuffer::utf8text, and RunBuffer::clusters should be ignored.

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 SkTextBlob bounds does not intersect SkSurface bounds. If bounds is nullptr, SkTextBlob bounds is computed from (x, y) and RunBuffer::glyphs metrics.

Parameters
fontSkFont used for this run
countnumber of glyphs
xhorizontal offset within the blob
yvertical offset within the blob
boundsoptional run bounding box
Returns
writable glyph buffer

◆ allocRunPos()

const RunBuffer& SkTextBlobBuilder::allocRunPos ( const SkFont font,
int  count,
const SkRect bounds = nullptr 
)

Returns run with storage for glyphs and SkPoint positions.

Caller must write count glyphs to RunBuffer::glyphs, and count SkPoint to RunBuffer::pos; before next call to SkTextBlobBuilder.

RunBuffer::utf8text, and RunBuffer::clusters should be ignored.

Glyphs share metrics in font.

Glyphs are positioned using SkPoint written by caller to RunBuffer::pos, using two scalar values for each SkPoint.

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

Parameters
fontSkFont used for this run
countnumber of glyphs
boundsoptional run bounding box
Returns
writable glyph buffer and SkPoint buffer

◆ allocRunPosH()

const RunBuffer& SkTextBlobBuilder::allocRunPosH ( const SkFont font,
int  count,
SkScalar  y,
const SkRect bounds = nullptr 
)

Returns run with storage for glyphs and positions along baseline.

Caller must write count glyphs to RunBuffer::glyphs, and count scalars to RunBuffer::pos; before next call to SkTextBlobBuilder.

RunBuffer::utf8text, and RunBuffer::clusters should be ignored.

Glyphs share metrics in font.

Glyphs are positioned on a baseline at y, using x-axis positions written by caller to RunBuffer::pos.

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

Parameters
fontSkFont used for this run
countnumber of glyphs
yvertical offset within the blob
boundsoptional run bounding box
Returns
writable glyph buffer and x-axis position buffer

◆ allocRunRSXform()

const RunBuffer& SkTextBlobBuilder::allocRunRSXform ( const SkFont font,
int  count 
)

◆ make()

sk_sp<SkTextBlob> SkTextBlobBuilder::make ( )

Returns SkTextBlob built from runs of glyphs added by builder.

Returned SkTextBlob 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 SkTextBlobBuilder to its initial empty state, allowing it to be reused to build a new set of runs.

Returns
SkTextBlob or nullptr

example: https://fiddle.skia.org/c/@TextBlobBuilder_make

Friends And Related Function Documentation

◆ SkTextBlobBuilderPriv

friend class SkTextBlobBuilderPriv
friend

◆ SkTextBlobPriv

friend class SkTextBlobPriv
friend

The documentation for this class was generated from the following file: