Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just want to render some text to the screen using:

  • monogame 3.0
  • MS Visual Studio 2010 C# Express

In XNA, you were able to add fonts to the content pipeline quite easily. But this doesn't seem to be the case in monogame. Loading TTF Files using Content<SpriteFont>.Load() doesn't work. Is there any way to generate or download *.spritefont files or *.xnb files containing the font data (without resorting to install XNA)?

share|improve this question
I also had a lot of problems figuring this out, this tutorial helped me out a whole lot. – user29722 Apr 19 '13 at 8:11
up vote 4 down vote accepted

An alternative is to use pre-generated bitmap fonts instead. Here's a tutorial I wrote a while back on using the BMFont tool to get text into your game using the MonoGame.Extended library.

share|improve this answer
Although I'm not 100% satisfied with this solution, I guess I'll go with bitmap fonts for now and hope for the best in the near future. – Khôi Dec 25 '12 at 11:37
More recently I added BitmapFont's to the MonoGame.Extended library – craftworkgames Jul 28 '15 at 12:39
@J2V I updated the answer to point at a working link. It's not exactly the same as the old one but it still answers the question I believe. – craftworkgames Oct 1 '15 at 7:55
@craftworkgames Thanks! I'm going to remove my previous comment. – J2V Oct 1 '15 at 7:59

I ran into the same problem as you. Thankfully, I had an existing XNA project that already used a .spritefont file, and generated the XNB file. I just compiled it, and copied the XNB into my MonoGame project, and I can use it without any problems.

(Disclaimer: I tried building the XNA content pipeline for MonoGame 3.0 beta as per instructions, and after a few hours, I gave up; it wouldn't include the project properly in Visual Studio.)

share|improve this answer
Thanks for tip. Good to know that you can work around it like this. – Khôi Dec 25 '12 at 11:33
@Khôi it's not perfect, but it can at least get you somewhere while you figure out how to integrate the content pipeline project. – ashes999 Dec 25 '12 at 15:11

At least in August this year generating spritefonts was not yet supported by MonoGame, however the content pipeline was the main focus of attention the last few months so I wouldn't be surprised if it does work currently. Of course you need to know the syntax of a .spritefont file which needs to be added to your content folder. For that see the bottom of this post.

As far as I can tell, even as far back as August, the loading of already compiled spritefonts from XNB files is supported. Since you don't want to install XNA to generate these XNB files you might want to check the XNA Content Compiler Project on codeplex.

Here is an example .spritefont file so you can see if it's currently supported

<?xml version="1.0" encoding="utf-8"?>
This file contains an xml description of a font, and will be read by the XNA
Framework Content Pipeline. Follow the comments to customize the appearance
of the font in your game, and to change the characters which are available to draw
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
  <Asset Type="Graphics:FontDescription">

    Modify this string to change the font that will be imported.

    Size is a float value, measured in points. Modify this value to change
    the size of the font.

    Spacing is a float value, measured in pixels. Modify this value to change
    the amount of spacing in between characters.

    UseKerning controls the layout of the font. If this value is true, kerning information
    will be used when placing characters.

    Style controls the style of the font. Valid entries are "Regular", "Bold", "Italic",
    and "Bold, Italic", and are case sensitive.

    If you uncomment this line, the default character will be substituted if you draw
    or measure text that contains characters which were not included in the font.
    <!-- <DefaultCharacter>*</DefaultCharacter> -->

    CharacterRegions control what letters are available in the font. Every
    character from Start to End will be built and made available for drawing. The
    default range is from 32, (ASCII space), to 126, ('~'), covering the basic Latin
    character set. The characters are ordered according to the Unicode standard.
    See the documentation for more information.
share|improve this answer
As of now (25.12.2012 - merry xmas!), spritefonts are not supported by monogame 3.0 yet. I just tried it out according to your instructions. – Khôi Dec 25 '12 at 11:27
The XNA Content Compiler won't run for me either. Since it seems you need to have XNA installed to run the content compiler. The XNA Content Compiler builds a dummy project using XNA in the background to compile .xnb files. – Khôi Dec 25 '12 at 11:31
@Khôi Merry Christmas to you too :). Strange that the project requires XNA installed, makes it quite useless for most scenarios! – Roy T. Dec 25 '12 at 11:50
It's not strange, nor useless. MonoGame needs its own content pipline to support other platforms, like Android. This is a temporary xrutch--piggyback off the XNA content pipeline. – ashes999 Dec 25 '12 at 15:12

Check this out guys, I've been compiling my *.spritefont files to .xnb for use in MonoGame, for me, it's the only way it worked.

Check it out, might help you too.

share|improve this answer

The best alternative is to pre-generate the font xnb via XNA first then just use them in your Monogame for Windows project or you can do the old trick of getting the Window.Handle and the screen coordinates ScreenToClient then use the GDI to draw your text with the System.Drawing.dll.

share|improve this answer

You can now do this without installing anything extra. In a brand new MonoGame project you should have a Content.mgcb file. That should bring up the MonoGame Pipeline app. You can right click on the Content node in the tree and add a new item. Select `SpriteFont Description'. That will get compiled correctly and you should be able to load it in your code.

share|improve this answer
Thank you! I've been looking for hours and even tried installing VS2010 & XNA on WIndows 10 (disaster!). For anyone else finding this, the next step would be to open the .spritefont file (you just created) in a text editor and modify it from the default 'arial' to the font you want. – VenerableAgents Jan 14 at 22:42
I don't understand why more tutorials don't give you these steps! I didn't find any after looking all day. It's such an easy thing to overlook that the Pipeline does for you. – VenerableAgents Jan 14 at 22:43

I have been working on this for several days now, trying to fix this and eventually i got i to work. What i am working on is Windows8, VS2012, MonoGame. i should add that this is as "monoGame Windows OpenGL Pjoject"

Let me take you through the steps i have taken. 1. I installed monGame for VS2012 2. I installed WindowsPhone SDK8 3. I installed XNA 4.0 for my VS2010

I dont know if all these steps are nessecery....

Sence you cant generate a .spritefont in vs2012 I generated a spriteFont file in my vs2010 and then added i to my vs2012 project....BUT it did not work. And this morning I saw that the URL for that .spritefont file was wrong. When i added it through solution explorer..content-->add exsisting item...then the url was wrong.. "C:\Users\admin\Documents\Visual Studio 2012\Projects\MyGame\MyGame\Content" this is not where vs2012 where looking for my *.spritefot file it was here..--> "C:\Users\admin\Documents\Visual Studio 2012\Projects\MyGame\MyGame\bin\WindowsGL\Debug\Content" I added i manully, and WOW it worked. i paste some code here so you better can see what i have done.. inside my game class i put these variables

    SpriteFont myFont;
    int score;

in my loadcontent method autogenerated by VS was

    myFont = Content.Load<SpriteFont>("test");

in my draw method autogenerated by VS was

     spriteBatch.DrawString(myFont, "Score: " +score, new Vector2(20,10),Color.Red);

and then manully added my spritefont file in the right folder

The strange thing is that i have added pictures with this way and the have ended up in the right folder but not the *.spritefont, you have to manully add it in the later folder to get i to work..

I hope some of this makes sense to someone because this has given me the biggest headache these last days. I may have forgotten some steps and all this may be useless, but I hope that I may ease the headaches for some out there

And i hope that monoGame will be updated to fix these issues...

share|improve this answer

I've used XNB Builder to manually convert them into .xnb files. Simply run the app, choose your files and it will convert them into XNB files that are ready to use with MonoGame.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.