Sign in to follow this  

Issue Loading Spritefont

This topic is 2049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am having trouble loading a spritefont for Trajan Pro. I downloaded/installed the font (multiple times/ways now) and have restarted both my machine and visual studio many times, but I still get a build error telling me that it cannot find the 'Trajan Pro' font family. It's in the font folder, both regular and bold. I've tried every spelling of 'Trajan Pro' I can think of, and cannot get it to work.

I even tried running through the .net library of available font families, and I noted several ones that were in my font folder, but did not show up, Trajan Pro was among them.

The code I used to show font family (in a winforms project, not xna):

[CODE]
Dim family As FontFamily
For Each family In FontFamily.Families
debug.Print(family.Name)

Next
[/CODE]

Does anyone know how visual studio/XNA loads in these fonts? Is there any way I can make this work? Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites
Are you sure you're using the "friendly name" of the font that Windows recognizes? This doesn't necessarily match the font filename. And it's a TrueType font, .ttf, right?

More from MSDN re: the FontName tag in the .spritefont file:
[quote]The name of the font to be imported. This is not the name of a font file, but rather the friendly name that identifies the font once it is installed on your computer. You can use the [b]Fonts[/b] folder in Control Panel to see the names of fonts installed on your system, and to install new ones as well. The Content Pipeline supports the same fonts as the [url="http://msdn.microsoft.com/en-us/library/system.drawing.font.aspx"]System.Drawing.Font[/url] class, including TrueType fonts, but not bitmap (.fon) fonts.[/quote]

Share this post


Link to post
Share on other sites
It's an open type font, but the error specifically states that it has to be open type or true type, so it's covered there. I am mostly attempting to use the name "Trajan Pro" with any variation I can think of. The 'friendly name' as far as I can tell is Trajan Pro according to the font folder and notepad/wordpad/word, etc. Which all show Trajan Pro as an option and work. Hmm... is there any way to load the font directly from the file, say if I include it in the project directory?

Share this post


Link to post
Share on other sites
Aha! Found it. So apparently some OpenType Font setups will not work. It's a misleading error message. To quote an exerpt from where I found my answer:

[quote][color=#4A4A4A][background=rgb(241, 241, 241)]The OpenType requirement is a bit misleading as the font has to have TrueType outlines; OpenType also supports PostScript outlines which do not work in GDI+, which is what the SpriteFont processor internally uses.[/background][/color][/quote]

So I did an online conversion from otf to ttf and reinstalled my fonts with the TTF files, once I restarted visual studio again after that, it worked.

Share this post


Link to post
Share on other sites

This topic is 2049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this