Cosmos/source2/Users/Orvid/Orvid.Graphics/FontSupport/Defaults/DefaultFontManager.cs
blah38621_cp 92dcac4a51 Made a few improvements to the speed of the ILScanner, including caching the resolved plugs.
Added the possibility for an optimization step in the IL2CPU MSBuild task. Currently commented out, but should work fine with a few modifications to the optimizer.
Moved classes that are dependent on Cosmos from the Orvid.Graphics, into the Orvid.Graphics.Cosmos assembly. 
Re-factored the font mechanism, added partially working .fnt Font support. 
Added a Rectangle class, and a Vec2d class, which is the same as Vec2, except with doubles for the X and Y values.
Made a small aesthetic improvement to the output of the File2ByteArray Converter.
2011-09-03 21:05:46 +00:00

62 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
namespace Orvid.Graphics.FontSupport
{
/// <summary>
/// The default FontManager.
/// </summary>
public class DefaultFontManager : FontManager
{
Dictionary<int, Font> Providers = new Dictionary<int, Font>();
public DefaultFontManager()
{
Providers.Add(1, new bdf.BDFFont());
Providers.Add(2, new fnt.FntFont());
}
public override string Name
{
get { return "Default Font Manager"; }
}
public override FontMetrics GetFontMetrics(Font font)
{
return font.GetFontMetrics();
}
public override void DrawText(Image i, BoundingBox clip, AffineTransform trans, string s, Font f, Vec2 Loc, Pixel p)
{
f.Render(i, clip, trans, s, Loc, p);
}
public override Font LoadFont(int format, Stream s)
{
if (!Providers.ContainsKey(format))
{
throw new Exception("Unknown format!");
}
return Providers[format].LoadFont(s);
throw new Exception("can't create font with format #'" + format.ToString() + "'");
}
public override Font[] Fonts
{
get
{
List<Font> all = new List<Font>();
foreach (KeyValuePair<int,Font> prv in Providers)
{
all.AddRange(prv.Value.DefaultFonts);
}
return all.ToArray();
}
}
}
}