feat: allowFontScaling prop#620
Conversation
086eafc to
c7927aa
Compare
Co-authored-by: Kacper Żółkiewski <74975508+kacperzolkiewski@users.noreply.github.com>
kacperzolkiewski
left a comment
There was a problem hiding this comment.
Looks and works correct! 🚀
| _primaryFontNeedsRecreation = YES; | ||
| _monospacedFontNeedsRecreation = YES; | ||
| _olMarkerFontNeedsRecreation = YES; | ||
| _allowFontScaling = YES; |
There was a problem hiding this comment.
I wouldn't put it here. Only internal flags used in config are instantiated here (see flags that track font recreation above). Since _allowFontScaling is essentially mirroring a prop and only set via updateProps, I think we can entirely drop this statement.
| isFirstMount) { | ||
| textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling; | ||
| _placeholderLabel.adjustsFontForContentSizeCategory = | ||
| newViewProps.allowFontScaling; |
There was a problem hiding this comment.
I did some research and we actually shouldn't need the adjustsFontForContentSizeCategory prop. It is used for automatic resizing only if the font was instantiated either via
UIFont.preferredFont(forTextStyle: ..)
or
UIFontMetrics(forTextStyle: ..).scaledFont(for: ..)
We don't use either - instead we are subscribed to traitCollectionDidChange, which in turn calls [config invalidateFonts].
Instead of these calls however, we definitely want to run [config invalidateFonts] here if the allowFontScaling prop was changed - maybe we didn't touch the accessibility scaling but just the prop change alone should cause fonts recalculation.
| const auto &viewProps = | ||
| *std::static_pointer_cast<EnrichedTextInputViewProps const>(_props); | ||
| if (!viewProps.allowFontScaling) { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
Instead of reading props we can just access the allowFontScaling from the config.
| // allowFontScaling | ||
| if (newViewProps.allowFontScaling != oldViewProps.allowFontScaling || | ||
| isFirstMount) { | ||
| textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling; |
There was a problem hiding this comment.
Same as in input, we probably want to exchange this call with a [config invalidateFonts].
There was a problem hiding this comment.
Also, I believe we don't need isFirstMount check here - oldViewProps on first mount will usually be not defined so any first value will always be different than the compared "old" one. Please also check it for the input.
| const auto &viewProps = | ||
| *std::static_pointer_cast<EnrichedTextViewProps const>(_props); | ||
| if (!viewProps.allowFontScaling) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Same as in input, we can just access the allowFontScaling from the config.
| if (!config.allowFontScaling) { | ||
| return; | ||
| } | ||
|
|
||
| if (previousTraitCollection.preferredContentSizeCategory != | ||
| self.traitCollection.preferredContentSizeCategory) { |
There was a problem hiding this comment.
One more improvement, we can make the previousTraitCollection an early return too:
(might be formatted wrongly)
| if (!config.allowFontScaling) { | |
| return; | |
| } | |
| if (previousTraitCollection.preferredContentSizeCategory != | |
| self.traitCollection.preferredContentSizeCategory) { | |
| if (!config.allowFontScaling) { | |
| return; | |
| } | |
| if (previousTraitCollection.preferredContentSizeCategory == self.traitCollection.preferredContentSizeCategory) { | |
| return; | |
| } |
Summary
Thanks for the feature suggestion in this issue!
Implemented a
allowFontScalingproptrue, the font size will be scaled to satisfy the system's accessibility font size settings (default behaviour)false, it works independently of the current settingsVideos
EnrichedTextInputScreen.Recording.2026-05-27.at.16.18.28.mov
EnrichedTextScreen.Recording.2026-05-27.at.16.20.20.mov
Compatibility
Checklist