using System; using System.Collections.Generic; using System.Text; using System.IO; namespace Orvid.Graphics.FontSupport { /// /// The base type for a font. /// public abstract class Font { private static Dictionary LoadedFonts = new Dictionary(); public static Font GetFont(string name) { if (LoadedFonts.ContainsKey(name)) { return LoadedFonts[name]; } return null; } public static Font LoadFont(Stream s, int format) { return FontManager.Instance.LoadFont(format, s); } public abstract Font LoadFont(Stream s); public abstract void Render(Image i, BoundingBox clip, AffineTransform trans, string text, Vec2 loc, Pixel color); public abstract ITextRenderer GetTextRenderer(); public abstract FontMetrics GetFontMetrics(); public abstract bool IsSupportedType(Font f); public abstract string ProviderName { get; } public abstract List DefaultFonts { get; } /// /// The name of the font. /// public string Name { get; private set; } /// /// The style of the font. /// public FontStyle Style { get; private set; } /// /// The point-size of the Font rounded to an int. /// public float Size { get; private set; } /// /// This constructor should only be used /// for initializing it as a loader. /// /// internal Font(bool b) { } /// /// The default constructor. /// /// The name of the font. /// The style of the font. /// The point-size of the font. public Font(string name, FontStyle style, int size) { this.Name = name; this.Style = style; this.Size = (float)size; LoadedFonts.Add(name, this); } /// /// The default constructor. /// /// The name of the font. /// The style of the font. /// The point-size of the font. public Font(string name, FontStyle style, double size) { this.Name = name; this.Style = style; this.Size = (float)size; LoadedFonts.Add(name, this); } /// /// The default constructor. /// /// The name of the font. /// The style of the font. /// The point-size of the font. public Font(string name, FontStyle style, float size) { this.Name = name; this.Style = style; this.Size = size; LoadedFonts.Add(name, this); } } }