3
3
4
4
using System . Globalization ;
5
5
using System . Numerics ;
6
+ using System . Text ;
6
7
using SixLabors . Fonts . Tests . Fakes ;
7
8
using SixLabors . Fonts . Unicode ;
8
9
using SixLabors . ImageSharp . Drawing . Processing ;
@@ -289,11 +290,11 @@ public void MeasureTextWordWrappingHorizontalTopBottom(string text, float height
289
290
LayoutMode = LayoutMode . HorizontalTopBottom
290
291
} ;
291
292
292
- FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
293
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
293
294
295
+ FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
294
296
Assert . Equal ( width , size . Width , 4F ) ;
295
297
Assert . Equal ( height , size . Height , 4F ) ;
296
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
297
298
}
298
299
}
299
300
@@ -315,11 +316,12 @@ public void MeasureTextWordWrappingHorizontalBottomTop(string text, float height
315
316
LayoutMode = LayoutMode . HorizontalBottomTop
316
317
} ;
317
318
318
- FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
319
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
320
+
319
321
322
+ FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
320
323
Assert . Equal ( width , size . Width , 4F ) ;
321
324
Assert . Equal ( height , size . Height , 4F ) ;
322
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
323
325
}
324
326
}
325
327
@@ -338,11 +340,11 @@ public void MeasureTextWordWrappingVerticalLeftRight(string text, float height,
338
340
LayoutMode = LayoutMode . VerticalLeftRight
339
341
} ;
340
342
341
- FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
343
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
342
344
345
+ FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
343
346
Assert . Equal ( width , size . Width , 4F ) ;
344
347
Assert . Equal ( height , size . Height , 4F ) ;
345
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
346
348
}
347
349
}
348
350
@@ -361,11 +363,11 @@ public void MeasureTextWordWrappingVerticalRightLeft(string text, float height,
361
363
LayoutMode = LayoutMode . VerticalRightLeft
362
364
} ;
363
365
364
- FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
366
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
365
367
368
+ FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
366
369
Assert . Equal ( width , size . Width , 4F ) ;
367
370
Assert . Equal ( height , size . Height , 4F ) ;
368
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
369
371
}
370
372
}
371
373
@@ -384,11 +386,11 @@ public void MeasureTextWordWrappingVerticalMixedLeftRight(string text, float hei
384
386
LayoutMode = LayoutMode . VerticalMixedLeftRight
385
387
} ;
386
388
387
- FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
389
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
388
390
391
+ FontRectangle size = TextMeasurer . MeasureBounds ( text , options ) ;
389
392
Assert . Equal ( width , size . Width , 4F ) ;
390
393
Assert . Equal ( height , size . Height , 4F ) ;
391
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { height , width } ) ;
392
394
}
393
395
}
394
396
@@ -416,14 +418,11 @@ public void MeasureTextWordBreakMatchesMDN(string text, LayoutMode layoutMode, W
416
418
FallbackFontFamilies = new [ ] { jhengHei }
417
419
} ;
418
420
419
- FontRectangle size = TextMeasurer . MeasureAdvance (
420
- text ,
421
- options ) ;
421
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { layoutMode , wordBreaking } ) ;
422
422
423
+ FontRectangle size = TextMeasurer . MeasureAdvance ( text , options ) ;
423
424
Assert . Equal ( width , size . Width , 4F ) ;
424
425
Assert . Equal ( height , size . Height , 4F ) ;
425
-
426
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { layoutMode , wordBreaking } ) ;
427
426
}
428
427
}
429
428
@@ -455,10 +454,10 @@ public void MeasureTextWordBreak(string text, LayoutMode layoutMode, WordBreakin
455
454
text ,
456
455
options ) ;
457
456
457
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : new { layoutMode , wordBreaking } ) ;
458
+
458
459
Assert . Equal ( width , size . Width , 4F ) ;
459
460
Assert . Equal ( height , size . Height , 4F ) ;
460
-
461
- TextLayoutTestUtilities . TestLayout ( text , options , properties : new { layoutMode , wordBreaking } ) ;
462
461
}
463
462
}
464
463
@@ -550,8 +549,8 @@ public void CountLinesWithSpan()
550
549
551
550
[ Theory ]
552
551
[ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 25 , 6 ) ]
553
- [ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 50 , 5 ) ]
554
- [ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 100 , 4 ) ]
552
+ [ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 50 , 4 ) ]
553
+ [ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 100 , 3 ) ]
555
554
[ InlineData ( "This is a long and Honorificabilitudinitatibus califragilisticexpialidocious" , 200 , 3 ) ]
556
555
public void CountLinesWrappingLength ( string text , int wrappingLength , int usedLines )
557
556
{
@@ -561,9 +560,10 @@ public void CountLinesWrappingLength(string text, int wrappingLength, int usedLi
561
560
WrappingLength = wrappingLength
562
561
} ;
563
562
563
+ TextLayoutTestUtilities . TestLayout ( text , options , properties : usedLines ) ;
564
+
564
565
int count = TextMeasurer . CountLines ( text , options ) ;
565
566
Assert . Equal ( usedLines , count ) ;
566
- TextLayoutTestUtilities . TestLayout ( text , options , properties : usedLines ) ;
567
567
}
568
568
569
569
[ Fact ]
@@ -1217,10 +1217,11 @@ public void BreakWordEnsuresSingleCharacterPerLine()
1217
1217
} ;
1218
1218
1219
1219
const string text = "Hello World!" ;
1220
- int lineCount = TextMeasurer . CountLines ( text , options ) ;
1221
- Assert . Equal ( text . Length - 1 , lineCount ) ;
1222
1220
1223
1221
TextLayoutTestUtilities . TestLayout ( text , options ) ;
1222
+
1223
+ int lineCount = TextMeasurer . CountLines ( text , options ) ;
1224
+ Assert . Equal ( text . Length - 1 , lineCount ) ;
1224
1225
}
1225
1226
1226
1227
private class CaptureGlyphBoundBuilder : IGlyphRenderer
0 commit comments