@@ -1632,7 +1632,7 @@ void main() {
16321632 expect (painter.computeDistanceToActualBaseline (TextBaseline .alphabetic), 10 + 10 * 7.5 );
16331633 });
16341634
1635- test ('force strut height' , () {
1635+ test ('strut no half leading + force strut height' , () {
16361636 const StrutStyle strut = StrutStyle (height: 10 , fontSize: 10 , forceStrutHeight: true );
16371637 final TextPainter painter = TextPainter (
16381638 textDirection: TextDirection .ltr,
@@ -1646,6 +1646,34 @@ void main() {
16461646 const < ui.TextBox > [TextBox .fromLTRBD (0 , baseline - 15 , 20 , baseline + 5 , TextDirection .ltr)],
16471647 );
16481648 });
1649+
1650+ test ('strut half leading + force strut height' , () {
1651+ const StrutStyle strut = StrutStyle (height: 10 , fontSize: 10 , forceStrutHeight: true , leadingDistribution: TextLeadingDistribution .even);
1652+ final TextPainter painter = TextPainter (
1653+ textDirection: TextDirection .ltr,
1654+ text: const TextSpan (text: 'A' , style: TextStyle (fontSize: 20 )),
1655+ strutStyle: strut,
1656+ )..layout ();
1657+ expect (painter.height, 100 );
1658+ const double baseline = 45 + 7.5 ;
1659+ expect (
1660+ painter.getBoxesForSelection (const TextSelection (baseOffset: 0 , extentOffset: 1 )),
1661+ const < ui.TextBox > [TextBox .fromLTRBD (0 , baseline - 15 , 20 , baseline + 5 , TextDirection .ltr)],
1662+ );
1663+ });
1664+
1665+ test ('force strut height applies to widget spans' , () {
1666+ const Size placeholderSize = Size (1000 , 1000 );
1667+ const StrutStyle strut = StrutStyle (height: 10 , fontSize: 10 , forceStrutHeight: true );
1668+ final TextPainter painter = TextPainter (
1669+ textDirection: TextDirection .ltr,
1670+ text: const WidgetSpan (child: SizedBox ()),
1671+ strutStyle: strut,
1672+ )
1673+ ..setPlaceholderDimensions (const < PlaceholderDimensions > [PlaceholderDimensions (size: placeholderSize, alignment: PlaceholderAlignment .bottom)])
1674+ ..layout ();
1675+ expect (painter.height, 100 );
1676+ });
16491677 }, skip: kIsWeb && ! isCanvasKit); // [intended] strut spport for HTML renderer https://github.com/flutter/flutter/issues/32243.
16501678
16511679 test ('TextPainter dispatches memory events' , () async {
0 commit comments