【RN v0.71.10】Text doesn't show all content on Android(some devices)
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
Init a new project, just add Text component to show some texts on Android. The Text doesn't show all content for Japanese with custom font fontFamily--BarlowCondensed-Regular on Android(some devices only) such as OPPO K9x 5G.
React Native Version
0.71.10
Output of npx react-native info
➜ newrnversion npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 12.5
CPU: (8) arm64 Apple M2
Memory: 86.42 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 19.6.0 - /opt/homebrew/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.4.0 - /opt/homebrew/bin/npm
Watchman: 2023.02.06.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9123335
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.17 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.10 => 0.71.10
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
- Init a new project using
npx react-native init newrnversion. - Create a font directory
assets/fontsinsidenewrnversion/android/app/src/main. - Add a custom font
BarlowCondensed-Regularfile tonewrnversion/android/app/src/main/assets/fonts. - Edit
App.tsxfile, adds aTextcomponent with Japanese. - Sets the
fontFamilyasBarlowCondensed-Regular. - Run android only.
- The content in
Textdoes not show incomplete.
Snack, code example, screenshot, or link to a repository
Codes
import React from "react";
import { Text, View } from "react-native";
import { Header } from "react-native/Libraries/NewAppScreen";
function App(): JSX.Element {
return (
<View>
<Header />
<Text style={{
fontSize: 16,
backgroundColor: "red",
marginTop: 200,
alignSelf: "center",
textAlign: 'center',
fontFamily: "BarlowCondensed-Regular"
}}>
番号を変更
</Text>
</View>
);
}
export default App;
Screenshot
Actual behaviour
The text does not align center and the content shows incomplete. It seems that it's cut off and moves down!
Expected behaviour
The text aligns center and the content shows complete. For example:
However, if I sets lineHeight: 20 like
<Text style={{
fontSize: 16,
backgroundColor: "red",
marginTop: 200,
alignSelf: "center",
textAlign: 'center',
fontFamily: "BarlowCondensed-Regular",
lineHeight: 20, // here!
}}>
番号を変更
</Text>
Everything works well on all devices! But I think we shouldn't always set lineHeight to avoid this problem. It should be a bug on Android. Any ideas or how to fix it using a efficient way?
At last, the font file(BarlowCondensed-Regular) can be downloaded via the link: BarlowCondensed-Regular.
Any help will be appreciated.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先,在受影响的 Android 设备(例如 OPPO K9x 5G)上,使用 android/app/src/main/assets/fonts 中的字体从 App.tsx 复现该问题。比较有无 lineHeight 时 Japanese Text 的渲染效果:当内容能够完全显示并居中,且无需 lineHeight 时,即表示工作完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, react-native
- 领域
- mobile-dev
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100