Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm planning on my game using multiple backgrounds so I'm trying to use spritefonts to draw the text. Every time I load my spritefont I get a error.

Line1 = content.Load<SpriteFont>("Courier New");
Line2 = content.Load<SpriteFont>("Courier New");

This is the error I get.

Error loading "Courier New". File not found.

Although this was the font listed on the official microsoft website http://msdn.microsoft.com/en-us/library/bb447673.aspx.

share|improve this question
1  
Have you actually imported the font into your project through visual studio? –  ssb Nov 10 '12 at 13:15
    
try this , its a msdn tutorial to load and using the spritefont . pls check this too if u r begineer msdn.microsoft.com/en-us/library/bb447673.aspx –  Eldho May 29 '13 at 14:27
add comment

2 Answers

You have to add new a new SpriteFont item to your content project. Inside the .spritefont file, there is FontName element. Replace the default value with Courier New.

Take note of the asset name of the .spritefont file you added. Because that is the name you should reference inside your game. Assuming you named the asset as courier, you could load the font like this

SpriteFont Line1 = content.Load<SpriteFont>("courier");
share|improve this answer
add comment

You can only load content that's in your Content project. Since there isn't any file with the name "Courier New" (.ttf, or whatever) in your Content project, it's natural you'd get a File not found error.

You can't just load system fonts. The example in the official Microsoft website just needed an example font name. For their situation to work, they'd need a "Courier New.ttf" (or something) in the corresponding Content project.

share|improve this answer
add comment

Your Answer

 
discard

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.