internal static void WriteMetrics(object spriteFontContent, ContentProcessorContext context, string filename) { dynamic sfc = ExposedObject.From(spriteFontContent); using(FileStream fs = File.Open(filename, FileMode.Create, FileAccess.Write)) { using(BinaryWriter bw = new BinaryWriter(fs, Encoding.Unicode)) { // Identifier and version: bw.Write((int)0x6E457845); // ExEn bw.Write((int)0x746E6F46); // Font bw.Write((int)0); // Write common properties bw.Write((int)sfc.LineSpacing); bw.Write((int)sfc.Spacing); if(bw.WriteBoolean(((char?)sfc.DefaultCharacter).HasValue)) bw.Write(((char?)sfc.DefaultCharacter).Value); // Write glyph list: int count = sfc.CharacterMap.Count; bw.Write(count); for(int i = 0; i < count; i++) { bw.Write((char)sfc.CharacterMap[i]); bw.Write((Rectangle)sfc.Glyphs[i]); bw.Write((Rectangle)sfc.Cropping[i]); bw.Write((Vector3)sfc.Kerning[i]); } } } context.AddDependency(filename); }