From a8b5cee6e0a8a7c711195c2da1866bb3180e6425 Mon Sep 17 00:00:00 2001 From: "Dr. Alex Mitre" Date: Sat, 2 May 2026 11:15:00 -0600 Subject: [PATCH] [fix/3505] Use system LANG environment variable for CJK font fallback On Linux/FreeBSD, the cosmic_text FontSystem was hardcoded to use "en" locale, which prevented proper CJK (Chinese/Japanese/Korean) font fallback. The system LANG environment variable contains the user's locale (e.g., zh_CN.UTF-8, ja_JP.UTF-8), which cosmic_text uses to determine which fallback fonts to use for non-Latin characters. This fix reads the LANG environment variable at TextLayoutSystem initialization and uses it to configure the FontSystem locale, ensuring CJK characters display correctly on first render instead of requiring a keypress to trigger re-rendering. Fixes #3505 --- crates/warpui/src/windowing/winit/fonts.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/warpui/src/windowing/winit/fonts.rs b/crates/warpui/src/windowing/winit/fonts.rs index 16e985523b..776a7362a3 100644 --- a/crates/warpui/src/windowing/winit/fonts.rs +++ b/crates/warpui/src/windowing/winit/fonts.rs @@ -300,12 +300,16 @@ impl Default for TextLayoutSystem { impl TextLayoutSystem { pub fn new() -> Self { + let locale = std::env::var("LANG") + .ok() + .filter(|lang| !lang.is_empty()) + .map(cosmic_text::Locale::new) + .unwrap_or_else(|| cosmic_text::Locale::new("en").expect("en is a valid locale")); + Self { families: Default::default(), font_store: RwLock::new(cosmic_text::FontSystem::new_with_locale_and_db( - // Locale is needed for font fallback. For now, we hardcode this to "en" to match - // our mac implementation https://github.com/warpdotdev/warp-internal/blob/bf33d651a9fcece70df8eac35f89b0393ca5189a/ui/src/platform/mac/fonts.rs#L383. - "en".into(), + locale, Default::default(), )), font_id_map: Default::default(),