Fix @ being used in figlet font

This commit is contained in:
Salvage 2022-09-21 19:03:11 +02:00 committed by Patrik Svensson
parent fd8d271a10
commit 999c59909b
6 changed files with 1261 additions and 5 deletions

View File

@ -35,7 +35,7 @@ internal static class FigletFontParser
throw new InvalidOperationException("Unknown index for FIGlet character");
}
buffer.Add(line.Replace(header.Hardblank, ' ').ReplaceExact("@", string.Empty));
buffer.Add(line.Replace(header.Hardblank, ' ').TrimEnd('@'));
if (line.EndsWith("@@", StringComparison.Ordinal))
{

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@

@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@ @@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@@@@@@
@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@ @@@ @@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@@
@@! @@@ @@! @@@ @@! @@! @@@ @@! @@! !@@ @@! @@! @@! @@! @@@ !@@ @@! @@@ @@! @@! @@@ @@!
!@! @!@ !@! @!@ !@! !@! @!@ !@! !@! @!! !@! !@! !@! !@! @!@ !@! !@! @!@ !@! !@! @!@ !@!
@!@@!@! @!@!@!@! @!! @!@!!@! !!@ @!@@!@! @!! !!@ @!@ @!@!@!@! !!@@!! @!@!@!@! @!!!:! @!@!!@! @!!!:!
!!@!!! !!!@!!!! !!! !!@!@! !!! !!@!!! !@! !!! !@! !!!@!!!! !!@!!! !!!@!!!! !!!!!: !!@!@! !!!!!:
!!: !!: !!! !!: !!: :!! !!: !!: :!! !!: !!: !!: !!: !!! !:! !!: !!! !!: !!: :!! !!:
:!: :!: !:! :!: :!: !:! :!: :!: !:! :!: :!: :!: :!: !:! !:! :!: !:! :!: :!: !:! :!:
:: :: ::: :: :: ::: :: :: ::: :::: :: ::: :: ::: :::: :: :: ::: :: :::: :: ::: :: ::::
: : : : : : : : : : ::: :: : : : : : : :: : : : : : : :: :: : : : : :: ::

View File

@ -9,6 +9,8 @@
<AdditionalFiles Include="..\..\src\stylecop.json" Link="Properties/stylecop.json" />
<None Remove="Data\starwars.flf" />
<EmbeddedResource Include="Data\starwars.flf" />
<None Remove="Data\poison.flf" />
<EmbeddedResource Include="Data\poison.flf" />
</ItemGroup>
<ItemGroup>

View File

@ -4,20 +4,23 @@ namespace Spectre.Console.Tests.Unit;
[ExpectationPath("Widgets/Figlet")]
public sealed class FigletTests
{
[Fact]
[Theory]
[InlineData("starwars.flf")]
[InlineData("poison.flf")]
[Expectation("Load_Stream")]
public async Task Should_Load_Font_From_Stream()
public async Task Should_Load_Font_From_Stream(string fontfile)
{
// Given
var console = new TestConsole().Width(180);
var font = FigletFont.Load(EmbeddedResourceReader.LoadResourceStream("Spectre.Console.Tests/Data/starwars.flf"));
var font = FigletFont.Load(EmbeddedResourceReader.LoadResourceStream($"Spectre.Console.Tests/Data/{fontfile}"));
var text = new FigletText(font, "Patrik was here");
// When
console.Write(text);
// Then
await Verifier.Verify(console.Output);
await Verifier.Verify(console.Output)
.UseParameters(fontfile);
}
[Fact]