Example #1
0
        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));
        }
Example #2
0
        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));
        }