Scale text by font size ratio when applying system theme
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s

This commit is contained in:
2026-10-21 14:08:35 +07:00
parent 6122474f9e
commit 36e5a18982
2 changed files with 17 additions and 1 deletions
+8 -1
View File
@@ -37,7 +37,14 @@ fn main() {
}
match SystemTheme::from_system() {
Ok(system) => apply_system_theme(&system, cx),
Ok(mut system) => {
let native = system.light.defaults.font.size;
if native > 0.0 {
let scaling = settings.theme.font_size / native;
system.accessibility.text_scaling_factor *= scaling;
}
apply_system_theme(&system, cx);
}
Err(error) => {
tracing::warn!("native theme unavailable ({error})");
+9
View File
@@ -147,6 +147,15 @@ match native_theme_gpui::SystemTheme::from_system() {
configs, so the subsequent `Theme::change` / `sync_system_appearance` for the
user's `AppearanceMode` picks the right native palette.
Sizing note: gpui-component derives the window rem from `theme.font_size`, so
every rem-relative element scales with it. The OS-reported UI font (13 on
macOS) is smaller than the 16 this app is designed around, so the native path
multiplies `system.accessibility.text_scaling_factor` by
`settings.theme.font_size / native_size` before applying — the connector's
supported scaling knob, which also preserves any OS accessibility scaling.
The same factor scales `mono_font_size`, so code text follows the UI size
(the pre-migration app used 13 for mono while the UI was 16).
On the native path, do **not** set `radius` / `font_size` / `light_theme` /
`dark_theme` etc. on `Theme::global_mut` — the connector owns those fields,
and overwriting them fights its observer.