react / react/react-native

Emojis inside <Text> increase line-height or stretch the element on iOS

Offen
#47,621 14 Kommentare 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Needs: Triage :mag: Newer Patch Available Platform: iOS
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

Description

Reported previously in #18559. Emojis within <Text> elements are not aligned with other text in the same text element or other text elements on screen. They also cause the height of the <Text> to increase disproportionate to the fontSize.

As a workaround, the fontFamily of the emoji can be set to System. The referenced Snack shows this behavior. The emoji is rendered initially with the Menlo font family and overridden to System when the override button is pressed. When overridden, the strikethrough more closely aligns with the text, though is not perfectly aligned like on Android.

This issue no longer seems to be reproducible on Android.

Steps to reproduce
  1. Launch the Snack
  2. Note that the strikethrough does not align with the emoji nor the text to the right
  3. Click Override
  4. Note that the strikethrough more closely aligns with the emoji and the text on the right
React Native Version

0.76.1

Affected Platforms

Runtime - iOS

Output of npx react-native info
System:
  OS: macOS 14.7.1
  CPU: (16) arm64 Apple M3 Max
  Memory: 3.73 GB / 48.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.20.5
    path: /opt/homebrew/opt/node@18/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.8.2
    path: /opt/homebrew/opt/node@18/bin/npm
  Watchman:
    version: 2024.11.11.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.1.2
    wanted: ^15.1.2
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Stacktrace or Logs
None
Reproducer

https://snack.expo.dev/@mhoran/hazardous-orange-celery

Screenshots and Videos
Without override With override
Screenshot 2024-11-14 at 4 02 20 PM Screenshot 2024-11-14 at 4 02 27 PM

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, den verlinkten Snack auf iOS zu reproduzieren, und vergleiche das Verhalten von Emojis in mit den fontFamily-Einstellungen Menlo und System. Verfolge den für Zeilenhöhe und Ausrichtung verantwortlichen iOS-Text-Rendering-Pfad; fertig ist die Aufgabe, wenn Emojis den Text nicht mehr strecken oder falsch ausrichten, ohne das Verhalten unter Android zu beeinträchtigen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ios, react-native
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.