Font ClassDelta Engine Documentation
Holds the image and data for rendering a smoothly drawn font. View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Content ContentData
    DeltaEngine.Content.Xml XmlContent
      DeltaEngine.Rendering2D.Fonts Font
        DeltaEngine.Rendering2D.Mocks MockFont

Namespace: DeltaEngine.Rendering2D.Fonts
Assembly: DeltaEngine.Rendering2D.Fonts (in DeltaEngine.Rendering2D.Fonts.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class Font : XmlContent

The Font type exposes the following members.

Constructors

  NameDescription
Protected methodFont
Initializes a new instance of the Font class
Top
Methods

  NameDescription
Protected methodCreateDefault (Overrides ContentData CreateDefault .)
Public methodDispose (Inherited from ContentData.)
Protected methodDisposeData (Overrides XmlContent DisposeData .)
Protected methodInitializeDescriptionAndMaterial
Public methodInternalCreateDefault (Inherited from ContentData.)
Protected methodLoadData (Overrides XmlContent LoadData(Stream).)
Public methodToString (Inherited from ContentData.)
Top
Fields

  NameDescription
Protected fieldContentChanged (Inherited from ContentData.)
Top
Properties

  NameDescription
Protected propertyAllowCreationIfContentNotFound (Overrides ContentData AllowCreationIfContentNotFound.)
Public propertyData (Inherited from XmlContent.)
Public propertyStatic memberDefault
Public propertyIsDisposed (Inherited from ContentData.)
Public propertyMetaData (Inherited from ContentData.)
Public propertyName (Inherited from ContentData.)
Top
Remarks

Tests: DeltaEngine.Rendering2D.Fonts.Tests.FontDataTests
Examples

29 unit tests call DeltaEngine.Rendering2D.Fonts.Font
[Test, CloseAfterFirstFrame]
public void LoadFontData()
{
    var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
    Assert.AreEqual("Verdana", fontData.FontFamilyName);
    Assert.AreEqual(12, fontData.SizeInPoints);
    Assert.AreEqual("AddOutline", fontData.Style);
    Assert.AreEqual(16, fontData.PixelLineHeight);
    Assert.AreEqual("Verdana12Font", fontData.FontMapName);
    Assert.AreEqual(new Size(128, 128), fontData.FontMapPixelSize);
    Assert.AreEqual(new Rectangle(0, 0, 1, 16), fontData.GlyphDictionary[' '].UV);
    Assert.AreEqual(7.34875f, fontData.GlyphDictionary[' '].AdvanceWidth);
}
[Test, CloseAfterFirstFrame]
public void GetGlyphDrawAreaAndUVs()
{
    var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
    fontData.Generate("", HorizontalAlignment.Center);
    Assert.AreEqual(0, fontData.Glyphs.Length);
    fontData.Generate("\n", HorizontalAlignment.Center);
    Assert.AreEqual(0, fontData.Glyphs.Length);
    fontData.Generate(" ", HorizontalAlignment.Center);
    Assert.AreEqual(1, fontData.Glyphs.Length);
    GlyphDrawData glyphA = fontData.Glyphs[0];
    Assert.AreEqual(glyphA.UV,
        Rectangle.BuildUVRectangle(new Rectangle(0, 0, 1, 16), new Size(128, 128)));
    Assert.AreEqual(new Rectangle(0, 0, 1, 16), glyphA.DrawArea);
}
[Test, CloseAfterFirstFrame]
public void GetGlyphsForMultilineText()
{
    var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
    fontData.Generate(" \n \n ", HorizontalAlignment.Center);
    Assert.AreEqual(3, fontData.Glyphs.Length);
}
See Also