Browse Source

ensure pen code path is tested

af/merge-core
Scott Williams 8 years ago
parent
commit
121f1edce6
  1. 2
      src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs
  2. 30
      tests/ImageSharp.Tests/Drawing/Text/DrawTextOnImageTests.cs
  3. 2
      tests/Images/External

2
src/ImageSharp.Drawing/Processing/Text/Processors/DrawTextProcessor.cs

@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Processing.Text.Processors
{
this.fillRegionProcessor = new FillRegionProcessor<TPixel>()
{
Brush = this.Brush,
Brush = this.Pen.StrokeFill,
Options = pathOptions
};
}

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

@ -18,6 +18,7 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
using System.Linq;
using System.Text;
using SixLabors.ImageSharp.Processing.Drawing.Brushes.GradientBrushes;
using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Primitives;
[GroupOutput("Drawing/Text")]
@ -101,6 +102,35 @@ namespace SixLabors.ImageSharp.Tests.Drawing.Text
false);
}
[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)]
[WithSolidFilledImages(400, 40, "White", PixelTypes.Rgba32, 20, 0, 0, "OpenSans-Regular.ttf", TestText)]
[WithSolidFilledImages(1100, 200, "White", PixelTypes.Rgba32, 50, 150, 100, "OpenSans-Regular.ttf", TestText)]
public void FontShapesAreRenderedCorrectlyWithAPen<TPixel>(
TestImageProvider<TPixel> provider,
int fontSize,
int x,
int y,
string fontName,
string text)
where TPixel : struct, IPixel<TPixel>
{
Font font = CreateFont(fontName, fontSize);
string fnDisplayText = text.Replace("\n", "");
fnDisplayText = fnDisplayText.Substring(0, Math.Min(fnDisplayText.Length, 4));
TPixel color = NamedColors<TPixel>.Black;
provider.VerifyOperation(
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})",
appendPixelTypeToFileName: false,
appendSourceFileOrDescription: true);
}
private static string Repeat(string str, int times) => string.Concat(Enumerable.Repeat(str, times));
private static Font CreateFont(string fontName, int size)

2
tests/Images/External

@ -1 +1 @@
Subproject commit 443db93ffdb175dd0ef67eb8f0c525cc9ad59083
Subproject commit 07cdbcfca121081eae97d6a9cd0e230c653eeb39
Loading…
Cancel
Save