I'm developing a game in XNA, however, I do not want to use a content project. I'm loading all my textures through different means, and I'd also like to load my fonts without a content project.

Is there any quick way to maybe include the SpriteFont in the main game project?

  • \$\begingroup\$ I'm pretty sure there isnt a quick way to load a font as a sprite font. As todo that a font is baked into a texture. Maybe head over to MonoGame and check their source code to see if they have something for text rendering. Why are you not using the content project btw? Its a good way to pack and manage textures. \$\endgroup\$
    – Roy T.
    Mar 16 '13 at 13:59
  • \$\begingroup\$ A content project isn't ideal for my needs, because all the textures I use are concentrated in two different very large spritesheets. I want to be able to change these files out very easily, and I want to use my own code to load and process them. \$\endgroup\$ Mar 21 '13 at 12:18
  • 1
    \$\begingroup\$ That is what custom content importers and processors are for :) \$\endgroup\$
    – Roy T.
    Mar 21 '13 at 15:06

XNA is designed around the content processor pipeline and SpriteFont resources are designed to make use of that. There are really no good ways to circumvent that.

You could create a separate project that used a content project to generate and load the sprite font, and then use reflection to access the SpriteFont object's private members, including textureValue (which is a Texture2D) and spit them out to some format you can parse yourself. But that is really a bit heavy-handed, and at that point not much different than using a third-party, API-agnostic bitmap font generation tool (like BMFont).

Plus it still uses a content project somewhere in your pipeline. Your best option if you really don't want to make use of XNA's content pipeline is to find third-party tools.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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