// GetKerningAmount public int GetKerningAmount(char first, char second) { int kerningHash = GetKerningHash(first, second); int result; if (KerningMap.TryGetValue(kerningHash, out result)) { return(result); } return(0); }
public StaticSpriteFont(FontSystem fontSystem, StaticSpriteFontData spriteFontData) : base(fontSystem, spriteFontData, false) { characterToGlyph = new Dictionary <char, Glyph>(spriteFontData.Glyphs.Length); // build the character map foreach (var glyph in spriteFontData.Glyphs) { var character = (char)glyph.Character; characterToGlyph[character] = glyph; } // Prepare kernings if they are available. var kernings = spriteFontData.Kernings; if (kernings != null) { for (int i = 0; i < kernings.Length; i++) { int key = (kernings[i].First << 16) | kernings[i].Second; KerningMap.Add(key, kernings[i].Offset); } } // Read the texture data. StaticTextures = new Texture2D[spriteFontData.Bitmaps.Length]; for (int i = 0; i < StaticTextures.Length; i++) { if (spriteFontData.Bitmaps[i].Value != null) { StaticTextures[i] = Texture2D.New(fontSystem.GraphicsDevice, spriteFontData.Bitmaps[i].Value).DisposeBy(this); } } Textures = StaticTextures; BaseOffsetY = spriteFontData.BaseOffset; DefaultLineSpacing = spriteFontData.FontDefaultLineSpacing; }