Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/warpui/src/windowing/winit/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Comment on lines +303 to +307

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 [CRITICAL] This does not type-check with the locked cosmic-text API: FontSystem::new_with_locale_and_db expects a String, and cosmic_text::Locale is not part of that API. Keep this as a String and normalize the POSIX LANG value before passing it through.

Suggested change
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"));
let locale = std::env::var("LANG")
.ok()
.and_then(|lang| lang.split('.').next().map(str::to_string))
.filter(|lang| !lang.is_empty())
.map(|lang| lang.replace('_', "-"))
.unwrap_or_else(|| "en".to_string());


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(),
Expand Down