SpriteFonts on iOS

ok so I’ve spent about a day porting to iOS and I’ve got it all up and running on my mac and in the iOS emulator, with one issue… sprite font appears as all black blobs.

I’ve tried to follow this

and build a .xnb of my font in xamarin studio on my mac
but it gets a runtime error now of could not load asset as a non-content file!

i couldnt add the .target line refered to above as it failed to load

but my mac based content file is building the .xnb - just it wont work

can i build a iOS compatible spritefont on windows in visual studio ?

note I am only indie not business on xamarin so have to build android/ios versions in xamarin studio

thanks in advance

Hi Chris,

We had a similar issue which also affected our Android port (but only a subset of devices). We found out that it has something to do with DepthStencilState. Try to use DepthStencilState.None in your SpriteBatch.Begin calls surrounding your font rendering and let me know if it changes anything.

ah well i don’t get past loading with the iOS specific .xnb i created on my mac.

But i guess you are referring to using the original .xnb file.
I tried passing DepthStencilState.None to Begin - but it didn’t like it even when i nulled all other arguments.

Ok, so it has nothing to do with DepthStencilState.

How do you create your xnb files? Regarding the font, do you use a spriteFont descriptor or bmp font?

the one that works but is all black blocks was created on VS2012 for the original WP8 version
So I’ve rebuilt it using a blank content project on the mac xamarin studio - which creates an iOS bin directory with the new xnb in it.

it gets an exception saying its a non content file.

the original spritefont file has it listed as a

It is normal that the original one (targeting WP8) does not work, as iOS xnb’s require PVRTC compression.

Looks like you have correctly generated the file on your mac, this error typically appears if you haven’t set the XNB file “action” property to “content”.

it sounds like that but its set to content / copy always - infuriating!! :smile:

Maybe the file path is wrong then. I suppose your xnb files are in a “Content” folder at the root your project?
Also check that in your Game class constructor you initialize the content root directory to that folder ( Content.RootDirectory = “Content”; ).

yep it works fine with the old file but black blocks
when i overwrite it with the new one it fails to load
oddly the file type is appearing as different for the old and new ones.

original.xnb is showing as Unix Executable File
new.xnb is showing as Document ?

both are identical in size

they may be identical in size but the headers are different in a good way

the one built for iOS has monogame references in it (this is just opening the .xnb in textedit)


This is just the file explorer showing fancy stuff, it happens to me too when I copy/paste XNBs.

Well, this is strange. Do you still have access to VS? If yes, try installing MonoGame, create a Content Builder Project, target iOS, set the font Content Processor to “MonoGame Spritefont from texture” (or “MonoGame Spritefont” if your working with an XML descriptor) and build the xnb from there.

If it works, your Mac generated xnb have a problem, but I don’t know which one (haven’t tried to generate spritefonts on mac yet).

And this just came to my mind: if you are using an XML file to generate your spriteFont XNB, you need the font TTF file to be next to the xml file on Mac. Is this ok too?

1 Like

I’m home now so only have mac - I’m not sure i can target iOS on my pc as i only have indie xamarin?
yep the ttf is in the content directory too :smile:


You don’t need Xamarin to build XNBs with the Content Builder project template (but it requires XNA to be installed). :slight_smile:

ok ill give that a go - typically ive only got my pc with me today !!

mmmm putting xna on a win 8.1 machine seems unlikely :smile:

Anyone got a dummy content project that builds spritefonts that will work on iOS
I’ve spent days on this and fail every time

I’ve just found this

which installs XNA on windows 8 / VS2012

so now my monogame content project builds - Won’t know until i get home if it fixes things
but its movment :slight_smile:

Back home now - and no go still getting black boxes where all the text should be
this is using the xnb that built into the iOS bin directory - will bring macbook to work tomorrow to play around a bit more.


it was me being a complete muppet.

i hadn’t selected MonoGame SpriteFont in Content Processor (in the XNA Framework content pipeline section of the properties) I wrongly assumed that if i used the monogame content project it would be using monogame content processors - but you have to select them in properties for the font.

The new monogame content template in VS2012 doesn’t seem to need all the hand editing just select iOS as target etc.

phew - i can submit my game to the app store now (well once i package it all up)

1 Like