class TextGeometry::Line

Represents a single line as a set of words.

Public

Methods

GetWidth

float GetWidth() const

Returns width of the line in pixels.

GetHeight

float GetHeight() const

Returns height of the line in pixels.

GetYOffset

float GetYOffset() const

Returns an offset used to separate two lines.

CalculateWidthWithChararacter

float CalculateWidthWithChararacter(const CharacterInformation &characterInformation) const

Calculates new width of the line if we were to add the provided character, without actually adding it.

characterInformation
Character description from the font.

Returns: Width of the line in pixels with the character appended to it.

FillBuffer

u32 FillBuffer(u32 page, Vector2 *outVertices, Vector2 *outUVs, u32 *outIndices, u32 offset, u32 size) const

Fills the vertex/uv/index buffers for the specified page, with all the character data needed for rendering.

page
The page.
outVertices
Pre-allocated array where character vertices will be written.
outUVs
Pre-allocated array where character uv coordinates will be written.
outIndices
Pre-allocated array where character indices will be written.
offset
Offsets the location at which the method writes to the buffers. Counted as number of quads.
size
Total number of quads that can fit into the specified buffers.

Returns: Number of quads that were written.

IsAtWordBoundary

bool IsAtWordBoundary() const

Checks are we at a word boundary (meaning the next added character will start a new word).

GetCharacterCount

u32 GetCharacterCount() const

Returns the total number of characters on this line.

HasNewlineChar

bool HasNewlineChar() const

Query if this line was created explicitly due to a newline character.

As opposed to a line that was created because a word couldn't fit on the previous line.

Private

Methods

Add

void Add(u32 characterIndex, const CharacterInformation &characterInformation)

Appends a new character to the line.

characterIndex
Sequential index of the character in the original string.
characterInformation
Character description from the font.

AddSpace

void AddSpace(float spaceWidth)

Appends a space to the line.

AddWord

void AddWord(u32 wordIndex, const Word &word)

Adds a new word to the line.

wordIndex
Sequential index of the word in the original string. Spaces are counted as words as well.
word
Description of the word.

Initialize

void Initialize(TextGeometry *textData)

Initializes the line.

Must be called after construction.

Finalize

void Finalize(bool hasNewlineChar)

Finalizes the line.

Do not add new characters/words after a line has been finalized.

hasNewlineChar
Set to true if line was create due to an explicit newline char. As opposed to a line that was created because a word couldn't fit on the previous line.

IsEmpty

bool IsEmpty() const

Returns true if the line contains no words.

RemoveLastWord

u32 RemoveLastWord()

Removes last word from the line and returns its sequential index.

CalculateBounds

void CalculateBounds()

Calculates the line width and height in pixels.

Fields

mTextData

TextGeometry * mTextData

mWordStartIndex

u32 mWordStartIndex

mWordEndIndex

u32 mWordEndIndex

mWidth

float mWidth

mHeight

float mHeight

mIsEmpty

bool mIsEmpty

mHasNewline

bool mHasNewline