Skip to content

Chinese text has positive bottom padding and negative top padding, happening on both iOS and Android, thus not possible to vertically center a text #96713

@fzyzcjy

Description

@fzyzcjy

Steps to Reproduce

Just copy and paste this code snippet and run it.

Expected results:

Text should not have such strange padding at bottom.

Actual results:

This is the screenshot when running the app. As we can see, the text has two strange things:

  1. It has non-neglectable bottom paddings.
  2. It has negative top padding.

This is a problem, because with such, we cannot vertically make a text center-aligned. for example, a Center will make the text "box" centered, but due to uneven padding, it will indeed be put higher than expected.

By the way, I have tested it on a iPhone and an android, so it seems not to be a problem of one specific font, but rather something intrinsic.

image

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(),
        body: Center(
          child: Container(
            color: Colors.orange[200],
            child: const Text(
              '探索文本工王田甲乙丙丁一二三四口',
              style: TextStyle(
                fontSize: 24,
                height: 1,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
Logs
n/a
no problem
2.8.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: internationalizationSupporting other languages or locales. (aka i18n)a: typographyText rendering, possibly libtxtfound in release: 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions