How are .xnb files actually built? (using .ttf -> .spritefont as example)

Hey guys, I just wanna know if and, if so how, it’s possible to build .spritefont files with custom .ttf files, using the Content Pipeline in MonoGame? I already know how to make a .spritefont, but doesn’t that require the user to have that font installed on his system? Or does the .xnb file, once I bulid it, copy and contain all the .ttf data, as if it was its own .ttf file? What if I want to use some obscure font type, or even one I make myself?

(In other words, I don’t mind having to install the .ttf on my system in order to build the .xnb file, but I don’t want the end user to have to have it on his system in order to use the .xnb file.)

I guess my real question is, once you’ve built an .xnb file, will that single file be the ONLY dependency that your program will have (in terms of getting the specific asset data)? And is that true regardless of what file format you built it from?

Thanks for any input.

Include the .ttf file in the content folder next to the spritefont file. In the .spritefont file add the .ttf extension to the name to use the file in the same folder.

.xnb files do not always contain all data for the asset, they sometimes depend on other files being in the same folder.

1 Like

Awesome, I got it to work thanks. Took a bit of dickery though, as I realized I had to use …/ but it works now. :slight_smile:
So basically …/myFont.tff if your .spritefont file is in a subfolder, for anyone else who wonders.

1 Like