react / react/react-native

letterSpacing property not working properly

オープン
#54,823 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Needs: Triage :mag:
主要言語
C++
スター
127k
フォーク
25.3k
平均マージ
1日 23時間
マージ済み PR(30日)
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:

Image

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:

Image

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
  1. 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
Image

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

リンクされたSnackとTextコンポーネントの例を使用して、AndroidとiOSの両方でレポートを再現し、letterSpacingの値として30と90を試します。Textのレンダリングパスを追跡して、文字の後に間隔が現れる理由を特定し、レンダリングされた間隔が意図したletter-spacingの動作と一致することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
react-native
領域
mobile
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。