Possible bug with NuclexSpriteFontDescriptionProcessor

Sep 8, 2011 at 10:55 PM

I've noticed that if the list of characters I add to the FontDescription.Characters collection are not sorted ahead of time (by me) then the resulting SpriteFont I get from XNA at runtime will have problems locating certain characters in its character map. Looking at Microsoft's SpriteFont.GetIndexForCharacter method in Reflector it looks like they're doing binary search to locate the character, so they assume the collection is sorted.

I'm not sure if it would be the Nuclex processor's responsobility to ensure the list is sorted when it is processing, or if this is a known requirement for the user when building a FontDescription, but I thought I would point this out just in case.

-Evan

Coordinator
Sep 13, 2011 at 4:13 PM
Edited Sep 17, 2011 at 10:18 AM

Good find! I didn't know that the list needs to be sorted and so far I didn't even notice that there's a binary search taking place to look up the characters :)

I'll just have it sort the character list from the next release onwards, whether or not it's the content processor's responsibility, sorting in the order of just a few thousand 16 bit integers should take a negligible amount of time!

Sep 15, 2011 at 12:45 AM
Edited Sep 15, 2011 at 12:47 AM

yes