letterSpacing property not working properly
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
When Applying the letterSpacing to style in Text component, it applies the spacing after the character instead of adding space between the characters.
Here is the sample vanila code.
<Text
style={{
backgroundColor: 'blue',
color: 'white',
fontSize: 18,
alignSelf: 'center',
letterSpacing: 30,
fontVariant: ['tabular-nums'],
}}
>
1/3
</Text>
Output:
I also tried to apply the fontVariant: ['tabular-nums'], assuming that it may keep the character width same if that's the issue.
But seems that doesn't fix the error.
And this gap keeps increasing when you increase the letterSpacing.
Try 2:
<Text
style={{
backgroundColor: 'blue',
color: 'white',
fontSize: 18,
alignSelf: 'center',
letterSpacing: 90, // <- increased
fontVariant: ['tabular-nums'],
}}
>
1/3
</Text>
Output:
And thus How I conclude that it may adds the space after each character instead of gap.
Here is my package.json file's dependencies.
"dependencies": {
"@medusajs/js-sdk": "2.8.7",
"@medusajs/types": "2.8.7",
"@react-native-clipboard/clipboard": "^1.16.3",
"@react-native-community/geolocation": "^3.4.0",
"@react-native-documents/picker": "^11.0.0",
"@react-native-documents/viewer": "^2.0.2",
"@react-native-firebase/analytics": "^23.4.1",
"@react-native-firebase/app": "^23.4.1",
"@react-native-firebase/crashlytics": "^23.4.1",
"@react-native-firebase/remote-config": "^23.4.1",
"@react-navigation/bottom-tabs": "^7.4.6",
"@react-navigation/drawer": "^7.5.7",
"@react-navigation/native": "^7.1.17",
"@react-navigation/native-stack": "^7.3.25",
"@shopify/flash-list": "^2.1.0",
"@tanstack/react-query": "^5.85.2",
"dayjs": "^1.11.19",
"formik": "^2.4.9",
"i18next": "^25.5.2",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"qs": "6.12.0",
"react": "19.1.0",
"react-i18next": "^15.7.3",
"react-native": "0.80.2",
"react-native-config": "^1.5.6",
"react-native-fast-image": "^8.6.3",
"react-native-flash-message": "^0.4.2",
"react-native-gesture-handler": "^2.28.0",
"react-native-image-crop-picker": "^0.51.1",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-keyboard-controller": "^1.19.6",
"react-native-linear-gradient": "^2.8.3",
"react-native-mmkv": "^3.3.0",
"react-native-navigation-bar-color": "^2.0.2",
"react-native-otp-entry": "^1.8.5",
"react-native-permissions": "^5.4.4",
"react-native-reanimated": "^4.0.2",
"react-native-reanimated-carousel": "^4.0.3",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "^5.6.0",
"react-native-screens": "^4.14.1",
"react-native-svg": "^15.12.1",
"react-native-video": "^6.16.1",
"react-native-worklets": "^0.4.1",
"yup": "^1.7.1",
"zustand": "^5.0.7"
},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/runtime": "^7.25.0",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@react-native-community/cli": "19.1.1",
"@react-native-community/cli-platform-android": "19.1.1",
"@react-native-community/cli-platform-ios": "19.1.1",
"@react-native/babel-preset": "0.80.2",
"@react-native/eslint-config": "0.80.2",
"@react-native/metro-config": "0.80.2",
"@react-native/typescript-config": "0.80.2",
"@tanstack/eslint-plugin-query": "^5.83.1",
"@types/jest": "^29.5.13",
"@types/lodash": "^4.17.20",
"@types/react": "^19.1.0",
"@types/react-test-renderer": "^19.1.0",
"babel-plugin-module-resolver": "^5.0.2",
"cspell": "^9.3.2",
"eslint": "^8.19.0",
"eslint-plugin-import": "^2.32.0",
"husky": "^9.1.7",
"jest": "^29.6.3",
"lint-staged": "^16.1.5",
"prettier": "2.8.8",
"react-native-dotenv": "^3.4.11",
"react-test-renderer": "19.1.0",
"reactotron-react-native": "^5.1.15",
"typescript": "5.0.4"
},
Steps to reproduce
- Just paste the code blocks I added in the react native project created with same version as mine.
React Native Version
0.80.2
Affected Platforms
Runtime - Android, Runtime - iOS
Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
OS: macOS 26.1
CPU: (10) arm64 Apple M4
Memory: 162.77 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.11.0
path: ~/.nvm/versions/node/v22.11.0/bin/node
Yarn:
version: 3.2.3
path: ~/.nvm/versions/node/v22.11.0/bin/yarn
npm:
version: 10.9.0
path: ~/.nvm/versions/node/v22.11.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods:
version: 1.16.2
path: /Users/aditya/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 25.1
- iOS 26.1
- macOS 26.1
- tvOS 26.1
- visionOS 26.1
- watchOS 26.1
Android SDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.26094.121.2512.13840223
Xcode:
version: 26.1.1/17B100
path: /usr/bin/xcodebuild
Languages:
Java:
version: 21.0.8
path: /usr/bin/javac
Ruby:
version: 2.7.5
path: /Users/aditya/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 19.1.1
wanted: 19.1.1
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.80.2
wanted: 0.80.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
info React Native v0.82.1 is now available (your project is running on v0.80.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.82.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.80.2&to=0.82.1
info For more info, check out "https://reactnative.dev/docs/upgrading?os=macos".
Stacktrace or Logs
Not a crash
MANDATORY Reproducer
https://snack.expo.dev/@aditya_thummar/moody-indigo-yogurt
Screenshots and Videos
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用链接的 Snack 和 Text 组件示例在 Android 和 iOS 上重现该报告,并尝试将 letterSpacing 值设为 30 和 90。跟踪 Text 的渲染路径,以确定字符后出现间距的原因,然后验证渲染出的间隔是否符合预期的 letter-spacing 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100