File tree Expand file tree Collapse file tree
tests/ImageSharp.Drawing.Tests/Shapes Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments