Skip to content

Commit 0ddc366

Browse files
Test wrap/nowrap
1 parent c40576e commit 0ddc366

9 files changed

Lines changed: 25 additions & 15 deletions

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

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,17 @@ public void FontShapesAreRenderedCorrectly_LargeText<TPixel>(
205205
}
206206

207207
[Theory]
208-
[WithSolidFilledImages(400, 600, "White", PixelTypes.Rgba32, 1, 5)]
209-
[WithSolidFilledImages(400, 600, "White", PixelTypes.Rgba32, 1.5, 3)]
210-
[WithSolidFilledImages(400, 600, "White", PixelTypes.Rgba32, 2, 2)]
208+
[WithSolidFilledImages(400, 550, "White", PixelTypes.Rgba32, 1, 5, true)]
209+
[WithSolidFilledImages(400, 550, "White", PixelTypes.Rgba32, 1.5, 3, true)]
210+
[WithSolidFilledImages(400, 550, "White", PixelTypes.Rgba32, 2, 2, true)]
211+
[WithSolidFilledImages(400, 100, "White", PixelTypes.Rgba32, 1, 5, false)]
212+
[WithSolidFilledImages(400, 100, "White", PixelTypes.Rgba32, 1.5, 3, false)]
213+
[WithSolidFilledImages(400, 100, "White", PixelTypes.Rgba32, 2, 2, false)]
211214
public void FontShapesAreRenderedCorrectly_WithLineSpacing<TPixel>(
212215
TestImageProvider<TPixel> provider,
213216
float lineSpacing,
214-
int lineCount)
217+
int lineCount,
218+
bool wrap)
215219
where TPixel : unmanaged, IPixel<TPixel>
216220
{
217221
Font font = CreateFont("OpenSans-Regular.ttf", 16);
@@ -224,16 +228,22 @@ public void FontShapesAreRenderedCorrectly_WithLineSpacing<TPixel>(
224228
sb.AppendLine(str);
225229
}
226230

227-
var textOptions = new TextGraphicsOptions
231+
var textOptions = new TextOptions
228232
{
229-
TextOptions =
230-
{
231-
ApplyKerning = true,
232-
VerticalAlignment = VerticalAlignment.Top,
233-
HorizontalAlignment = HorizontalAlignment.Left,
234-
LineSpacing = lineSpacing,
235-
WrapTextWidth = 300
236-
}
233+
ApplyKerning = true,
234+
VerticalAlignment = VerticalAlignment.Top,
235+
HorizontalAlignment = HorizontalAlignment.Left,
236+
LineSpacing = lineSpacing
237+
};
238+
239+
if (wrap)
240+
{
241+
textOptions.WrapTextWidth = 300;
242+
}
243+
244+
var textGraphicsOptions = new TextGraphicsOptions
245+
{
246+
TextOptions = textOptions
237247
};
238248

239249
Color color = Color.Black;
@@ -243,8 +253,8 @@ public void FontShapesAreRenderedCorrectly_WithLineSpacing<TPixel>(
243253

244254
provider.VerifyOperation(
245255
comparer,
246-
img => img.Mutate(c => c.DrawText(textOptions, sb.ToString(), font, color, new PointF(10, 1))),
247-
$"linespacing_{lineSpacing}_linecount_{lineCount}",
256+
img => img.Mutate(c => c.DrawText(textGraphicsOptions, sb.ToString(), font, color, new PointF(10, 1))),
257+
$"linespacing_{lineSpacing}_linecount_{lineCount}_wrap_{wrap}",
248258
false,
249259
false);
250260
}
Loading
Loading
Loading

tests/Images/ReferenceOutput/Drawing/Text/DrawTextOnImageTests/FontShapesAreRenderedCorrectly_WithLineSpacing_linespacing_1_linecount_5.png renamed to tests/Images/ReferenceOutput/Drawing/Text/DrawTextOnImageTests/FontShapesAreRenderedCorrectly_WithLineSpacing_linespacing_1_linecount_5_wrap_True.png

77.8 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)