Repository navigation
feat: Add text scaling (accessibility) support across all platforms - #22928
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Pull request overview
Implements WinUI-compatible accessibility text scaling across Uno by introducing a central font-scale state, wiring text-scale enablement through core text controls, and adding platform-specific text scale factor providers (Android/iOS + Skia extension model), along with tests and a SamplesApp page.
Changes:
- Added text scaling core infrastructure (
TextScaleHelper,CoreServices.FontScale/UpdateFontScale,FeatureConfiguration.Font.TextScaleFactoroverride) and OS change observation plumbing. - Implemented
IsTextScaleFactorEnabledon key text-related controls (TextBlock,RichTextBlock,ContentPresenter,Control,TextElement) and applied scaled font sizes in Skia/WASM rendering paths. - Added Skia platform text scale factor extensions (Win32/X11/macOS), plus unit/runtime tests and a SamplesApp demo page.
Reviewed changes
Copilot reviewed 31 out of 36 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UWP/UI/ViewManagement/UISettings.UIKit.cs | Adds iOS/tvOS UISettings.TextScaleFactor implementation based on Dynamic Type. |
| src/Uno.UWP/UI/ViewManagement/UISettings.skia.cs | Adds Skia extension interface + resolution/observation for text scale factor. |
| src/Uno.UWP/UI/ViewManagement/UISettings.cs | Wires TextScaleFactor + change notification event plumbing (partial/platform-specific). |
| src/Uno.UWP/UI/ViewManagement/UISettings.Android.cs | Adds Android UISettings.TextScaleFactor implementation from Configuration.FontScale. |
| src/Uno.UI/UI/Xaml/Window/Native/NativeWindow.UIKit.cs | Updates global font scale on iOS content-size category changes. |
| src/Uno.UI/UI/Xaml/Internal/TextScaleHelper.cs | Introduces WinUI logarithmic scaling formula + FeatureConfiguration overrides. |
| src/Uno.UI/UI/Xaml/Internal/CoreServices.cs | Adds global font scale state, update method, and recursive invalidation of text elements. |
| src/Uno.UI/UI/Xaml/Documents/TextElement.cs | Adds inheritable IsTextScaleFactorEnabled DP for text elements/inlines. |
| src/Uno.UI/UI/Xaml/Documents/Inline.skia.cs | Applies scaled font size for Skia inlines; invalidates cached font info on scaling changes. |
| src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.wasm.cs | Applies scaled font size to DOM styling; adds invalidation hook for scale changes. |
| src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.skia.cs | Applies scaled font size in Skia font resolution. |
| src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs | Adds inheritable IsTextScaleFactorEnabled DP (affects measure). |
| src/Uno.UI/UI/Xaml/Controls/RichTextBlock/RichTextBlock.cs | Adds inheritable IsTextScaleFactorEnabled DP (affects measure). |
| src/Uno.UI/UI/Xaml/Controls/Icons/FontIcon.cs | Removes NotImplemented attributes and changes default IsTextScaleFactorEnabled value. |
| src/Uno.UI/UI/Xaml/Controls/Control/Control.cs | Adds inheritable IsTextScaleFactorEnabled DP for controls (affects measure). |
| src/Uno.UI/UI/Xaml/Controls/ContentPresenter/ContentPresenter.cs | Adds inheritable IsTextScaleFactorEnabled DP (affects measure). |
| src/Uno.UI/UI/Xaml/ApplicationActivity.Android.cs | Updates global font scale on Android configuration changes. |
| src/Uno.UI/UI/Xaml/Application.skia.cs | Hooks Skia text scale factor change observation to update global font scale. |
| src/Uno.UI/UI/Xaml/Application.cs | Initializes text scaling during app initialization. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Documents/TextElement.cs | Updates generated stubs to avoid duplicate IsTextScaleFactorEnabled declarations. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/TextBlock.cs | Updates generated stubs to avoid duplicate IsTextScaleFactorEnabled declarations. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/RichTextBlock.cs | Updates generated stubs to avoid duplicate IsTextScaleFactorEnabled declarations. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/Control.cs | Updates generated stubs to avoid duplicate IsTextScaleFactorEnabled declarations. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/ContentPresenter.cs | Updates generated stubs to avoid duplicate IsTextScaleFactorEnabled declarations. |
| src/Uno.UI/FeatureConfiguration.cs | Adds FeatureConfiguration.Font.TextScaleFactor override and broadens scaling config availability. |
| src/Uno.UI.Tests/Windows_UI_Xaml_Internal/Given_TextScaleHelper.cs | Adds unit tests for scaling formula + FeatureConfiguration overrides. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock_TextScaling.cs | Adds runtime tests for scaling enablement and measured-size impact (Skia). |
| src/Uno.UI.Runtime.Skia.X11/UI/ViewManagement/X11TextScaleFactorExtension.cs | Adds X11 DBus-based scale factor reader extension. |
| src/Uno.UI.Runtime.Skia.X11/Hosting/X11ApplicationHost.cs | Registers X11 text scale extension with ApiExtensibility. |
| src/Uno.UI.Runtime.Skia.Win32/UI/ViewManagement/Win32TextScaleFactorExtension.cs | Adds Win32 registry-based scale factor reader extension. |
| src/Uno.UI.Runtime.Skia.Win32/Hosting/Win32Host.cs | Registers Win32 text scale extension with ApiExtensibility. |
| src/Uno.UI.Runtime.Skia.MacOS/UI/ViewManagement/MacOSTextScaleFactorExtension.cs | Adds macOS extension returning 1.0 (documented limitation). |
| src/Uno.UI.Runtime.Skia.MacOS/Hosting/MacSkiaHost.cs | Registers macOS text scale extension with ApiExtensibility. |
| src/SamplesApp/UITests.Shared/Windows_UI_ViewManagement/TextScalingSample.xaml.cs | Adds sample page code-behind displaying current scale and toggling scaling. |
| src/SamplesApp/UITests.Shared/Windows_UI_ViewManagement/TextScalingSample.xaml | Adds sample page UI for visual validation. |
| src/SamplesApp/UITests.Shared/UITests.Shared.projitems | Includes new sample page in SamplesApp build items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22928/wasm-skia-net9/index.html |
|
The build 204728 found UI Test snapshots differences: Details
|
|
@copilot resolve the merge conflicts in this pull request |
…scaling # Conflicts: # src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/ContentPresenter.cs # src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/Control.cs # src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/RichTextBlock.cs # src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Controls/TextBlock.cs # src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Documents/TextElement.cs Co-authored-by: morning4coffe-dev <[email protected]>
|
|
Resolved the merge conflicts in commit Also addressed the code review feedback in commit
|
Agent-Logs-Url: https://github.com/unoplatform/uno/sessions/cca09694-933b-4914-8888-cc44ab42707c Co-authored-by: morning4coffe-dev <[email protected]>
Investigated and pushed fixes in Root causes grouped by behavior:
Direct text-scaling assertions that map into the failing mobile shards:
Local validation:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22928/wasm-skia-net9/index.html |
|
The build 210756 found UI Test snapshots differences: Details
|
…od to private protected
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 39 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22928/wasm-skia-net9/index.html |
|
The build 210843 found UI Test snapshots differences: Details
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22928/wasm-skia-net9/index.html |
|
The build 211011 found UI Test snapshots differences: Details
|
|
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-22928/wasm-skia-net9/index.html |
|
The build 211423 found UI Test snapshots differences: Details
|
Summary
Implements WinUI-compatible text scaling support, allowing Uno Platform apps to respect OS-level accessibility text size settings on all platforms. This was previously stubbed as
[NotImplemented].Closes #19056
Closes #20296
Closes https://github.com/unoplatform/kahua-private/issues/443
What changed
Core infrastructure
TextScaleHelper— Ports the WinUI logarithmic scaling formula (s_o = s_i + max(-e * ln(s_i) + 18, 0) * (f - 1)) fromTextFormatting.cpp. Smaller fonts receive proportionally more scaling than larger fonts, matching WinUI behavior.CoreServices.FontScale— Central font scale state withUpdateFontScale()that firesUISettings.TextScaleFactorChangedand recursively invalidates measure on all text elements when the scale changes.FeatureConfiguration.Font— ExistingIgnoreTextScaleFactorandMaximumTextScaleFactorare wired in; addedTextScaleFactoroverride for testing/manual control.Platform-specific text scale factor reading
FontScalefromResources.Configuration(already provided by the OS).UIFont.PreferredFontForTextStyle(Body).PointSize / 17.0to derive relative scale from Dynamic Type.HKCU\SOFTWARE\Microsoft\Accessibility\TextScaleFactorvia registry P/Invoke.org.gnome.desktop.interface text-scaling-factorvia the freedesktop Settings DBus portal.ITextScaleFactorExtensioninterface viaApiExtensibilitypattern, consistent with other Skia platform extensions.Text control integration
TextBlock,RichTextBlock,ContentPresenter,Control—IsTextScaleFactorEnabledDependencyProperty implemented (default:true, inheritable, affects measure).TextElement—IsTextScaleFactorEnabledDependencyProperty with change callback to invalidate Skia font info.Inline.skia.csappliesTextScaleHelper.GetScaledFontSize()when resolving font size.TextBlock.wasm.csapplies scaled font size to DOM element styles.Application lifecycle
Application.InitializeTextScaling()reads the initial OS text scale factor at startup.ITextScaleFactorExtension.TextScaleFactorChangedfor live updates without app restart.Activity.onConfigurationChanged.UIContentSizeCategoryDidChangeNotification.Generated stubs updated
[NotImplemented]fromTextScaleFactorproperty andTextScaleFactorChangedevent onUISettings.[NotImplemented]fromIsTextScaleFactorEnabledonTextBlock,RichTextBlock,ContentPresenter,Control, andTextElement.Tests
Given_TextScaleHelper) — Validate the logarithmic formula at various font sizes and scale factors, boundary conditions, andFeatureConfigurationoverrides.Given_TextBlock_TextScaling) — VerifyIsTextScaleFactorEnableddefault values, property behavior,UISettings.TextScaleFactorreturns valid values, and (on Skia) that scaled text blocks produce larger measured sizes than unscaled ones.TextScalingSample) — Interactive sample with configurable scale factor slider for visual validation.Test plan
Uno.UI-Skia-only.slnf)Given_TextScaleHelper)Given_TextBlock_TextScaling)IsTextScaleFactorEnabled=falseopts out individual controls🤖 Generated with Claude Code