Skia
2D Graphics Library
SkTextBlobBuilder Class Reference

Helper class for constructing SkTextBlob. More...

#include <SkTextBlob.h>

Classes

struct  RunBuffer
 RunBuffer supplies storage for glyphs and positions within a run. More...
 

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)
 
const RunBufferallocRunText (const SkFont &font, int count, SkScalar x, SkScalar y, int textByteCount, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs, text, and clusters. More...
 
const RunBufferallocRunTextPosH (const SkFont &font, int count, SkScalar y, int textByteCount, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs, positions along baseline, text, and clusters. More...
 
const RunBufferallocRunTextPos (const SkFont &font, int count, int textByteCount, const SkRect *bounds=nullptr)
 Returns run with storage for glyphs, SkPoint positions, text, and clusters. More...
 
const RunBufferallocRunTextRSXform (const SkFont &font, int count, int textByteCount, const SkRect *bounds=nullptr)
 

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::pos, 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 
)

◆ allocRunText()

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

Returns run with storage for glyphs, text, and clusters.

Caller must write count glyphs to RunBuffer::glyphs, textByteCount UTF-8 code units into RunBuffer::utf8text, and count monotonic indexes into utf8text into RunBuffer::clusters before next call to SkTextBlobBuilder.

RunBuffer::pos 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
textByteCountnumber of UTF-8 code units
boundsoptional run bounding box
Returns
writable glyph buffer, text buffer, and cluster buffer

◆ allocRunTextPos()

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

Returns run with storage for glyphs, SkPoint positions, text, and clusters.

Caller must write count glyphs to RunBuffer::glyphs, count SkPoint to RunBuffer::pos, textByteCount UTF-8 code units into RunBuffer::utf8text, and count monotonic indexes into utf8text into RunBuffer::clusters before next call to SkTextBlobBuilder.

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
textByteCountnumber of UTF-8 code units
boundsoptional run bounding box
Returns
writable glyph buffer, SkPoint buffer, text buffer, and cluster buffer

◆ allocRunTextPosH()

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

Returns run with storage for glyphs, positions along baseline, text, and clusters.

Caller must write count glyphs to RunBuffer::glyphs, count scalars to RunBuffer::pos, textByteCount UTF-8 code units into RunBuffer::utf8text, and count monotonic indexes into utf8text into RunBuffer::clusters before next call to SkTextBlobBuilder.

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
textByteCountnumber of UTF-8 code units
boundsoptional run bounding box
Returns
writable glyph buffer, x-axis position buffer, text buffer, and cluster buffer

◆ allocRunTextRSXform()

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

◆ 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: