New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typography().dense and TextBaseline.ideographic cannot work with Chinese? #47512
Comments
CC @GaryQian |
So the way layout of fonts currently works is that all metrics are reported as relative to a single baseline. This baseline is treated as the alphabetic baseline. The ideographic baseline is actually computed separately from the layout and exists as a reference metric only. What you are seeing is the text being aligned the way the font meant it to be aligned, but since most alphabetic fonts do not take up the full ascent/descent, the alphabetic numbers look smaller and therefore misaligned. You should be able to shift the text by either adjusting the TextStyle height properties or wrapping it in a Column with spacing above it. We would like to improve the way ideographic baselines are used/integrated. There is a bug filed on that topic. I'll link it if I can find it. |
This issue still exists flutter doctor -v
|
code sampleimport 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
theme: ThemeData(
typography: Typography(
dense: TextTheme(
subtitle1: TextStyle(
textBaseline: TextBaseline.ideographic,
)),
)),
home: Scaffold(
appBar: AppBar(
title: Text('Material App Bar'),
),
body: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: [
Text(
'我是中文',
style: Theme.of(context).textTheme.subtitle1,
),
Spacer(),
Text(
'123456',
style: Theme.of(context).textTheme.subtitle1,
),
]),
),
),
);
}
} flutter doctor -v[✓] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.22.6 at /Users/tahatesser/Code/flutter_stable
• Framework revision 9b2d32b605 (5 days ago), 2021-01-22 14:36:39 -0800
• Engine revision 2f0af37152
• Dart version 2.10.5
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Volumes/Extreme/SDK
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Volumes/Extreme/SDK
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.1
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (1 available)
• Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.3
! Doctor found issues in 1 category. [✓] Flutter (Channel master, 1.26.0-13.0.pre.229, on macOS 11.1 20C69 darwin-x64, locale en-GB)
• Flutter version 1.26.0-13.0.pre.229 at /Users/tahatesser/Code/flutter_master
• Framework revision 650b240634 (2 hours ago), 2021-01-27 21:39:06 -0800
• Engine revision 68cd4c42b5
• Dart version 2.12.0 (build 2.12.0-267.0.dev)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Volumes/Extreme/SDK
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Volumes/Extreme/SDK
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
[✓] Connected device (3 available)
• Taha’s iPad (mobile) • 00008020-000255113EE8402E • ios • iOS 14.3
• macOS (desktop) • macos • darwin-x64 • macOS 11.1 20C69 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.96
• No issues found! |
Hi is there any updates? thanks! |
I can still reproduce the issue based on the expected behavior specified flutter doctor -v (mac)
|
Typography().dense and TextBaseline.ideographic cannot work with Chinese?
When I write a widget, just like this:
The first
Text
and the secondText
cann't be vertically centered,The Chinese font's offset will be lower than number or english. Although, I apply Typography().dense to the AppTheme, also set 'TextBaseline.ideographic' to text, but still cannot work well. What should I do ? Is it a bug? Thank you for your answer.The text was updated successfully, but these errors were encountered: