VectorFont returns null for all fonts

May 19, 2011 at 9:13 PM

not sure what ive done wrong. I have everything building just fine. I chose a known font "arial".

When i dig into contentmanager i get the exception deep in read asset as :

Could not load file or assembly 'Nuclex.Fonts, Version=4.0.0.0, Culture=neutral, PublicKeyToken=96bb577564343f16' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

 

Not sure what is wrong.

May 19, 2011 at 9:33 PM

Well, i found out what was wrong.

in the cpp project Nuclex.Font.Content.TrueTypeImporter there are 4 places (2 in VectorFontCharacterWriter.cpp and 2 in VectorFontWriter.cpp) where "PublicKeyToken" refers to the value above.

The way i ended up fixing this is navigating to the final NuclexFonts.dll that was built and placed in my project directory and running the command      sn -T Nuclex.Fonts.dll    from a visual studio command prompt. then i took the public key token that it said Nuclex.Fonts.dll had and replaced all instances in those 4 places with this new one.

 

Now i get a good VectorFont out of Nuclex.

 

Thanks for the great framework.

Coordinator
May 20, 2011 at 9:25 AM

Glad you figured it out :)

I have just added a How to Compile page to the documentation (I guess I should have been doing that all along), explaining the steps needed to compile. Hopefully that will make it easier for others in the future!

May 20, 2011 at 2:07 PM

Awesome. Compiling overall was extremely easy. Runtime style errors are just always confusing, especially when XNA Content Reader eats the really descriptive part of the error. Only found it thanks to reflector.

 

Also, a quick question, is there anyway to adjust the smoothing of a VectorFont (like how facetted its edge is)?

Coordinator
May 20, 2011 at 8:58 PM

Yes, although not without recompiling the TrueType importer:

In Nuclex.Fonts.Content.TrueTypeImporter\Source\VectorFonts\FreeTypeFontVectorizer.cpp, you'll find a constant named "BezierStepCount", once for conic curve interpolations and once for cubic curve interpolations. This constant controls the number of supporting points generated for each curve in the font.

It would definitely be cool if the number of supporting points required to make a font's curves look smooth could be determined programmatically, but after pondering this problem fruitlessly for some time, I just decided that the answer is 3 - 3 interpolation steps for any kind of curve. Feel free to raise that number in order to get finer facets :-)

May 20, 2011 at 9:03 PM

Thanks very much. 

Even if it couldnt be done programmatically (although that would be totally awesome), it would be interesting if it could be done in the spriteFont import file.

If i can remember how to write an importer i may attempt it.

thanks for the help and the great framework, keep it up!

Coordinator
May 20, 2011 at 9:42 PM

Modifying the .spritefont XML format is probably not so easy because I'm just reusing the SpriteFontDescription class already provided by XNA.

What you could probably do quite easily is to add a property to the NuclexVectorFontDescriptionProcessor (the NuclexSpriteFontDescriptionProcessor already has properties, check its header for the properties with DefaultValueAttribute and DisplayNameAttribute). Then just pass that along to the vectorizer and XNA should be taking care of saving the properties' value in the content project and assigning it to the processor before building the vector font.