Text is one of the most overlooked features of a game, but it is sometimes essential to the gaming experience—for example, using the correct font and size, displaying the appropriate amount of information, and so on. Yes, there are games where text is not used at all, but those are quite rare. If you make a game, you'll need to render text at some point during the development process (even for debugging data). In this section, we will talk about text and fonts.
Remember the Sprite
—Texture
and Sound
—SoundBuffer
relation? Take a guess which other part of SFML uses the same model. Yes, you're right—the sf::Font
and
sf::Text
classes. In this case, the Font
class is the resource which we want to keep safe while the Text
class uses it. You should probably be able to picture the process of loading fonts and creating texts based on the fact that this is the third time that we've come across it. If you can't—don't worry, this is what this book is for. Let's start by...