Skip to content

Commit 2abbe4f

Browse files
Add unit test
1 parent 8507f95 commit 2abbe4f

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Six Labors.
2+
// Licensed under the Apache License, Version 2.0.
3+
4+
using System.Numerics;
5+
using SixLabors.Fonts;
6+
using Xunit;
7+
8+
namespace SixLabors.ImageSharp.Drawing.Tests.Shapes
9+
{
10+
public class TextBuilderTests
11+
{
12+
[Fact]
13+
public void TextBuilder_Bounds_AreCorrect()
14+
{
15+
Vector2 position = new(5, 5);
16+
var options = new TextOptions(TestFontUtilities.GetFont(TestFonts.OpenSans, 16))
17+
{
18+
Origin = position
19+
};
20+
21+
string text = "Hello World";
22+
23+
IPathCollection glyphs = TextBuilder.GenerateGlyphs(text, options);
24+
25+
RectangleF builderBounds = glyphs.Bounds;
26+
FontRectangle measuredBounds = TextMeasurer.MeasureBounds(text, options);
27+
28+
Assert.Equal(measuredBounds.X, builderBounds.X);
29+
Assert.Equal(measuredBounds.Y, builderBounds.Y);
30+
Assert.Equal(measuredBounds.Width, builderBounds.Width);
31+
Assert.Equal(measuredBounds.Height, builderBounds.Height);
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)