Skip to content

[iOS] dynamicTypeRamp grows text by its text style's line height, not its font size #60386

Backlog

Description

@miniware9

Description

On iOS, a Text with dynamicTypeRamp grows with the text size by the ratio of its text style's leading at that size to its leading at Large, not by the ratio of the style's font size. So text on a ramp draws smaller than the text style it names at every enlarged text size: on the Footnote ramp, a 13-point Text draws at 17.3 points at xxxLarge and at 37.7 at AX5, where Footnote is 19 and 44.

RCTEffectiveFontSizeMultiplierFromTextAttributes (RCTAttributedTextUtils.mm) sets a ramp's multiplier to [fontMetrics scaledValueForValue:requestedSize] / requestedSize, fontMetrics being the ramp's text style's UIFontMetrics, and scales both the font size and the line height by it. The multiplier that gives is the style's leading ratio, as the measurements below show, while RCTBaseSizeForDynamicTypeRamp takes each style's size at Large from Apple's typography specifications, the same tables that give the sizes the text should reach.

Measured with the reproducer on an iPhone 17 Simulator, iOS 27.2. Each Text is given its style's size and leading at Large; React Native scales both by one multiplier, so the multiplier is the laid-out line height over that leading.

Ramp Text size Drawn Multiplier Style's size ratio Style's leading ratio
footnote xxxLarge 17.3 pt 1.333 1.462 (19 pt) 1.333
body xxxLarge 22.3 pt 1.314 1.353 (23 pt) 1.318
title3 xxxLarge 25.7 pt 1.283 1.300 (26 pt) 1.280
footnote AX5 37.7 pt 2.897 3.385 (44 pt) 2.889
body AX5 48.0 pt 2.824 3.118 (53 pt) 2.818
title3 AX5 52.0 pt 2.600 2.750 (55 pt) 2.600

Sizes and leadings are Apple's "iOS, iPadOS Dynamic Type sizes" (Human Interface Guidelines, Typography). A style's own size at the current text size is +[UIFont preferredFontForTextStyle:]'s pointSize. Since one multiplier scales both the font size and the line height today, a fix would choose whether the line height keeps following the leading while the font size follows the size.

Steps to reproduce

  1. Open the reproducer Snack on an iOS device or Simulator, on SDK 58 (React Native 0.88.1).
  2. Set the text size to xxxLarge: Settings > Accessibility > Display & Text Size > Larger Text, or on a Simulator xcrun simctl ui booted content_size extra-extra-extra-large.
  3. Each row shows the size its Text drew at and the multiplier it grew by, beside Apple's size and leading for its text style at that text size. The multiplier equals the style's leading ratio, not its size ratio.
  4. Repeat at AX5: xcrun simctl ui booted content_size accessibility-extra-extra-extra-large.

React Native Version

0.88.1

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx @react-native-community/cli info

System:
  OS: macOS 27.2.1
  CPU: (11) arm64 Apple M3 Pro
  Memory: 85.88 MB / 18.00 GB
  Shell:
    version: 5.3.20
    path: /opt/local/bin/bash
Binaries:
  Node:
    version: 26.13.0
    path: /opt/local/bin/node
  Yarn: Not Found
  npm:
    version: 11.21.2
    path: /opt/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.17.0
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 27.2
      - iOS 27.2
      - macOS 27.2
      - tvOS 27.2
      - visionOS 27.2
      - watchOS 27.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2026.2 AI-262.10968.63.2622.16975389
  Xcode:
    version: 27.2/27B52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.18
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.3.0
    wanted: 19.3.0
  react-native:
    installed: 0.88.1
    wanted: 0.88.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

No crash or error. The reproducer's rows on an iPhone 17 Simulator, iOS 27.2:

Text size: xxxLarge (fontScale 1.353)
Drawn: 17.3 pt on 24.0 pt lines, ×1.333
Apple's Footnote at xxxLarge: 19 pt on 24 pt lines, size ×1.462, leading ×1.333
Drawn: 22.3 pt on 28.9 pt lines, ×1.314
Apple's Body at xxxLarge: 23 pt on 29 pt lines, size ×1.353, leading ×1.318
Drawn: 25.7 pt on 32.1 pt lines, ×1.283
Apple's Title 3 at xxxLarge: 26 pt on 32 pt lines, size ×1.300, leading ×1.280

Text size: AX5 (fontScale 3.571)
Drawn: 37.7 pt on 52.2 pt lines, ×2.897
Apple's Footnote at AX5: 44 pt on 52 pt lines, size ×3.385, leading ×2.889
Drawn: 48.0 pt on 62.1 pt lines, ×2.824
Apple's Body at AX5: 53 pt on 62 pt lines, size ×3.118, leading ×2.818
Drawn: 52.0 pt on 65.0 pt lines, ×2.600
Apple's Title 3 at AX5: 55 pt on 65 pt lines, size ×2.750, leading ×2.600

MANDATORY Reproducer

https://snack.expo.dev/@miniware/ios-dynamic-type-ramp

Screenshots and Videos

xxxlarge ax5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions