class TextGeometry::Word

Represents a single word as a set of characters, or optionally just a blank space of a certain length.

Public

Methods

Initialize

void Initialize(bool isSpacer)

Initializes the word and signals if it just a space (or multiple spaces), or an actual word with letters.

AddCharacter

float AddCharacter(u32 characterIndex, const CharacterInformation &characterInformation)

Appends a new character to the word.

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

Returns: How many pixels did the added character expand the word by.

AddSpace

void AddSpace(float spaceWidth)

Adds a space to the word.

Word must have previously have been declared as a "spacer".

GetWidth

float GetWidth() const

Returns the width of the word in pixels.

GetHeight

float GetHeight() const

Returns height of the word in pixels.

CalculateWidthWithCharacter

float CalculateWidthWithCharacter(const CharacterInformation &characterInformation) const

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

characterInformation
Character description from the font.

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

IsSpacer

bool IsSpacer() const

Returns true if word is a spacer.

Spacers contain just a space of a certain length with no actual characters.

GetCharacterCount

u32 GetCharacterCount() const

Returns the number of characters in the word.

GetStartCharacterIndex

u32 GetStartCharacterIndex() const

Returns the index of the starting character in the word.

GetEndCharacterIndex

u32 GetEndCharacterIndex() const

Returns the index of the last character in the word.

staticCalculateCharacterWidth

static float CalculateCharacterWidth(const CharacterInformation *previousCharacter, const CharacterInformation &currentCharacter)

Calculates width of the character by which it would expand the width of the word if it was added to it.

previousCharacter
Descriptor of the character preceding the one we need the width for. Can be null.
currentCharacter
Character description from the font.

Returns: How many pixels would the added character expand the word by.

Private

Fields

mCharacterStartIndex

u32 mCharacterStartIndex

mCharacterEndIndex

u32 mCharacterEndIndex

mWidth

float mWidth

mHeight

float mHeight

mLastCharacter

const CharacterInformation * mLastCharacter

mIsSpacer

bool mIsSpacer

mSpaceWidth

float mSpaceWidth