Skip to content

Commit a1dc5a0

Browse files
committed
updated tests as per JimBobSquarePants PR review
1 parent 090c68e commit a1dc5a0

7 files changed

Lines changed: 66 additions & 83 deletions

tests/ImageSharp.Drawing.Tests/Drawing/Text/DrawTextOnImageTests.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,60 @@ public void CanDrawTextWithEmptyPath()
439439
Vector2.Zero));
440440
}
441441

442+
[Theory]
443+
[WithSolidFilledImages(300, 200, nameof(Color.White), PixelTypes.Rgba32, TestFonts.OpenSans, 32, 75F)]
444+
[WithSolidFilledImages(300, 200, nameof(Color.White), PixelTypes.Rgba32, TestFonts.OpenSans, 40, 90F)]
445+
public void CanRotateFilledFont_Issue175<TPixel>(
446+
TestImageProvider<TPixel> provider,
447+
string fontName,
448+
int fontSize,
449+
float angle)
450+
where TPixel : unmanaged, IPixel<TPixel>
451+
{
452+
Font font = CreateFont(fontName, fontSize);
453+
const string text = "QuickTYZ";
454+
AffineTransformBuilder builder = new AffineTransformBuilder().AppendRotationDegrees(angle);
455+
456+
TextOptions textOptions = new(font);
457+
FontRectangle bounds = TextMeasurer.Measure(text, textOptions);
458+
Matrix3x2 transform = builder.BuildMatrix(Rectangle.Round(new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height)));
459+
460+
provider.RunValidatingProcessorTest(
461+
x => x.SetDrawingTransform(transform).DrawText(textOptions, text, Color.Black),
462+
$"F({fontName})-S({fontSize})-A({angle})-{ToTestOutputDisplayText(text)})",
463+
TextDrawingComparer,
464+
appendPixelTypeToFileName: false,
465+
appendSourceFileOrDescription: true);
466+
}
467+
468+
[Theory]
469+
[WithSolidFilledImages(300, 200, nameof(Color.White), PixelTypes.Rgba32, TestFonts.OpenSans, 32, 75F, 1)]
470+
[WithSolidFilledImages(300, 200, nameof(Color.White), PixelTypes.Rgba32, TestFonts.OpenSans, 40, 90F, 2)]
471+
public void CanRotateOutlineFont_Issue175<TPixel>(
472+
TestImageProvider<TPixel> provider,
473+
string fontName,
474+
int fontSize,
475+
float angle,
476+
int strokeWidth)
477+
where TPixel : unmanaged, IPixel<TPixel>
478+
{
479+
Font font = CreateFont(fontName, fontSize);
480+
const string text = "QuickTYZ";
481+
AffineTransformBuilder builder = new AffineTransformBuilder().AppendRotationDegrees(angle);
482+
483+
TextOptions textOptions = new(font);
484+
FontRectangle bounds = TextMeasurer.Measure(text, textOptions);
485+
Matrix3x2 transform = builder.BuildMatrix(Rectangle.Round(new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height)));
486+
487+
provider.RunValidatingProcessorTest(
488+
x => x.SetDrawingTransform(transform)
489+
.DrawText(textOptions, text, Pens.Solid(Color.Black, strokeWidth)),
490+
$"F({fontName})-S({fontSize})-A({angle})-STR({strokeWidth})-{ToTestOutputDisplayText(text)})",
491+
TextDrawingComparer,
492+
appendPixelTypeToFileName: false,
493+
appendSourceFileOrDescription: true);
494+
}
495+
442496
private static string Repeat(string str, int times) => string.Concat(Enumerable.Repeat(str, times));
443497

444498
private static string ToTestOutputDisplayText(string text)

tests/ImageSharp.Drawing.Tests/Issues/Issue_175.cs

Lines changed: 0 additions & 79 deletions
This file was deleted.

tests/ImageSharp.Drawing.Tests/TestImages.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,6 @@ public static class Png
9090
public const string Issue1014_5 = "Png/issues/Issue_1014_5.png";
9191
public const string Issue1014_6 = "Png/issues/Issue_1014_6.png";
9292

93-
// Issue 175: https://github.com/SixLabors/ImageSharp.Drawing/issues/175
94-
public const string Issue175Filled = "Png/issues/issue175_filled.png";
95-
public const string Issue175Outlined = "Png/issues/issue175_outlined.png";
96-
9793
public static class Bad
9894
{
9995
// Odd chunk lengths
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)