Repository navigation
Closed
Labels
a: fidelityMatching the OEM platforms betterMatching the OEM platforms betterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
Description
It's a bug.
Text position is not cented in PopupMenuItem When I set the language to Chinese.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Demo',
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('zh', 'CN'),
],
locale: const Locale('zh', 'CN'),
home: LaunchPage(),
);
}I am sure this is the reason, because it wokes fine when I commented out this code. It's like gallery.
It has no effect when I am try to use padding or center warp this text widget. I don't know why, but I hope
to resove this problem.
Logs
[✓] Flutter (Channel beta, v1.0.0, on Linux, locale zh_CN.UTF-8)
• Flutter version 1.0.0 at /home/xia/develop/flutter/flutter
• Framework revision 5391447fae (4 周前), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at /home/xia/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• Java binary at:
/home/xia/develop/tool/android-studio-ide-181.5014246-linux/android-studio
/jre/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] Android Studio (version 3.2)
• Android Studio at
/home/xia/develop/tool/android-studio-ide-181.5014246-linux/android-studio
• Flutter plugin version 31.1.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build
1.8.0_152-release-1136-b06)
[!] IntelliJ IDEA Ultimate Edition (version 2018.2)
• IntelliJ at /home/xia/develop/tool/ideaIU-2018.2.4/idea-IU-182.4505.22
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.io/intellij-setup/#installing-the-plugins
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API
28) (emulator)
Reacted by nagoya0
Metadata
Metadata
Assignees
Labels
a: fidelityMatching the OEM platforms betterMatching the OEM platforms betterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages

Activity
HansMuller commentedon Jan 3, 2019
cc @GaryQian @justinmc
ozexpert commentedon Jan 4, 2019
seeing this problem too.
justinmc commentedon Jan 4, 2019
I was able to reproduce this with the following code:
Don't forget to include localizations in pubspec.yaml:
[-]Text position is not cented in PopupMenuItem[/-][+]Text position is not centered in PopupMenuItem[/+]reply-1988 commentedon Jan 15, 2019
I also met this problem with the following code:
voiddog commentedon Jan 18, 2019
In flutter 1.0
PopupMenuItem's default height is 48You can solve the problem by setting
PopupMenuItem's heightreply-1988 commentedon Jan 18, 2019
i try it, but the text in PopupMenuItem is not center.
voiddog commentedon Jan 18, 2019
Yes, there may be deviations here.
PopupMenuItemforce the baseline to start at the bottom 20. you can see the code inPopupMenuItem:So the problem is the baseline, you can see the picture blew:


_kBaselineOffsetFromBottomis pravite and final, so we can't modify it, but we can center the text by setting the height ofPopupMenuItem.PopupMenuItem's height is about 40 + fontSize. But the results may have deviations, beacause the height of text may not equal to font size.nagoya0 commentedon Feb 4, 2019
any updates on this?
seeing this issue in Japanese locale too.
shingohu commentedon Mar 28, 2019
try this code or just copy the PopupMenuItem source and remove the wrap of Baseline
xia-weiyang commentedon May 20, 2019
I hope to provide the settings for this
_kBaselineOffsetFromBottomfield instead of changing the source code.tmulin commentedon Jun 21, 2019
I got the same problem too when using whti locale "zh" .
GaryQian commentedon Jun 29, 2019
I am indeed seeing completely different heights of the laid out text for the different locales.
Just a guess for now, but it could be that the alphabetic letters are being rendered using the chinese font's alphabet instead the true alphabetic font. This may have caused skewed text meant to line up with Chinese.
GaryQian commentedon Jul 2, 2019
The problem is that when locale is set to chinese, we begin to use the ideographic baseline (instead of alphabetic baseline) for laying out the vertical alignment.
However, it is currently known that our metric for ideographic baseline is inaccurate. The solution for now may be to just use the alphabetic baseline regardless of the locale, which should produce comparable results between different locales.
GaryQian commentedon Jul 2, 2019
#35493 Is a fix for this until our ideographic baseline implementation is improved, after which it can be reverted.
GaryQian commentedon Jul 16, 2019
I will close this for now. There is a TODO to undo this change in the future.
github-actions commentedon Aug 14, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.