Skip to content

Commit 92a4f32

Browse files
Merge pull request #407 from SixLabors/js/fix-400-whitespace-trim
Ensure only trailing whitespace is trimmed.
2 parents a47bb5d + b0c5765 commit 92a4f32

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/SixLabors.Fonts/TextLayout.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,7 +1396,7 @@ private void TrimTrailingWhitespaceAndRecalculateMetrics()
13961396
index--;
13971397
}
13981398

1399-
if (index < this.data.Count)
1399+
if (index < this.data.Count && index != 0)
14001400
{
14011401
this.data.RemoveRange(index, this.data.Count - index);
14021402
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Six Labors Split License.
3+
4+
namespace SixLabors.Fonts.Tests.Issues;
5+
public class Issues_400
6+
{
7+
[Fact]
8+
public void RenderingTextIncludesAllGlyphs()
9+
{
10+
#if OS_WINDOWS
11+
12+
TextOptions options = new(new Font(SystemFonts.Get("Arial"), 16 * 2))
13+
{
14+
WrappingLength = 1900
15+
};
16+
17+
const string content = """
18+
NEWS_CATEGORY=EWF&NEWS_HASH=4b298ff9277ef9fdf515356be95ea3caf57cd36&OFFSET=0&SEARCH_VALUE=CA88105E1088&ID_NEWS
19+
""";
20+
21+
int lineCount = TextMeasurer.CountLines(content, options);
22+
Assert.Equal(2, lineCount);
23+
#endif
24+
}
25+
}

tests/SixLabors.Fonts.Tests/SixLabors.Fonts.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<DebugSymbols>True</DebugSymbols>
55
<Platforms>AnyCPU;x64;x86</Platforms>
6+
<LangVersion>11</LangVersion>
67
</PropertyGroup>
78

89
<PropertyGroup>

0 commit comments

Comments
 (0)