class TextGeometry

This object takes as input a string, a font and optionally some constraints (like word wrap) and outputs a set of character data you may use for rendering or calculating dimensions.

Public

Constructors

TextGeometry

TextGeometry(const U32String &text, const HFont &font, float fontSize, u32 width = 0, u32 height = 0, bool wordWrap = false, bool wordBreak = true)

Initializes a new text geometry object using the specified string and font.

Text will attempt to fit into the provided area. If enabled it will wrap words to new line when they don't fit. Individual words will be broken into multiple pieces if they don't fit on a single line when word break is enabled, otherwise they will be clipped. If the specified area is zero size then the text will not be clipped or word wrapped in any way.

After this object is constructed you may call various getter methods to get needed information.

Methods

~TextGeometry

virtual ~TextGeometry() = default

GetLineCount

u32 GetLineCount() const

Returns the number of lines that were generated.

GetPageCount

u32 GetPageCount() const

Returns the number of font pages references by the used characters.

GetLineHeight

float GetLineHeight() const

Returns the height of a line in pixels.

GetLine

const Line &GetLine(u32 idx) const

Gets information describing a single line at the specified index.

GetTextureForPage

const HTexture &GetTextureForPage(u32 page) const

Returns font texture for the provided page index.

GetQuadCount

u32 GetQuadCount(u32 page) const

Returns the number of quads used by all the characters in the provided page.

GetWidth

float GetWidth() const

Returns the width of the actual text in pixels.

GetHeight

float GetHeight() const

Returns the height of the actual text in pixels.

Protected

Methods

GeneratePersistentData

void GeneratePersistentData(const U32String &text, u8 *buffer, u32 &size, bool freeTemporary = true)

Copies internally stored data in temporary buffers to a persistent buffer.

text
Text originally used for creating the internal temporary buffer data.
buffer
Memory location to copy the data to. If null then no data will be copied and the parameter will contain the required buffer size.
size
Size of the provided memory buffer, or if the buffer is null, this will contain the required buffer size after method exists.
freeTemporary
If true the internal temporary data will be freed after copying.

staticEnsurePerThreadTemporaryBufferIsInitialized

static void EnsurePerThreadTemporaryBufferIsInitialized()

Allocates an initial set of buffers that will be reused while parsing text data.

Fields

mCharacters

const CharacterInformation ** mCharacters

mCharacterCount

u32 mCharacterCount

mWords

Word * mWords

mWordCount

u32 mWordCount

mLines

Line * mLines

mLineCount

u32 mLineCount

mPageInfos

PageInfo * mPageInfos

mPageCount

u32 mPageCount

mFont

HFont mFont

mFontBitmapInformation

SPtr<const FontBitmapInformation> mFontBitmapInformation

Private

Methods

GetBaselineOffset

float GetBaselineOffset() const

Returns Y offset that determines the line on which the characters are placed.

In pixels.

GetSpaceWidth

float GetSpaceWidth() const

Returns the width of a single space in pixels.

GetCharacter

const CharacterInformation &GetCharacter(u32 index) const

Gets a description of a single character referenced by its sequential index based on the original string.

GetWord

const Word &GetWord(u32 index) const

Gets a description of a single word referenced by its sequential index based on the original string.