Skip to content

Text misaligned when strut style is set #142969

@LongCatIsLooong

Description

@LongCatIsLooong

Extracted from #124852 since the new issue is not related to input decorator.

Steps to reproduce

See the code sample

Expected results

flutter_02

Actual results

flutter_03

Code sample

Code sample
  final style = TextStyle(fontFamily: 'Roboto', backgroundColor: Colors.blue.withAlpha(125), fontSize: 100, height: 1, leadingDistribution: TextLeadingDistribution.even);

  return Directionality(
    textDirection: TextDirection.ltr,
    child: Scaffold(
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, strutStyle: StrutStyle.fromTextStyle(style, forceStrutHeight: true), textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.even),),
              ),
            ),
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, strutStyle: StrutStyle.fromTextStyle(style, forceStrutHeight: false), textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.even),),
              ),
            ),
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, strutStyle: StrutStyle.fromTextStyle(style, forceStrutHeight: true), textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.proportional),),
              ),
            ),
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, strutStyle: StrutStyle.fromTextStyle(style, forceStrutHeight: false), textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.proportional),),
              ),
            ),
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.proportional),),
              ),
            ),
            Expanded(
              child: ColoredBox(
                color: Colors.red,
                child: Text.rich(TextSpan(text: 'A'), style: style, textHeightBehavior: TextHeightBehavior(leadingDistribution: TextLeadingDistribution.even),),
              ),
            ),
          ],
        ),
      ),
    ),
  );

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listfound in release: 3.16Found to occur in 3.16found in release: 3.20Found to occur in 3.20frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions