Holds the image and data for rendering a smoothly drawn font.
View code on GitHub
Inheritance Hierarchy
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
The Font type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Font | Initializes a new instance of the Font class |
Methods
Name | Description | |
---|---|---|
CreateDefault | (Overrides ContentData CreateDefault .) | |
Dispose | (Inherited from ContentData.) | |
DisposeData | (Overrides XmlContent DisposeData .) | |
InitializeDescriptionAndMaterial | ||
InternalCreateDefault | (Inherited from ContentData.) | |
LoadData | (Overrides XmlContent LoadData(Stream).) | |
ToString | (Inherited from ContentData.) |
Fields
Name | Description | |
---|---|---|
ContentChanged | (Inherited from ContentData.) |
Properties
Name | Description | |
---|---|---|
AllowCreationIfContentNotFound | (Overrides ContentData AllowCreationIfContentNotFound.) | |
Data | (Inherited from XmlContent.) | |
Default | ||
IsDisposed | (Inherited from ContentData.) | |
MetaData | (Inherited from ContentData.) | |
Name | (Inherited from ContentData.) |
Remarks
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); }
See Also