public void TestRemoveCharacterAdjustsCharactersBaselineOfRelevantLine() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("a"); builder.AddNewLine(); builder.AddText("ab"); builder.AddNewLine(); builder.AddText("abm"); builder.RemoveLastCharacter(); assertOtherCharactersNotAffected(); Assert.That(builder.Characters[3].DrawRectangle.Top, Is.EqualTo(font_size * 2 + y_offset + (b_baseline - baseline))); Assert.That(builder.Characters[4].DrawRectangle.Top, Is.EqualTo(font_size * 2 + b_y_offset)); builder.RemoveLastCharacter(); assertOtherCharactersNotAffected(); Assert.That(builder.Characters[3].DrawRectangle.Top, Is.EqualTo(font_size * 2 + y_offset)); void assertOtherCharactersNotAffected() { Assert.That(builder.Characters[0].DrawRectangle.Top, Is.EqualTo(y_offset)); Assert.That(builder.Characters[1].DrawRectangle.Top, Is.EqualTo(font_size + y_offset + (b_baseline - baseline))); Assert.That(builder.Characters[2].DrawRectangle.Top, Is.EqualTo(font_size + b_y_offset)); } }
public void TestNewLineOnEmptyLineOffsetsPositionByFontSize() { var builder = new TextBuilder(fontStore, normal_font); builder.AddNewLine(); builder.AddNewLine(); builder.AddText("a"); Assert.That(builder.Characters[0].DrawRectangle.Top, Is.EqualTo(y_offset + y_offset)); }
public void TestLineBaseHeightThrowsOnMultiline() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("a"); builder.AddNewLine(); builder.AddText("b"); Assert.Throws <InvalidOperationException>(() => _ = builder.LineBaseHeight); }
public void TestFirstCharacterOnNewLineHasNoKerning() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("a"); builder.AddNewLine(); builder.AddText("a"); Assert.That(builder.Characters[1].DrawRectangle.Left, Is.EqualTo(x_offset)); }
public void TestFirstCharacterOnNewLineIsOnNewLine() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("a"); builder.AddNewLine(); builder.AddText("a"); Assert.That(builder.Characters[1].OnNewLine, Is.True); }
public void TestNewLineUsesFontHeightWhenUsingFontHeightAsSize() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("a"); builder.AddText("b"); builder.AddNewLine(); builder.AddText("a"); Assert.That(builder.Characters[2].DrawRectangle.Top, Is.EqualTo(font_size + y_offset)); }
public void TestRemoveFirstCharacterOnNewlineDoesntAffectLastLineAlignment() { var builder = new TextBuilder(fontStore, normal_font); builder.AddText("ab"); builder.AddNewLine(); builder.AddText("m"); builder.RemoveLastCharacter(); Assert.That(builder.Characters[0].DrawRectangle.Top, Is.EqualTo(y_offset + (b_baseline - baseline))); Assert.That(builder.Characters[1].DrawRectangle.Top, Is.EqualTo(b_y_offset)); }
public void TestNewLineUsesGlyphHeightWhenNotUsingFontHeightAsSize() { var builder = new TextBuilder(fontStore, normal_font, useFontSizeAsHeight: false); builder.AddText("a"); builder.AddText("b"); builder.AddNewLine(); builder.AddText("a"); // b is the larger glyph Assert.That(builder.Characters[2].DrawRectangle.Top, Is.EqualTo(b_y_offset + b_height + y_offset)); }
public void TestSpacingAdded() { var builder = new TextBuilder(fontStore, normal_font, spacing: spacing); builder.AddText("a"); builder.AddText("a"); builder.AddNewLine(); builder.AddText("a"); Assert.That(builder.Characters[0].DrawRectangle.Left, Is.EqualTo(x_offset)); Assert.That(builder.Characters[1].DrawRectangle.Left, Is.EqualTo(x_advance + spacing.X + kerning + x_offset)); Assert.That(builder.Characters[2].DrawRectangle.Left, Is.EqualTo(x_offset)); Assert.That(builder.Characters[2].DrawRectangle.Top, Is.EqualTo(font_size + spacing.Y + y_offset)); }
public void TestRemoveCharacterOnNewLineRemovesCharacterAndLine() { var builder = new TextBuilder(fontStore, normal_font, spacing: spacing); builder.AddText("a"); builder.AddNewLine(); builder.AddText("a"); builder.RemoveLastCharacter(); Assert.That(builder.Bounds, Is.EqualTo(new Vector2(x_advance, font_size))); builder.AddText("a"); Assert.That(builder.Characters[1].DrawRectangle.TopLeft, Is.EqualTo(new Vector2(x_advance + spacing.X + kerning + x_offset, y_offset))); Assert.That(builder.Bounds, Is.EqualTo(new Vector2(x_advance + spacing.X + kerning + x_advance, font_size))); }