public static void WriteToSng(Sng2014File sng, string glyphDefinitionsPath)
        {
            GlyphDefinitions glyphDefs;

            using (var reader = new StreamReader(glyphDefinitionsPath))
            {
                glyphDefs = new XmlStreamingDeserializer <GlyphDefinitions>(reader).Deserialize();
            }

            sng.SymbolsTexture.SymbolsTextures[0].Width  = glyphDefs.TextureWidth;
            sng.SymbolsTexture.SymbolsTextures[0].Height = glyphDefs.TextureHeight;

            var symbolDefs = new List <SymbolDefinition>(glyphDefs.Glyphs.Count);

            foreach (var glyph in glyphDefs.Glyphs)
            {
                if (Encoding.UTF8.GetByteCount(glyph.Symbol) > 12)
                {
                    throw new Exception(String.Format("The following symbol does not fit into 12 bytes when encoded in UTF-8: {0}", glyph.Symbol));
                }

                var sDef = new SymbolDefinition
                {
                    Rect_Inner = new Rect
                    {
                        xMax = glyph.InnerXMax,
                        xMin = glyph.InnerXMin,
                        yMax = glyph.InnerYMax,
                        yMin = glyph.InnerYMin
                    },
                    Rect_Outter = new Rect
                    {
                        xMax = glyph.OuterXMax,
                        xMin = glyph.OuterXMin,
                        yMax = glyph.OuterYMax,
                        yMin = glyph.OuterYMin
                    }
                };
                Encoding.UTF8.GetBytes(glyph.Symbol).CopyTo(sDef.Text, 0);

                symbolDefs.Add(sDef);
            }

            sng.SymbolsDefinition = new SymbolDefinitionSection
            {
                Count             = symbolDefs.Count,
                SymbolDefinitions = symbolDefs.ToArray()
            };
        }
 public static Sng2014File ReadVocals(Stream xmlData)
 {
     var data = new MemoryStream(Resources.VOCALS_RS2);
     var sng = new Sng2014File(data);
     var xml = new XmlStreamingDeserializer<Vocals>(new StreamReader(xmlData)).Deserialize();
     Sng2014FileWriter.parseVocals(xml, sng);
     return sng;
 }