Skia
2D Graphics Library
SkTextBlob Class Referencefinal

#include <SkTextBlob.h>

Inheritance diagram for SkTextBlob:

Classes

class  Iter
 

Public Member Functions

const SkRectbounds () const
 Returns conservative bounding box. More...
 
uint32_t uniqueID () const
 Returns a non-zero value unique among all text blobs. More...
 
int getIntercepts (const SkScalar bounds[2], SkScalar intervals[], const SkPaint *paint=nullptr) const
 Returns the number of intervals that intersect bounds. More...
 
size_t serialize (const SkSerialProcs &procs, void *memory, size_t memory_size) const
 Writes data to allow later reconstruction of SkTextBlob. More...
 
sk_sp< SkDataserialize (const SkSerialProcs &procs) const
 Returns storage containing SkData describing SkTextBlob, using optional custom encoders. More...
 
bool unique () const
 
void ref () const
 
void unref () const
 
void deref () const
 
bool refCntGreaterThan (int32_t threadIsolatedTestCnt) const
 

Static Public Member Functions

static sk_sp< SkTextBlobMakeFromText (const void *text, size_t byteLength, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
 Creates SkTextBlob with a single run. More...
 
static sk_sp< SkTextBlobMakeFromString (const char *string, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
 Creates SkTextBlob with a single run. More...
 
static sk_sp< SkTextBlobMakeFromPosTextH (const void *text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
 Returns a textblob built from a single run of text with x-positions and a single y value. More...
 
static sk_sp< SkTextBlobMakeFromPosText (const void *text, size_t byteLength, const SkPoint pos[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
 Returns a textblob built from a single run of text with positions. More...
 
static sk_sp< SkTextBlobMakeFromRSXform (const void *text, size_t byteLength, const SkRSXform xform[], const SkFont &font, SkTextEncoding encoding=SkTextEncoding::kUTF8)
 
static sk_sp< SkTextBlobDeserialize (const void *data, size_t size, const SkDeserialProcs &procs)
 Recreates SkTextBlob that was serialized into data. More...
 

Friends

class SkNVRefCnt< SkTextBlob >
 
class SkGlyphRunList
 
class GrTextBlobCache
 
class SkTextBlobBuilder
 
class SkTextBlobPriv
 
class SkTextBlobRunIterator
 

Detailed Description

SkTextBlob combines multiple text runs into an immutable container. Each text run consists of glyphs, SkPaint, and position. Only parts of SkPaint related to fonts and text rendering are used by run.

Member Function Documentation

◆ bounds()

const SkRect& SkTextBlob::bounds ( ) const
inline

Returns conservative bounding box.

Uses SkPaint associated with each glyph to determine glyph bounds, and unions all bounds. Returned bounds may be larger than the bounds of all glyphs in runs.

Returns
conservative bounding box

◆ deref()

void SkNVRefCnt< SkTextBlob >::deref
inlineinherited

◆ Deserialize()

static sk_sp<SkTextBlob> SkTextBlob::Deserialize ( const void *  data,
size_t  size,
const SkDeserialProcs procs 
)
static

Recreates SkTextBlob that was serialized into data.

Returns constructed SkTextBlob if successful; otherwise, returns nullptr. Fails if size is smaller than required data length, or if data does not permit constructing valid SkTextBlob.

procs.fTypefaceProc permits supplying a custom function to decode SkTypeface. If procs.fTypefaceProc is nullptr, default decoding is used. procs.fTypefaceCtx may be used to provide user context to procs.fTypefaceProc; procs.fTypefaceProc is called with a pointer to SkTypeface data, data byte length, and user context.

Parameters
datapointer for serial data
sizesize of data
procscustom serial data decoders; may be nullptr
Returns
SkTextBlob constructed from data in memory

◆ getIntercepts()

int SkTextBlob::getIntercepts ( const SkScalar  bounds[2],
SkScalar  intervals[],
const SkPaint paint = nullptr 
) const

Returns the number of intervals that intersect bounds.

bounds describes a pair of lines parallel to the text advance. The return count is zero or a multiple of two, and is at most twice the number of glyphs in the the blob.

Pass nullptr for intervals to determine the size of the interval array.

Runs within the blob that contain SkRSXform are ignored when computing intercepts.

Parameters
boundslower and upper line parallel to the advance
intervalsreturned intersections; may be nullptr
paintspecifies stroking, SkPathEffect that affects the result; may be nullptr
Returns
number of intersections; may be zero

◆ MakeFromPosText()

static sk_sp<SkTextBlob> SkTextBlob::MakeFromPosText ( const void *  text,
size_t  byteLength,
const SkPoint  pos[],
const SkFont font,
SkTextEncoding  encoding = SkTextEncoding::kUTF8 
)
static

Returns a textblob built from a single run of text with positions.

This is equivalent to using SkTextBlobBuilder and calling allocRunPos(). Returns nullptr if byteLength is zero.

Parameters
textcharacter code points or glyphs drawn (based on encoding)
byteLengthbyte length of text array
posarray of positions, must contain values for all of the character points.
fontSkFont used for this run
encodingspecifies the encoding of the text array.
Returns
new textblob or nullptr

◆ MakeFromPosTextH()

static sk_sp<SkTextBlob> SkTextBlob::MakeFromPosTextH ( const void *  text,
size_t  byteLength,
const SkScalar  xpos[],
SkScalar  constY,
const SkFont font,
SkTextEncoding  encoding = SkTextEncoding::kUTF8 
)
static

Returns a textblob built from a single run of text with x-positions and a single y value.

This is equivalent to using SkTextBlobBuilder and calling allocRunPosH(). Returns nullptr if byteLength is zero.

Parameters
textcharacter code points or glyphs drawn (based on encoding)
byteLengthbyte length of text array
xposarray of x-positions, must contain values for all of the character points.
constYshared y-position for each character point, to be paired with each xpos.
fontSkFont used for this run
encodingspecifies the encoding of the text array.
Returns
new textblob or nullptr

◆ MakeFromRSXform()

static sk_sp<SkTextBlob> SkTextBlob::MakeFromRSXform ( const void *  text,
size_t  byteLength,
const SkRSXform  xform[],
const SkFont font,
SkTextEncoding  encoding = SkTextEncoding::kUTF8 
)
static

◆ MakeFromString()

static sk_sp<SkTextBlob> SkTextBlob::MakeFromString ( const char *  string,
const SkFont font,
SkTextEncoding  encoding = SkTextEncoding::kUTF8 
)
inlinestatic

Creates SkTextBlob with a single run.

string meaning depends on SkTextEncoding; by default, string is encoded as UTF-8.

font contains attributes used to define the run text.

When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or SkTextEncoding::kUTF32, this function uses the default character-to-glyph mapping from the SkTypeface in font. It does not perform typeface fallback for characters not found in the SkTypeface. It does not perform kerning or other complex shaping; glyphs are positioned based on their default advances.

Parameters
stringcharacter code points or glyphs drawn
fonttext size, typeface, text scale, and so on, used to draw
encodingtext encoding used in the text array
Returns
SkTextBlob constructed from one run

◆ MakeFromText()

static sk_sp<SkTextBlob> SkTextBlob::MakeFromText ( const void *  text,
size_t  byteLength,
const SkFont font,
SkTextEncoding  encoding = SkTextEncoding::kUTF8 
)
static

Creates SkTextBlob with a single run.

font contains attributes used to define the run text.

When encoding is SkTextEncoding::kUTF8, SkTextEncoding::kUTF16, or SkTextEncoding::kUTF32, this function uses the default character-to-glyph mapping from the SkTypeface in font. It does not perform typeface fallback for characters not found in the SkTypeface. It does not perform kerning or other complex shaping; glyphs are positioned based on their default advances.

Parameters
textcharacter code points or glyphs drawn
byteLengthbyte length of text array
fonttext size, typeface, text scale, and so on, used to draw
encodingtext encoding used in the text array
Returns
SkTextBlob constructed from one run

◆ ref()

void SkNVRefCnt< SkTextBlob >::ref
inlineinherited

◆ refCntGreaterThan()

bool SkNVRefCnt< SkTextBlob >::refCntGreaterThan ( int32_t  threadIsolatedTestCnt) const
inlineinherited

◆ serialize() [1/2]

sk_sp<SkData> SkTextBlob::serialize ( const SkSerialProcs procs) const

Returns storage containing SkData describing SkTextBlob, using optional custom encoders.

procs.fTypefaceProc permits supplying a custom function to encode SkTypeface. If procs.fTypefaceProc is nullptr, default encoding is used. procs.fTypefaceCtx may be used to provide user context to procs.fTypefaceProc; procs.fTypefaceProc is called with a pointer to SkTypeface and user context.

Parameters
procscustom serial data encoders; may be nullptr
Returns
storage containing serialized SkTextBlob

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

◆ serialize() [2/2]

size_t SkTextBlob::serialize ( const SkSerialProcs procs,
void *  memory,
size_t  memory_size 
) const

Writes data to allow later reconstruction of SkTextBlob.

memory points to storage to receive the encoded data, and memory_size describes the size of storage. Returns bytes used if provided storage is large enough to hold all data; otherwise, returns zero.

procs.fTypefaceProc permits supplying a custom function to encode SkTypeface. If procs.fTypefaceProc is nullptr, default encoding is used. procs.fTypefaceCtx may be used to provide user context to procs.fTypefaceProc; procs.fTypefaceProc is called with a pointer to SkTypeface and user context.

Parameters
procscustom serial data encoders; may be nullptr
memorystorage for data
memory_sizesize of storage
Returns
bytes written, or zero if required storage is larger than memory_size

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

◆ unique()

bool SkNVRefCnt< SkTextBlob >::unique
inlineinherited

◆ uniqueID()

uint32_t SkTextBlob::uniqueID ( ) const
inline

Returns a non-zero value unique among all text blobs.

Returns
identifier for SkTextBlob

◆ unref()

void SkNVRefCnt< SkTextBlob >::unref
inlineinherited

Friends And Related Function Documentation

◆ GrTextBlobCache

friend class GrTextBlobCache
friend

◆ SkGlyphRunList

friend class SkGlyphRunList
friend

◆ SkNVRefCnt< SkTextBlob >

friend class SkNVRefCnt< SkTextBlob >
friend

◆ SkTextBlobBuilder

friend class SkTextBlobBuilder
friend

◆ SkTextBlobPriv

friend class SkTextBlobPriv
friend

◆ SkTextBlobRunIterator

friend class SkTextBlobRunIterator
friend

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