Skip to content

feat: allowFontScaling prop#620

Open
hejsztynx wants to merge 15 commits into
mainfrom
@ksienkiewicz/feat-allow-font-scaling
Open

feat: allowFontScaling prop#620
hejsztynx wants to merge 15 commits into
mainfrom
@ksienkiewicz/feat-allow-font-scaling

Conversation

@hejsztynx
Copy link
Copy Markdown
Collaborator

@hejsztynx hejsztynx commented May 27, 2026

Summary

Thanks for the feature suggestion in this issue!

Implemented a allowFontScaling prop

  • when set to true, the font size will be scaled to satisfy the system's accessibility font size settings (default behaviour)
  • when set to false, it works independently of the current settings

Videos

EnrichedTextInput

Screen.Recording.2026-05-27.at.16.18.28.mov

EnrichedText

Screen.Recording.2026-05-27.at.16.20.20.mov

Compatibility

OS Implemented
iOS
Android

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

@hejsztynx hejsztynx force-pushed the @ksienkiewicz/feat-allow-font-scaling branch from 086eafc to c7927aa Compare May 29, 2026 10:36
Comment thread .maestro/enrichedInput/flows/font_scaling.yaml Outdated
Comment thread .maestro/enrichedText/flows/font_scaling.yaml
Comment thread apps/example/src/screens/DevScreen.tsx Outdated
Copy link
Copy Markdown
Collaborator

@exploIF exploIF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works good

Copy link
Copy Markdown
Collaborator

@kacperzolkiewski kacperzolkiewski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and works correct! 🚀

Comment thread ios/config/EnrichedConfig.mm Outdated
_primaryFontNeedsRecreation = YES;
_monospacedFontNeedsRecreation = YES;
_olMarkerFontNeedsRecreation = YES;
_allowFontScaling = YES;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ios/EnrichedTextInputView.mm Outdated
isFirstMount) {
textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling;
_placeholderLabel.adjustsFontForContentSizeCategory =
newViewProps.allowFontScaling;
Copy link
Copy Markdown
Collaborator

@szydlovsky szydlovsky Jun 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ios/EnrichedTextInputView.mm Outdated
Comment on lines +1997 to +2002
const auto &viewProps =
*std::static_pointer_cast<EnrichedTextInputViewProps const>(_props);
if (!viewProps.allowFontScaling) {
return;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of reading props we can just access the allowFontScaling from the config.

Comment thread ios/EnrichedTextView.mm Outdated
// allowFontScaling
if (newViewProps.allowFontScaling != oldViewProps.allowFontScaling ||
isFirstMount) {
textView.adjustsFontForContentSizeCategory = newViewProps.allowFontScaling;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in input, we probably want to exchange this call with a [config invalidateFonts].

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread ios/EnrichedTextView.mm Outdated
Comment on lines +725 to +729
const auto &viewProps =
*std::static_pointer_cast<EnrichedTextViewProps const>(_props);
if (!viewProps.allowFontScaling) {
return;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in input, we can just access the allowFontScaling from the config.

Comment thread ios/EnrichedTextView.mm
Comment on lines +1993 to 1998
if (!config.allowFontScaling) {
return;
}

if (previousTraitCollection.preferredContentSizeCategory !=
self.traitCollection.preferredContentSizeCategory) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more improvement, we can make the previousTraitCollection an early return too:
(might be formatted wrongly)

Suggested change
if (!config.allowFontScaling) {
return;
}
if (previousTraitCollection.preferredContentSizeCategory !=
self.traitCollection.preferredContentSizeCategory) {
if (!config.allowFontScaling) {
return;
}
if (previousTraitCollection.preferredContentSizeCategory == self.traitCollection.preferredContentSizeCategory) {
return;
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants