3.4 Font and Size

Drawing text is all well and good, but the default text probably isn’t gonna do much for your game design. To customize this, you will need to provide your desired font. A new font can be added by right-clicking in the file-tree and choosing ‘New Font’. A dialog will open to change the font’s settings.

Next you create a new textStyle. With a textStyle, you can define a color and alignment for a particular font. (In the ‘font’ drop down menu, the active font can be set.) Even with one font, you can create as many textStyles as you like.

Now if you’d like to use your newly created textStyle to display text in your application, you can use an alternate version of D.text() :

 
D.text(*TextStyles(=== drop style here ===), Vec2(0, 0), ”text”);  

Just drag your textStyle over to the code editor and drop it as an argument of TextStyles(). Remember there’s an asterisk right before this function. We’ll discuss it later, but for now just remember it has to be there.

Exercise
Experiment with different options to shape a font and text style. Draw at least four different texts on the screen, each one with their own style.