@@ -204,6 +204,61 @@ public void FontShapesAreRenderedCorrectly_LargeText<TPixel>(
204204 false ) ;
205205 }
206206
207+ [ Theory ]
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 ) ]
214+ public void FontShapesAreRenderedCorrectly_WithLineSpacing < TPixel > (
215+ TestImageProvider < TPixel > provider ,
216+ float lineSpacing ,
217+ int lineCount ,
218+ bool wrap )
219+ where TPixel : unmanaged, IPixel < TPixel >
220+ {
221+ Font font = CreateFont ( "OpenSans-Regular.ttf" , 16 ) ;
222+
223+ var sb = new StringBuilder ( ) ;
224+ string str = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna." ;
225+
226+ for ( int i = 0 ; i < lineCount ; i ++ )
227+ {
228+ sb . AppendLine ( str ) ;
229+ }
230+
231+ var textOptions = new TextOptions
232+ {
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
247+ } ;
248+
249+ Color color = Color . Black ;
250+
251+ // NET472 is 0.0002 different.
252+ var comparer = ImageComparer . TolerantPercentage ( 0.0003f ) ;
253+
254+ provider . VerifyOperation (
255+ comparer ,
256+ img => img . Mutate ( c => c . DrawText ( textGraphicsOptions , sb . ToString ( ) , font , color , new PointF ( 10 , 1 ) ) ) ,
257+ $ "linespacing_{ lineSpacing } _linecount_{ lineCount } _wrap_{ wrap } ",
258+ false ,
259+ false ) ;
260+ }
261+
207262 [ Theory ]
208263 [ WithSolidFilledImages ( 200 , 150 , "White" , PixelTypes . Rgba32 , 50 , 0 , 0 , "SixLaborsSampleAB.woff" , AB ) ]
209264 [ WithSolidFilledImages ( 900 , 150 , "White" , PixelTypes . Rgba32 , 50 , 0 , 0 , "OpenSans-Regular.ttf" , TestText ) ]
0 commit comments