public static bool SaveToStream(BinaryWriter outputWriter, Font font) { FontStorage storage = new FontStorage(string.Empty, font); if (!storage.Write(outputWriter)) { Debug.Assert(false, "Cannot write a font file!"); return(false); } return(true); }
public static Font LoadFromStream(BinaryReader inputReader, string name) { FontStorage storage = new FontStorage(); if (!storage.Parse(inputReader)) { Debug.Assert(false, "Cannot read a font file!"); return(null); } Texture texture = new Texture(name, storage.Pixels, storage.Width, storage.Height); return(new Font(name, texture, storage.GlythOffsets)); }
public static bool SaveToFile(string filePath, Font font) { FontStorage storage = new FontStorage(filePath, font); using (FileStream outputStream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { using (BinaryWriter outputWriter = new BinaryWriter(outputStream, storage.Encoding)) { if (!storage.Write(outputWriter)) { Debug.Assert(false, "Cannot write a font file!"); return(false); } } } return(true); }
public static Font LoadFromFile(string filePath) { FontStorage storage = new FontStorage(filePath); using (FileStream inputStream = new FileStream(storage.LibraryPath, FileMode.Open, FileAccess.Read)) { using (BinaryReader inputReader = new BinaryReader(inputStream, storage.Encoding)) { if (!storage.Parse(inputReader)) { Debug.Assert(false, "Cannot read a font file!"); return(null); } } } string name = Path.GetFileNameWithoutExtension(filePath); Texture texture = new Texture(name, storage.Pixels, storage.Width, storage.Height); return(new Font(name, texture, storage.GlythOffsets)); }