# XNA 4.0 - Using premade .xnb font files

Basically, for our college project, we need to use a font in xna. The only problem is that we are not allowed to install it due to admin rights.

Is it possible to use and load the .xnb file that gets created as the font. Using spritefont gives errors as it searches for the font in windows.

(The .xnb file will be created on someones personal machine beforehand.)

• Yes you can do that. The .spritefont gives error because its not compiled to .xnb. You could also use a spritesheet with a font, here is how I do it: code image. I made that spritesheet using BMFC tool – dimitris93 Apr 27 '15 at 16:49
• First you need to Call Font.Initialize() in your Initialize and Font.Texture = Content.Load<Texture2D>("FontSprite"); in your LoadContent method. Then you can call Font.DrawString(spriteBatch, "my text", 1.15f, new Vector2(100, 200), Color.Snow); in your Draw method. – dimitris93 Apr 27 '15 at 17:08
• This tool XNA Formatter can also compile .spritefont to .xnb but it seems like it requires XNA 4.0 installed, so that you have the content pipeline dependencies set. – dimitris93 Apr 27 '15 at 17:38
• I have the .xnb file. Is there no way of using it easily like I use a spritefont, or do I need to write a new class handling the font? – Tom Cork Apr 27 '15 at 18:23
• .xnb is a compiled file, so no, of course you can't edit it. What would the purpose of it be then. What I showed you has nothing to do with .spritefont or .xnb. It is how you could use an image as a font. – dimitris93 Apr 27 '15 at 20:45