Cosmos/source2/Users/Orvid/Orvid.Graphics/FontSupport/fnt/FntFont.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

77 lines
1.7 KiB
C#

using System;
namespace Orvid.Graphics.FontSupport.fnt
{
internal class FntFont : Font
{
private FntLoader ldr;
private FntFontMetrics metrics;
/// <summary>
/// The constructor for the loader.
/// </summary>
public FntFont() : base(true) { }
public FntFont(FntLoader loadr)
: base(loadr.GetFamily(), loadr.GetStyle(), loadr.GetSize())
{
ldr = loadr;
metrics = new FntFontMetrics(this);
}
public FntLoader GetLoader()
{
return ldr;
}
public Rectangle GetBounds()
{
Rectangle r = new Rectangle();
r.SetBounds(0, ldr.Ascent, ldr.MaxWidth, ldr.PixHeight);
return r;
}
public override FontMetrics GetFontMetrics()
{
return metrics;
}
public override ITextRenderer GetTextRenderer()
{
return new FntTextRenderer(ldr);
}
public override bool IsSupportedType(Font f)
{
return (f is FntFont);
}
public override Font LoadFont(System.IO.Stream s)
{
FntLoader l = new FntLoader();
l.Load(s);
return new FntFont(l);
}
public override void Render(Image i, BoundingBox clip, AffineTransform trans, string text, Vec2 loc, Pixel color)
{
GetTextRenderer().Render(i,clip,trans,text,loc,color);
}
public override string ProviderName
{
get
{
return "Default Fnt Font Provider";
}
}
public override System.Collections.Generic.List<Font> DefaultFonts
{
get
{
return new System.Collections.Generic.List<Font>();
}
}
}
}