Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please select one of the following
Summary
This introduces Dynamic Type support for iOS as discussed here.
This allows
Text
elements to resize similarly (see note below) to native semantic text elements in iOS when we change the text size in the OS's Accessibility settings. Thanks to a new prop calledfontScaleRamp
dynamicTypeRamp
, we can specify what kind of scaling a particular text element should use.This prop is only used on iOS. Android appears to use a common linear scale factor for its "large text" accessibility feature, and macOS doesn't support Dynamic Type.
This is a React Native equivalent of this fluentui-apple PR. We're requiring developers to specify which font ramp to use instead of trying to intelligently map them because React Native by default has no innate sense of semantic text styles. This also gives developers the freedom to develop and conform to their own typography standards if they wish.
It's worth noting that while this code yields the same font sizes as FUA does, they're not quite the same as what we would get from
-[UIFont preferredFontForTextStyle:]
in UIKit orView.font(_:)
in SwiftUI. This is becauseUIFontMetrics
appears to develop its scaling ratios based on leading between lines rather than the font size itself, although these still appear to yield "good enough" results.Changelog
[iOS] [Added] - Dynamic Type support
Screenshots
The following are screenshots from the newly added section to the Text test page (albeit with the outdated
fontScaleRamp
name).Normal size:
AX5: