Exemplo n.º 1
0
        public static FontFile Load(String filename)
        {
            XmlSerializer deserializer;
            FontFile      file = null;

            deserializer = new XmlSerializer(typeof(FontFile));
            TextReader textReader = new StreamReader(filename);

            file = (FontFile)deserializer.Deserialize(textReader);
            textReader.Close();

            return(file);
        }
Exemplo n.º 2
0
        public static Font2D GetFont(string ressource)
        {
            Font2D font        = new Font2D();
            String currentPath = FindFile(ressource);

            if (!File.Exists(currentPath))
            {
                FontFile file = FontLoader.Load(currentPath + ".fnt");
                font.LineSpacing = file.Common.LineHeight;

                foreach (FontChar fchar in file.Chars)
                {
                    font.characterMap.Add((char)fchar.ID);
                    font.glyphData.Add(new Rectangle(fchar.X, fchar.Y, fchar.X + fchar.Width, fchar.Y + fchar.Height));
                    font.croppingData.Add(new Rectangle(fchar.XOffset, fchar.YOffset, fchar.XOffset + fchar.XAdvance, fchar.YOffset + fchar.YOffset));
                }
                foreach (FontKerning kern in file.Kernings)
                {
                    font.kerning.Add(new Vector3(kern.First, kern.Second, kern.Amount));
                }
            }
            font.textureValue = GetTexture(currentPath + "_0", false);
            return(font);
        }