Game Development Reference
conversion constructors from std::string and std::wstring . So, passing any of
these arguments works absolutely fine:
The color of the Text object can be set by calling Text::setColor() . Also, we can
set the style of the font— Text::Style::Regular , Text::Style::Bold ,
Text::Style::Italic , and Text::Style::Underlined . This is done with
the Text::setStyle() method. The expected argument is a bitmask of the elements
in the Text::Style enum. For example, this produces bold text, which is underlined:
An interesting feature of the Text class is the ability to get the global position of a specif-
ic character in the text. This is done with Text::findCharacterPos() . It expects
the character's index in the string and returns its position, accounting for translation, rota-
tion, scale, and origin. This is useful in instances where we want to place a graphic on top
of a character, or as an indication of the cursor position in a text input box.
All the properties that can be set to a Text object also have getters with the common sig-
nature, Text::get*() .
Now let's talk about fonts. Since they are a resource which has to be loaded from a file,
they need to be alive as long as a Text object is using them. Fortunately, we have the
AssetManager which does exactly that for all of our resources. It is time for the next
iteration on AssetManager .