forked from 1b-agent/opencadstudio-upstream
Follow the system UI font face
Detect the desktop's configured interface font and use its family for all application UI text, instead of iced's generic sans-serif. - sys::ui_font reads the setting per platform: GNOME/Cinnamon/MATE gsettings, KDE kdeglobals, Xfce xfconf, the XDG Settings portal, GTK settings.ini and a Fontconfig fallback on Linux; the non-client message font (SystemParametersInfoForDpi at 96 DPI) on Windows; the AppKit system font on macOS. - ui_font::apply remaps generic sans-serif in iced's shared font database to that family. iced's Font::DEFAULT is sans-serif, so every widget, canvas text, bold/italic variant and ribbon measurement follows it with no call-site changes. A family that is not installed (or a generic alias) keeps iced's own choice. The font's weight and style are ignored. - Live updates: portal SettingChanged on Linux, a 2 s poll on Windows. A change bumps the font-system version so laid-out text reshapes, and iced::font::set_defaults relays out every window; ribbon large-button widths re-measure. Without a portal, Linux needs a restart; macOS has no user-adjustable UI font. - Monospaced text, drawing text (own cosmic-text font systems) and the web build's font loading are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bec9e63679
commit
62175f4ed5
10 files changed
+1134
-7
No files matched your search
@@ -146,6 +146,22 @@ pub(in crate::app) const VIEWPORT_CAPTURE_BOUNDS_ID: &str = "viewport-capture-bo
|
||||
|
||||
const VIEWCUBE_HIT_SIZE: f32 = VIEWCUBE_REGION_PX;
|
||||
|
||||
/// Desktop UI-font changes while running. Linux listens for the Settings
|
||||
/// portal's `SettingChanged` (no portal: restart to apply). Windows exposes no
|
||||
/// change notification through iced, but the metrics read is a cheap system
|
||||
/// call, so it is polled. macOS has no user-adjustable UI font, and the web
|
||||
/// build follows the font it loads for the UI language.
|
||||
fn ui_font_changes() -> Subscription<Message> {
|
||||
#[cfg(target_os = "linux")]
|
||||
return Subscription::run(crate::sys::ui_font::change_signals)
|
||||
.map(|()| Message::UiFontSettingsChanged);
|
||||
#[cfg(target_os = "windows")]
|
||||
return iced::time::every(std::time::Duration::from_secs(2))
|
||||
.map(|_| Message::UiFontSettingsChanged);
|
||||
#[allow(unreachable_code)]
|
||||
Subscription::none()
|
||||
}
|
||||
|
||||
/// Background used by drafting overlays in model or paper space.
|
||||
fn crosshair_background(tab: &DocumentTab, is_paper: bool) -> [f32; 4] {
|
||||
if !is_paper {
|
||||
@@ -3052,6 +3068,7 @@ impl OpenCADStudio {
|
||||
single_instance,
|
||||
hatch_pattern_keys,
|
||||
keyboard_events,
|
||||
ui_font_changes(),
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user