This question is probably a duplicate but I'm still asking it since it's all yesterday that I'm trying to get this done without any success. I followed many solutions and tried even more libraries which were either outdated or they simply didn't work. Right now the most reasonable method I found is
- Open the Content Pipeline;
- Create a new Content if there isn't any;
- Right click on Content -> Add -> New item -> SpriteFont Description -> Give it a name;
- Click Build;
- Go to the output directory, grab the XNB file that was created and put it in some folder of the project, under Content;
- Change the properties to Content and Copy if newer;
And I use it like this:
private SpriteFont font;
font = Content.Load<SpriteFont>("NameOfXNBFile");
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, Global.Camera.TranslationMatrix);
spriteBatch.DrawString(font, "Some Text", new Vector2(100, 100), Color.White);
spriteBatch.End();
I don't have any errors, the text is simply not shown. I think I could be close to a solution since one and only one single time the text appeared, but as the fool I am I happily closed the tabs of countless tutorials and made some changes which led the text to never show again.
.spritefont
file into visual studio's code editor and edit the properties there. It's a mere.xml
file and has comments that will guide you on how to change the font and the size of the characters and even their styling. \$\endgroup\$