Time for action – add SpriteFonts to Game1
Right-click on the Fonts folder in the Content project in Solution Explorer, and select Add | New Item.
From the Add New Item dialog, select
SpriteFont
.Name the font as
Pericles36.spritefont
. After adding the font, theSpriteFont
file will open in the editor window.In the
SpriteFont
file, change<Fontname>Segoe UI Mono</Fontname>
to<Fontname>Pericles</Fontname>
.Change
<Size>14</Size>
to<Size>36</Size>
.Add the following declaration to the
Game1
class:Private pericles36Font as SpriteFont
Update the
LoadContent()
method of theGame1
class to load theSpriteFont
, by adding the following:pericles36Font = Content.Load(Of SpriteFont)("Fonts\Pericles36")
What just happened?
Adding a SpriteFont
to your game is very similar to adding a texture image. Since both are managed by the Content Pipeline, working with them is identical from a code standpoint. In fact, SpriteFonts
are really just specialized sprite sheets...