This project is read-only.

Support for Bold, Italic style in Spritefont processor

Feb 4, 2011 at 8:11 PM

I have a project that requires a lot of flexibility in font styling, so i need to include a huge number of fonts, and support all styles. I am having success with the Nuclex spritefont processor, except when it comes to "Bold, Italic" style.

I get the following error upon compilation:

Error 1 Building content threw Exception: Font could not be found   at Nuclex.Fonts.Content.FreeTypeManager.OpenWindowsFont(String faceName, FontDescriptionStyle style)   at Nuclex.Fonts.Content.FreeTypeManager.OpenFont(String pathOrFaceName, FontDescriptionStyle style)   at Nuclex.Fonts.Content.FreeTypeFontProcessor..ctor(FontDescription fontDescription)   at Nuclex.Fonts.Content.NuclexSpriteFontDescriptionProcessor.Process(FontDescription input, ContentProcessorContext context)   at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)   at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()   at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings) C:\Users\eflath.INEXT\dev\comcast\XRE\XNA receiver\trunk\XnaReceiver\XnaReceiver\XnaReceiverContent\Fonts\Monospace\Monospace_20_Bold, Italic.spritefont XnaReceiver

my spritefont descriptor is the following (I have tried with Arial and Times New Roman) :

<XnaContent xmlns:Graphics='Microsoft.Xna.Framework.Content.Pipeline.Graphics'>
	<Asset Type='Graphics:FontDescription'>
		<FontName>Courier New</FontName>
		<Style>Bold, Italic</Style>

Has anyone run in to this, or a related issue?

Feb 4, 2011 at 8:32 PM

This is a known issue in the current release. There's no well-defined API for looking up the font names in Windows, so I'm checking the names embedded in the *.ttf files in the Fonts directory to find "Courier New" with the appropriate style flags.

However, I recently received a generous code contribution that changes this behavior to look up fonts via an as far as I can tell undocumented (but very likely permanent) registry key. I just tested your .spritefont file and it is successfully processed with the latest build. If you wish to try it, you can find nightly builds here:



Feb 4, 2011 at 8:43 PM
Edited Feb 4, 2011 at 8:44 PM

wow, you're the best! :-)

and a hearty thanks to the generous contributor as well!

Sep 27, 2014 at 9:43 PM
For others out there in the dark: the <FontName> and <Style> tags in the .spritefont file must correspond exactly to the names specified in the .ttf file.

To find these, go to c:\windows\fonts, right-click the font -> properties -> Details tab
there you will find description -> title the EXACT names which you need to fill in, in this order:

Worked for me for all combinations of styles using the regular Nuclex processor, provided you have the font in these specific styles installed on your system.

If you have .otf files for input: this site worked fine for me: