Wraps a string of text introducing line breaks between words where possible.
View code on GitHub
Inheritance Hierarchy
DeltaEngine.Rendering2D.Fonts TextWrapper
Namespace: DeltaEngine.Rendering2D.Fonts
Assembly: DeltaEngine.Rendering2D.Fonts (in DeltaEngine.Rendering2D.Fonts.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The TextWrapper type exposes the following members.
Constructors
Name | Description | |
---|---|---|
TextWrapper | Initializes a new instance of the TextWrapper class |
Methods
Name | Description | |
---|---|---|
GetFontHeight | ||
SplitTextIntoLines |
Properties
Name | Description | |
---|---|---|
MaxTextLineWidth | ||
TextLineWidths |
Remarks
Examples
[Test] public void EmptyText() { var lines = textWrapper.SplitTextIntoLines("", new Size(100, fontDescription.PixelLineHeight), true); Assert.AreEqual(0, lines.Count); }
[Test] public void FontDoesNotFitInTooSmallArea() { var lines = textWrapper.SplitTextIntoLines(ThreeLineText, new Size(70, fontDescription.PixelLineHeight / 2.0f), true); Assert.AreEqual(0, lines.Count); }
[Test] public void GetLines() { var lines = textWrapper.SplitTextIntoLines(ThreeLineText, new Size(70, fontDescription.PixelLineHeight * 3), true); Assert.AreEqual(3, lines.Count); Assert.AreEqual(Spaces, new string(lines[0].ToArray())); Assert.AreEqual(Spaces, new string(lines[1].ToArray())); Assert.AreEqual(Spaces, new string(lines[2].ToArray())); }
See Also