Skip to content

Commit

Permalink
Merge pull request #407 from SixLabors/js/fix-400-whitespace-trim
Browse files Browse the repository at this point in the history
Ensure only trailing whitespace is trimmed.
  • Loading branch information
JimBobSquarePants authored Jun 28, 2024
2 parents a47bb5d + b0c5765 commit 92a4f32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SixLabors.Fonts/TextLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,7 @@ private void TrimTrailingWhitespaceAndRecalculateMetrics()
index--;
}

if (index < this.data.Count)
if (index < this.data.Count && index != 0)
{
this.data.RemoveRange(index, this.data.Count - index);
}
Expand Down
25 changes: 25 additions & 0 deletions tests/SixLabors.Fonts.Tests/Issues/Issues_400.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.

namespace SixLabors.Fonts.Tests.Issues;
public class Issues_400
{
[Fact]
public void RenderingTextIncludesAllGlyphs()
{
#if OS_WINDOWS

TextOptions options = new(new Font(SystemFonts.Get("Arial"), 16 * 2))
{
WrappingLength = 1900
};

const string content = """
NEWS_CATEGORY=EWF&NEWS_HASH=4b298ff9277ef9fdf515356be95ea3caf57cd36&OFFSET=0&SEARCH_VALUE=CA88105E1088&ID_NEWS
""";

int lineCount = TextMeasurer.CountLines(content, options);
Assert.Equal(2, lineCount);
#endif
}
}
1 change: 1 addition & 0 deletions tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PropertyGroup>
<DebugSymbols>True</DebugSymbols>
<Platforms>AnyCPU;x64;x86</Platforms>
<LangVersion>11</LangVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 92a4f32

Please sign in to comment.