Skip to content

Commit

Permalink
avoid linq for creating glyph and advances array fix test names
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlm committed Nov 10, 2024
1 parent 14ae365 commit cbb342e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/Consolonia.Core/Text/GlyphTypeface.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using Avalonia.Media;
using Consolonia.Core.Drawing;

Expand Down Expand Up @@ -41,7 +40,9 @@ public bool TryGetGlyph(uint codepoint, out ushort glyph)

public ushort[] GetGlyphs(ReadOnlySpan<uint> codepoints)
{
return Enumerable.Repeat(Glyph, codepoints.Length).ToArray();
ushort[] glyphs = new ushort[codepoints.Length];
Array.Fill(glyphs, Glyph);
return glyphs;
}

public int GetGlyphAdvance(ushort glyph)
Expand All @@ -51,7 +52,9 @@ public int GetGlyphAdvance(ushort glyph)

public int[] GetGlyphAdvances(ReadOnlySpan<ushort> glyphs)
{
return Enumerable.Repeat(1, glyphs.Length).ToArray();
int[] advances = new int[glyphs.Length];
Array.Fill(advances, 1);
return advances;
}

public bool TryGetTable(uint tag, out byte[] table)
Expand Down
10 changes: 5 additions & 5 deletions src/Tests/Consolonia.Gallery.Tests/TextBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace Consolonia.Gallery.Tests
internal class TextBlockTests : GalleryTestsBaseBase
{
[Test]
public async Task TextBlock_DisplaysBasicText()
public async Task DisplaysBasicText()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText("This is TextBlock");
}

[Test]
public async Task TextBlock_HandlesTrimming()
public async Task HandlesTrimming()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText(
Expand All @@ -29,7 +29,7 @@ await UITest.AssertHasText(
}

[Test]
public async Task TextBlock_HandlesAlignment()
public async Task HandlesAlignment()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText(
Expand All @@ -39,7 +39,7 @@ await UITest.AssertHasText(
}

[Test]
public async Task TextBlock_HandlesMultilineText()
public async Task HandlesMultilineText()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText(
Expand All @@ -48,7 +48,7 @@ await UITest.AssertHasText(
}

[Test]
public async Task TextBlock_HandlesSpecialCharacters()
public async Task HandlesSpecialCharacters()
{
await UITest.KeyInput(Key.Tab);
await UITest.AssertHasText(
Expand Down

0 comments on commit cbb342e

Please sign in to comment.