@@ -453,6 +453,67 @@ describe("Paragraphs", () => {
453
453
) ;
454
454
} ) ;
455
455
456
+ itRunsE2eOnly ( "should draw the bounding box" , async ( ) => {
457
+ const img = await surface . drawOffscreen (
458
+ ( Skia , canvas , { bold, boldItalic, italic } ) => {
459
+ const para = Skia . ParagraphBuilder . Make ( )
460
+ . pushStyle ( {
461
+ fontStyle : italic ,
462
+ color : Skia . Color ( "black" ) ,
463
+ } )
464
+ . addText ( "Hello Skia in italic" )
465
+ . pop ( )
466
+ . pushStyle ( { fontStyle : bold , color : Skia . Color ( "black" ) } )
467
+ . addText ( "Hello Skia in bold" )
468
+ . pop ( )
469
+ . pushStyle ( {
470
+ fontStyle : boldItalic ,
471
+ color : Skia . Color ( "black" ) ,
472
+ } )
473
+ . addText ( "Hello Skia in bold-italic" )
474
+ . pop ( )
475
+ . build ( ) ;
476
+ para . layout ( 150 ) ;
477
+ const height = para . getHeight ( ) ;
478
+ const paint = Skia . Paint ( ) ;
479
+ paint . setColor ( Skia . Color ( "cyan" ) ) ;
480
+ canvas . drawRect ( Skia . XYWHRect ( 0 , 0 , 150 , height ) , paint ) ;
481
+ para . paint ( canvas , 0 , 0 ) ;
482
+ } ,
483
+ {
484
+ bold : FontStyle . Bold ,
485
+ italic : FontStyle . Italic ,
486
+ boldItalic : FontStyle . BoldItalic ,
487
+ }
488
+ ) ;
489
+ checkImage (
490
+ img ,
491
+ `snapshots/paragraph/paragraph-text-style-font-style-${ surface . OS } -box.png`
492
+ ) ;
493
+ } ) ;
494
+
495
+ itRunsE2eOnly ( "should return the paragraph height" , async ( ) => {
496
+ const { width, height } = await surface . eval ( ( Skia ) => {
497
+ const para = Skia . ParagraphBuilder . Make ( )
498
+ . pushStyle ( {
499
+ color : Skia . Color ( "black" ) ,
500
+ fontSize : 25 ,
501
+ shadows : [
502
+ {
503
+ color : Skia . Color ( "#ff000044" ) ,
504
+ blurRadius : 4 ,
505
+ offset : { x : 4 , y : 4 } ,
506
+ } ,
507
+ ] ,
508
+ } )
509
+ . addText ( "Hello Skia with red shadow" )
510
+ . build ( ) ;
511
+ para . layout ( 150 ) ;
512
+ return { height : para . getHeight ( ) , width : para . getMaxWidth ( ) } ;
513
+ } ) ;
514
+ expect ( width ) . toBe ( 150 ) ;
515
+ expect ( height ) . toBeGreaterThan ( 25 ) ;
516
+ } ) ;
456
517
itRunsE2eOnly ( "should support font shadows" , async ( ) => {
457
518
const img = await surface . drawOffscreen ( ( Skia , canvas ) => {
458
519
const para = Skia . ParagraphBuilder . Make ( )
0 commit comments