@@ -1632,7 +1632,7 @@ void main() {
1632
1632
expect (painter.computeDistanceToActualBaseline (TextBaseline .alphabetic), 10 + 10 * 7.5 );
1633
1633
});
1634
1634
1635
- test ('force strut height' , () {
1635
+ test ('strut no half leading + force strut height' , () {
1636
1636
const StrutStyle strut = StrutStyle (height: 10 , fontSize: 10 , forceStrutHeight: true );
1637
1637
final TextPainter painter = TextPainter (
1638
1638
textDirection: TextDirection .ltr,
@@ -1646,6 +1646,34 @@ void main() {
1646
1646
const < ui.TextBox > [TextBox .fromLTRBD (0 , baseline - 15 , 20 , baseline + 5 , TextDirection .ltr)],
1647
1647
);
1648
1648
});
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
+ });
1649
1677
}, skip: kIsWeb && ! isCanvasKit); // [intended] strut spport for HTML renderer https://github.com/flutter/flutter/issues/32243.
1650
1678
1651
1679
test ('TextPainter dispatches memory events' , () async {
0 commit comments