// FontData public FontData(FontDataXML dataXML) { FontHeight = dataXML.Info.Size; LineHeight = dataXML.Common.LineHeight; TextureWidth = dataXML.Common.ScaleW; TextureHeight = dataXML.Common.ScaleH; Characters = new FontDataChar[dataXML.Chars.Count]; CharMap = new Dictionary <char, int>(Characters.Length); for (int i = 0; i < dataXML.Chars.Count; ++i) { Characters[i] = new FontDataChar(dataXML.Chars[i]); CharMap.Add((char)dataXML.Chars[i].ID, i); } NullCharacter = CharMap[(char)0xffff]; KerningMap = new Dictionary <int, int>(dataXML.Kernings.Count); for (int i = 0; i < dataXML.Kernings.Count; ++i) { KerningMap.Add(GetKerningHash((char)dataXML.Kernings[i].First, (char)dataXML.Kernings[i].Second), dataXML.Kernings[i].Amount); } }
// Load public static FontDataXML Load(string filename) { TextReader textReader = new StreamReader(filename); XmlSerializer deserializer = new XmlSerializer(typeof(FontDataXML)); FontDataXML fontData = (FontDataXML)deserializer.Deserialize(textReader); textReader.Close(); return(fontData); }
// Font public Font(string path, string name) { Name = name; _UI.Texture.Add(0, path + name, name); TextureIndex = _UI.Texture.Get(name); FontDataXML fontDataXML = FontDataXML.Load(_UI.Content.RootDirectory + "\\" + path + name + ".fnt"); FontData = new FontData(fontDataXML); }
// FontData public FontData( FontDataXML dataXML ) { FontHeight = dataXML.Info.Size; LineHeight = dataXML.Common.LineHeight; TextureWidth = dataXML.Common.ScaleW; TextureHeight = dataXML.Common.ScaleH; Characters = new FontDataChar[ dataXML.Chars.Count ]; CharMap = new Dictionary< char, int >( Characters.Length ); for ( int i = 0; i < dataXML.Chars.Count; ++i ) { Characters[ i ] = new FontDataChar( dataXML.Chars[ i ] ); CharMap.Add( (char)dataXML.Chars[ i ].ID, i ); } NullCharacter = CharMap[ (char)0xffff ]; KerningMap = new Dictionary< int, int >( dataXML.Kernings.Count ); for ( int i = 0; i < dataXML.Kernings.Count; ++i ) KerningMap.Add( GetKerningHash( (char)dataXML.Kernings[ i ].First, (char)dataXML.Kernings[ i ].Second ), dataXML.Kernings[ i ].Amount ); }