Skip to content

Text Size isn't corresponding to Logical pixels #52038

@feinstein

Description

@feinstein

The fontSize docs say The size of glyphs (in logical pixels) to use when painting the text.

But I think there's something more here that's missing, here's a simple test:

Row(
  children: <Widget>[
    Text('TESTÇg', style: TextStyle(fontSize: 16),),
    Container(height: 16, width: 100, color: Colors.black,),
    Container(height: 100, width: 100, color: Colors.orange,),
  ],
)

The orange Container is to get the the Row boundaries out of the way.

The Black Container has a height of 16 logic pixels, same as the fontSize but its shorter than the Text. The g represents letters that get to the bottom of the Text, the Á the ones that get to the top, so clearly the Text is bigger than 16 logic pixels:

image

image

I know typography isn't simple, I don't think there's anything wrong with the Text itself, but I think the docs aren't right. I found this because I wanted to make a Container the same size as a Text, but they didn't match and the docs didn't help me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxtd: api docsIssues with https://api.flutter.dev/frameworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions