TextWrapper ClassDelta Engine Documentation
Wraps a string of text introducing line breaks between words where possible. View code on GitHub
Inheritance Hierarchy

System Object
  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

public class TextWrapper

The TextWrapper type exposes the following members.

Constructors

  NameDescription
Public methodTextWrapper
Initializes a new instance of the TextWrapper class
Top
Methods

  NameDescription
Public methodGetFontHeight
Public methodSplitTextIntoLines
Top
Properties

  NameDescription
Public propertyMaxTextLineWidth
Public propertyTextLineWidths
Top
Remarks

Tests: DeltaEngine.Rendering2D.Fonts.Tests.TextWrapperTests
Examples

6 unit tests call DeltaEngine.Rendering2D.Fonts.TextWrapper
[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