-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #420 from SixLabors/js/fix-412
Always create new text run, don't assume behavior.
- Loading branch information
Showing
2 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
namespace SixLabors.Fonts.Tests.Issues; | ||
|
||
public class Issues_412 | ||
{ | ||
[Fact] | ||
public void ShouldCreateCorrectTextRunCount() | ||
{ | ||
FontCollection collection = new(); | ||
FontFamily family = collection.Add(TestFonts.OpenSansFile); | ||
Font font = family.CreateFont(24); | ||
|
||
TextOptions options = new(font) | ||
{ | ||
TextRuns = new[] | ||
{ | ||
new TextRun { Start = 0, End = 4 } | ||
} | ||
}; | ||
|
||
IReadOnlyList<TextRun> runs = TextLayout.BuildTextRuns("abcde", options); | ||
Assert.Equal(2, runs.Count); | ||
|
||
TextRun run = runs[0]; | ||
Assert.Equal(0, run.Start); | ||
Assert.Equal(4, run.End); | ||
|
||
run = runs[1]; | ||
Assert.Equal(4, run.Start); | ||
Assert.Equal(5, run.End); | ||
} | ||
} |