static SitanaFont LoadFont(string name, out Bitmap bitmap) { SitanaFont font = new SitanaFont(); using (Stream stream = File.OpenRead(name)) { using (BinaryReader reader = new BinaryReader(stream)) { font.Load(reader); } } string sheetPath = Path.GetFileNameWithoutExtension(name); if (!string.IsNullOrWhiteSpace(font.FontSheetPath)) { sheetPath = font.FontSheetPath; } sheetPath = Path.Combine(Path.GetDirectoryName(name), sheetPath) + ".png"; bitmap = (Bitmap)Bitmap.FromFile(sheetPath); return(font); }
public static void LoadFontsPack(string path) { Texture2D texture = ContentLoader.Current.Load <Texture2D>(path); using (Stream stream = ContentLoader.Current.Open(path + ".pft")) { using (BinaryReader reader = new BinaryReader(stream)) { int count = reader.ReadInt32(); while (count > 0) { count--; string name = reader.ReadString(); Font font = new Font(); font.Load(reader); font.FontSheet = texture; ContentLoader.Current.AddContent(name, typeof(Font), font); } } } }
public static Object Load(String name) { Font font = new Font(); using (Stream stream = ContentLoader.Current.Open(name + ".sft")) { using (BinaryReader reader = new BinaryReader(stream)) { font.Load(reader); } } string sheetPath = name; if (!font.FontSheetPath.IsNullOrWhiteSpace()) { string directory = Path.GetDirectoryName(name); sheetPath = Path.Combine(directory, font.FontSheetPath); } font.FontSheet = ContentLoader.Current.Load <Texture2D>(sheetPath); return(font); }