FontDataTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Rendering2D.Fonts.Tests FontDataTests

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

public class FontDataTests : TestWithMocksOrVisually

The FontDataTests type exposes the following members.

Constructors

  NameDescription
Public methodFontDataTests
Initializes a new instance of the FontDataTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodGetGlyphDrawAreaAndUVs
Public methodGetGlyphsForMultilineText
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLoadFontData
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodToStringTest
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[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);
}
[Test, CloseAfterFirstFrame]
public void ToStringTest()
{
    var fontDataType = typeof(FontDescription);
    var expected = fontDataType.Namespace + "." + fontDataType.Name +
        ", Font Family=Verdana, Font Size=12";
    var fontData = new FontDescription(ContentLoader.Load<Font>("Verdana12").Data);
    Assert.AreEqual(expected, fontData.ToString());
}
See Also