/// <summary> /// Function to read the kerning pairs for the font, if they exist. /// </summary> /// <param name="fontFile">Font file to read.</param> private static Dictionary <GorgonKerningPair, int> ReadKernPairs(GorgonChunkFileReader fontFile) { var result = new Dictionary <GorgonKerningPair, int>(); GorgonBinaryReader reader = fontFile.OpenChunk(KernDataChunk); // Read optional kerning information. int kernCount = reader.ReadInt32(); for (int i = 0; i < kernCount; ++i) { var kernPair = new GorgonKerningPair(reader.ReadChar(), reader.ReadChar()); result[kernPair] = reader.ReadInt32(); } fontFile.CloseChunk(); return(result); }
/// <summary> /// Function to read the chunk containing the font information. /// </summary> /// <param name="fontFile">The chunk file reader containing the font data.</param> /// <param name="name">Used defined name for the font.</param> /// <returns>A new <seealso cref="IGorgonFontInfo"/> containing information about the font.</returns> private static GorgonFontInfo GetFontInfo(GorgonChunkFileReader fontFile, string name) { GorgonBinaryReader reader = fontFile.OpenChunk(FontInfoChunk); var info = new GorgonFontInfo(reader.ReadString(), reader.ReadSingle(), reader.ReadValue <FontHeightMode>(), name) { FontStyle = reader.ReadValue <FontStyle>(), DefaultCharacter = reader.ReadChar(), Characters = reader.ReadString(), AntiAliasingMode = reader.ReadValue <FontAntiAliasMode>(), OutlineColor1 = new GorgonColor(reader.ReadInt32()), OutlineColor2 = new GorgonColor(reader.ReadInt32()), OutlineSize = reader.ReadInt32(), PackingSpacing = reader.ReadInt32(), TextureWidth = reader.ReadInt32(), TextureHeight = reader.ReadInt32(), UsePremultipliedTextures = reader.ReadValue <bool>(), UseKerningPairs = reader.ReadBoolean() }; fontFile.CloseChunk(); return(info); }