This project is read-only.

FontParser generates wrong XML when used on system with , as decimal separator

May 30, 2013 at 1:46 PM
Hi

I had trouble converting my own fonts using the included tool. The issue is that the FontParser uses the ToString and Format functions without culture information. On systems where the decimal seperator is "," the two numbers 0.5,0.2 becomes the four numbers 0,5,0,2.

The fix is easy, change the following lines in Window1.cs (in FontParser project):
XElement ele = new XElement("glyph",
                    new XAttribute("key", glyph),
                    new XAttribute("advance", string.Format("{0},{1}", widths[key], heights[key])),
                    new XAttribute("bearings", string.Format("{0},{1},{2},{3}", leftSide[key], topSide[key], rightSide[key], bottomSide[key])),
                    new XAttribute("path", g.ToString()));
to:
XElement ele = new XElement("glyph",
                    new XAttribute("key", glyph),
                    new XAttribute("advance", string.Format(CultureInfo.InvariantCulture, "{0},{1}", widths[key], heights[key])),
                    new XAttribute("bearings", string.Format(CultureInfo.InvariantCulture, "{0},{1},{2},{3}", leftSide[key], topSide[key], rightSide[key], bottomSide[key])),
                    new XAttribute("path", g.ToString(CultureInfo.InvariantCulture)));