Skip to content

Commit

Permalink
Update missed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JimBobSquarePants committed Oct 28, 2024
1 parent f1defa1 commit caaf901
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions tests/SixLabors.Fonts.Tests/Issues/Issues_269.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ namespace SixLabors.Fonts.Tests.Issues;

public class Issues_269
{
private static readonly ApproximateFloatComparer Comparer = new(.1F);

[Fact]
public void CorrectlySetsMetricsForFontsNotAdheringToSpec()
{
// AliceFrancesHMK has invalid subtables.
Font font = new FontCollection().Add(TestFonts.AliceFrancesHMKRegularFile).CreateFont(25);

FontRectangle size = TextMeasurer.MeasureSize("H", new TextOptions(font));
Assert.Equal(32, size.Width, 1F);
Assert.Equal(25, size.Height, 1F);
Assert.Equal(30.6000004F, size.Width, Comparer);
Assert.Equal(24.75F, size.Height, Comparer);
}
}
10 changes: 6 additions & 4 deletions tests/SixLabors.Fonts.Tests/Issues/Issues_367.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
namespace SixLabors.Fonts.Tests.Issues;
public class Issues_367
{
private static readonly ApproximateFloatComparer Comparer = new(.1F);

[Fact]
public void ShouldMatchBrowserBreak()
{
Font font = new FontCollection().Add(TestFonts.CourierPrimeFile).CreateFont(12);

TextOptions options = new(font)
{
Dpi = 96f // 1in = 96px
Dpi = 96F // 1in = 96px
};

const float wrappingLengthInInches = 3.875f;
const float wrappingLengthInInches = 3.875F;
options.WrappingLength = wrappingLengthInInches * options.Dpi;

const string text = "Leer, but lonesome has fussin' change a faith. Themself seen and four trample.";
Expand All @@ -23,7 +25,7 @@ public void ShouldMatchBrowserBreak()
Assert.Equal(3, lineCount);

FontRectangle advance = TextMeasurer.MeasureAdvance(text, options);
Assert.Equal(355, advance.Width);
Assert.Equal(48, advance.Height);
Assert.Equal(354.968658F, advance.Width, Comparer);
Assert.Equal(48, advance.Height, Comparer);
}
}

0 comments on commit caaf901

Please sign in to comment.