Line height is distributed unevenly when lineHeight <= fontSize
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
Description
When lineHeight is less than the fontSize, Text shrinks the line's bounding box only by removing space from above the text, rather than distributing the space evenly above and below, as is done with extra line height. Actually, the issue manifests when lineHeight is less than fontSize plus some small amount (perhaps the font bounding box height?)—e.g. <= 45px for 40px Helvetica.
This leads to clipped glyphs and produces differences in text rendering between react-native-web and react-native (https://github.com/necolas/react-native-web/issues/1687). After some discussion with @necolas, my inclination is that RNW's behavior is the more reasonable one, so I thought I'd open an issue here.
This issue reproduces across a variety of fonts.

Unfortunately,I worry that fixing this issue will create subtle and surprising source compatibility issues for existing clients.
React Native version:
System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 337.02 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.21.0 - ~/.nvm/versions/node/v10.21.0/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.14.4 - ~/.nvm/versions/node/v10.21.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.6/11E708 - /usr/bin/xcodebuild
Languages:
Java: 11.0.2 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: 0.63.2 => 0.63.2
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
Run example app here: https://snack.expo.io/W51F2OAqD
Expected Results
The extra line spacing should be removed evenly from both above and below the type.
Snack, code example, screenshot, or link to a repository:
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với ví dụ Snack được liên kết và đường dẫn kết xuất React Native Text; so sánh hành vi khi lineHeight bằng hoặc nhỏ hơn fontSize trên các phông chữ được mô tả. Xác nhận kết quả mong đợi bằng cách kiểm tra xem khoảng cách thừa có được loại bỏ đồng đều ở phía trên và phía dưới mà không cắt xén glyph hay không, sau đó đánh giá tác động đến khả năng tương thích mã nguồn được nêu trong issue.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- react-native
- Lĩnh vực
- mobile
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100