facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.75k stars 24.29k forks source link

[Android] React native 0.75.4 text number of lines not updating #46908

Open LunaticHero-Cyber opened 1 week ago

LunaticHero-Cyber commented 1 week ago

Description

I found the issue when using text align justify and found out that the text has an extra one number of lines. After further investigating, while using a custom asset I found out that the number of lines stays the same when it first initialize from when it had Left text align.

Here is when it is has Justify and Left text align respectively:

Screenshot 2024-10-09 at 09 24 06

It is worth noting that both width in the picture is the same. Furthermore, I also checked for the number of lines from onTextLayout, and the results shows that it remains having 6 lines instead of 5 (in my case previously shown).

Steps to reproduce

  1. Initialize project
  2. Install dependencies using 'npm install'
  3. Add custom asset (.tff file)
  4. Import Text component
  5. Put text align justify as style
  6. Use font family
  7. Adjust random number of words until the issue is replicated

React Native Version

0.75.4

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 13.0.1
  CPU: (8) arm64 Apple M1
  Memory: 80.97 MB / 8.00 GB
  Shell:
    version: 5.8.1
    path: /bin/zsh
Binaries:
  Node:
    version: 18.18.0
    path: ~/.nvm/versions/node/v18.18.0/bin/node
  Yarn:
    version: 3.6.4
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.8.1
    path: ~/.nvm/versions/node/v18.18.0/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.1
      - iOS 16.1
      - macOS 13.0
      - tvOS 16.1
      - watchOS 9.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2021.3 AI-213.7172.25.2113.9123335
  Xcode:
    version: 14.1/14B47b
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.4
    wanted: 0.75.4
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

none

Reproducer

https://github.com/LunaticHero-Cyber/text_test

Screenshots and Videos

No response

LunaticHero-Cyber commented 1 week ago

I want to note that I also find this issue when working on a project with 0.74.3

shubhamguptadream11 commented 1 week ago

@LunaticHero-Cyber Can you check this on New Architecture as well?

LunaticHero-Cyber commented 1 week ago

@LunaticHero-Cyber Can you check this on New Architecture as well?

After checking, with newArch enabled, the issue seems to persist. @shubhamguptadream11

Screenshot 2024-10-11 at 14 59 32 Screenshot 2024-10-11 at 14 59 38
coado commented 17 hours ago

That's interesting. The text is measured differently in TextLayoutManager.measureText than what's actually being displayed. There is probably something wrong with how the StaticLayout is built. I am having a closer look on that.