mirror of
https://github.com/storytold/effectcraft.git
synced 2026-11-03 06:52:21 -06:00
text, ui: follow a language change, and resolve the language before the fonts
Review follow-ups on #312: - `crates/ui-egui/src/theme.rs`'s `japanese_font_tests` still called `install` with two arguments, so `cargo test` did not compile. Every call site now passes a language. - The call sites passed the stored `general.language` preference. With the default `system` that is `""`, which handed the CJK choice back to the environment locale — one macOS and Windows usually do not set. They now pass `crate::i18n::language(app)`, the resolved language, so Match System draws Chinese on a Chinese system. - Changing Settings ▸ General ▸ Language only reached the fonts on the first frame. `EffectcraftApp` now remembers the language its fonts were installed for and installs them again when it changes, so the switch applies without a restart. - Documented that `fonts::set_cjk_locale` is process-global: the Han preference therefore applies to composition text as well as the interface chrome (docs/preferences.md and the function's own comment). Rebased onto main after #309 landed — `header.rs` gained an `install` call site in the meantime, and the catalogs now resolve through `i18n::language`.
This commit is contained in:
@@ -576,7 +576,8 @@ static REQUESTED_CJK_LOCALE: RwLock<Option<String>> = RwLock::new(None);
|
||||
/// environment, so a Chinese interface is drawn with a Chinese face on a machine whose locale is
|
||||
/// Japanese (and the other way round). The interface sets this from its language setting; an empty
|
||||
/// tag, `c` or `posix` clears the request and returns to the environment. Process-global, like the
|
||||
/// environment it replaces.
|
||||
/// environment it replaces: every layout in the process follows it, so composition text is drawn
|
||||
/// with the same language's Han forms as the interface, not only the interface chrome.
|
||||
pub fn set_cjk_locale(tag: &str) {
|
||||
let tag = tag.trim().to_ascii_lowercase();
|
||||
let requested = if tag.is_empty() || tag == "c" || tag == "posix" { None } else { Some(tag) };
|
||||
|
||||
Reference in New Issue
Block a user