diff --git a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs index 6922213f21..ef6dc40f03 100644 --- a/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs +++ b/tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs @@ -34,6 +34,8 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text private const string TestText2 = "THISISTESTWORDS "; + public static ImageComparer TextDrawingComparer = ImageComparer.TolerantPercentage(0.01f); + [Theory] [WithSolidFilledImages(200, 100, "White", PixelTypes.Rgba32, 50, 0, 0, "SixLaborsSampleAB.woff", AB)] [WithSolidFilledImages(900, 100, "White", PixelTypes.Rgba32, 50, 0, 0, "OpenSans-Regular.ttf", TestText)] @@ -49,17 +51,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont(fontName, fontSize); - string fnDisplayText = text.Replace("\n", ""); - fnDisplayText = fnDisplayText.Substring(0, Math.Min(fnDisplayText.Length, 4)); TPixel color = NamedColors.Black; provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { img.Mutate(c => c.DrawText(text, new Font(font, fontSize), color, new PointF(x, y))); }, - $"{fontName}-{fontSize}-{fnDisplayText}-({x},{y})", + $"{fontName}-{fontSize}-{ToTestOutputDisplayText(text)}-({x},{y})", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); } @@ -98,7 +98,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text TPixel color = NamedColors.Black; provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { img.Mutate(c => c.DrawText(textOptions, sb.ToString(), font, color, new PointF(10, 5))); @@ -121,17 +121,15 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text where TPixel : struct, IPixel { Font font = CreateFont(fontName, fontSize); - string fnDisplayText = text.Replace("\n", ""); - fnDisplayText = fnDisplayText.Substring(0, Math.Min(fnDisplayText.Length, 4)); TPixel color = NamedColors.Black; provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { img.Mutate(c => c.DrawText(text, new Font(font, fontSize), null, Pens.Solid(color, 1), new PointF(x, y))); }, - $"pen_{fontName}-{fontSize}-{fnDisplayText}-({x},{y})", + $"pen_{fontName}-{fontSize}-{ToTestOutputDisplayText(text)}-({x},{y})", appendPixelTypeToFileName: false, appendSourceFileOrDescription: true); } @@ -153,7 +151,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text TPixel color = NamedColors.Black; provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { img.Mutate(c => c.DrawText(text, new Font(font, fontSize), null, Pens.DashDot(color, 3), new PointF(x, y))); @@ -180,7 +178,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text IPen outlinePen = Pens.DashDot(colorOutline, 3); provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { IPath path = new Path(new LinearLineSegment(new Point(0, img.Height), new Point(img.Width, 0))); @@ -214,13 +212,12 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text string text) where TPixel : struct, IPixel { - Font font = CreateFont(fontName, fontSize); TPixel colorFill = NamedColors.Black; IBrush fillBrush = Brushes.Solid(colorFill); provider.VerifyOperation( - ImageComparer.Tolerant(imageThreshold: 0.1f, perPixelManhattanThreshold: 20), + TextDrawingComparer, img => { int w = (int)(img.Width * 0.6); diff --git a/tests/Images/External b/tests/Images/External index 83f6cbab9a..0e6407be70 160000 --- a/tests/Images/External +++ b/tests/Images/External @@ -1 +1 @@ -Subproject commit 83f6cbab9a08b550c84bf931c95188341140516a +Subproject commit 0e6407be7081341526f815a4d70e7912db276a98