Kevin Holditch
Kevin Holditch

Reputation: 5303

Cannot load a font on iOS using MonoGame 3

I am trying to load a font into my game for iPhone. I am using C# and MonoTouch and the excellent MonoGame project (I have got the latest build from the develop3d branch on github).

My fonts load correctly on Windows but when I try to run the game on iPhone I get an error saying could not load font. I have loaded the sprite font into a MonoGame content project and compiled for iOS.

I have imported the produced xnb file in as content, set it to content mode in properties and marked it as copy if newer. However it still won't load. After a lot of digging I found that iOS does not support DXT compressed fonts which is apparently what a SpriteFont is.

I have no idea as to how to go about loading the font into my game. Can someone please help with some code as to how to do it?

Upvotes: 2

Views: 812

Answers (1)

Kevin Holditch
Kevin Holditch

Reputation: 5303

I have just figured it out. For those who are struggling with the same thing follow these steps:

  • Create a new solution choose the mono game content for all platforms (which is basically a dummy game for building content)
  • Add a new mono game content builder project
  • Set the build type to the type you want e.g. iOS
  • Add the content you want
  • In the property window for each content file change the content processor, to the mono game version of the content you are building. e.g. for a texture choose "MonoGame - texture"
  • Build the solution which will build the content into a folder for the platform you have built for in the release directory
  • Add the content into your game project from the built folder of the content project. Make sure you set the build action to content and the copy to output directory to copy if newer (or copy always doesnt really matter)
  • Use the content using the normal content loader in xna

Upvotes: 2

Related Questions