Skip to content

[iOS] Fix Dynamic Type font auto-scaling not updating at runtime#34467

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/review-pr-34445
Closed

[iOS] Fix Dynamic Type font auto-scaling not updating at runtime#34467
Copilot wants to merge 1 commit intomainfrom
copilot/review-pr-34445

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 13, 2026

FontManager caches UIFont instances keyed on the Font struct. When the user changes the system Dynamic Type size at runtime, the cache key is unchanged, so stale pre-scaled fonts are returned until the app restarts.

Changes

  • FontManager.iOS.cs — Register a ContentSizeCategoryChanged observer that clears _fonts, ensuring the next GetFont call re-invokes UIFontMetrics.DefaultMetrics.GetScaledFont with the current category.

  • PageViewController.cs — In TraitCollectionDidChange, detect PreferredContentSizeCategory changes and drive a recursive font invalidation pass:

if (previousTraitCollection is not null &&
    previousTraitCollection.PreferredContentSizeCategory != TraitCollection.PreferredContentSizeCategory)
{
    InvalidateFontsOnContentSizeChanged(CurrentView as IView);
}
  • InvalidateFontsOnContentSizeChanged — Walks the visual tree via IVisualTreeElement.GetVisualChildren(). For any ITextStyle view with Font.AutoScalingEnabled: true and a live handler, calls UpdateValue(nameof(ITextStyle.Font)) (re-fetches from the now-cleared cache) and InvalidateMeasure().

Known limitation: Virtualized items in CollectionView/ListView that are off-screen are not updated in-flight; they pick up the correct font on next cell reuse. Shell-based navigation pages are not covered by this path and may require separate handling.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI changed the title [WIP] Review pull request #34445 [iOS] Fix Dynamic Type font auto-scaling not updating in real-time Mar 13, 2026
Copilot AI requested a review from sheiksyedm March 13, 2026 05:46
Copilot AI changed the title [iOS] Fix Dynamic Type font auto-scaling not updating in real-time [iOS] Fix Dynamic Type font auto-scaling not updating at runtime Mar 13, 2026
@sheiksyedm sheiksyedm closed this Mar 13, 2026
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.

2 participants