Example #1
0
        private static Dictionary <char, FontRegion> BuildCharacterMap(FontFile fontFile, Texture texture)
        {
            var characterMap = new Dictionary <char, FontRegion>();

            foreach (var fontChar in fontFile.Chars)
            {
                var character  = (char)fontChar.ID;
                var name       = character.ToString();
                var region     = new TextureRegion(name, texture, fontChar.X, fontChar.Y, fontChar.Width, fontChar.Height);
                var fontRegion = new FontRegion {
                    FontChar = fontChar, TextureRegion = region
                };
                characterMap.Add(character, fontRegion);
            }

            return(characterMap);
        }
Example #2
0
 public BitmapFont(string name, Texture texture, FontFile fontFile)
 {
     Name          = name;
     _characterMap = BuildCharacterMap(fontFile, texture);
 }