AuroraBertaOldham/SharpFNT

BitmapFont.FromStream throws System.IO.InvalidDataException: 'Invalid property name.'

danielscherzer opened this issue · 5 comments

Thank you for your very useful library!
I found that programs, like Hiero (https://github.com/libgdx/libgdx/wiki/Hiero), which also claim to create AngleCode compatible formats omit some properties (like alphaChnl, redChnl, greenChnl, blueChnl and outline) in the *.fnt file, if they have a default value. This causes the 'Invalid property name.' exception in your library.
If I add all the ommited properties per hand in the *.fnt file your library works perfectly again.
It would be nice if your BitmapFont parser would be more forgiving, so I do not have to edit every exported file per hand. Especially Hiero is widely used because it can produce distant field fonts for better quality. Any help would be greatly appreciated!

Hi, sorry for the issue that you’re having! I can definitely update the text and XML formats to be relaxed on missing properties. I can just infer that values are 0 or false when they are missing. I’m going to sleep soon but I’ll definitely work on this tomorrow. I have one question though. You said that a property like alphaChnl having a default value would cause it to be omitted. What is that default value?

Thanks for your quick response. Regarding your question, here is an excerpt from the output created by Hiero

info face="Droid Sans" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=0,0
common lineHeight=42 base=30 scaleW=256 scaleH=128 pages=1 packed=0

and the working version below with the added properties.

info face="Droid Sans" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=1,1,1,1 spacing=0,0 outline=0
common lineHeight=42 base=30 scaleW=256 scaleH=128 pages=1 packed=0  alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0

I added outline=0 and alphaChnl=0 redChnl=0 greenChnl=0 blueChnl=0. I took these values from the output of bmfont64.exe when creating a font with parameters set too: Screenshot (11)
I tuned the parameters to give me the same result as with Hiero. So I guess 0s are the defaults for bmfont64.exe for channels. In Hiero I do not have settings for the number of output channels. It seems to always create 4*8bit channels. Hope this clears things up! Thansk for your help!

Thank you for the detailed response! My concern was that Hiero might define its own default values. I'm planning on having the channel properties default to 0/glyph regardless. I was just curious to know if that might cause some issues with what Hiero outputs. I've started working on the update so I'd expect it in the next day or two.

Release 2.0.0 should allow you to read files with missing properties. It should be available on NuGet soon. Let me know if you have any issues and I can reopen this.

Thanks! Now it works perfectly!