diff --git a/assets/voxygen/i18n/sv.ron b/assets/voxygen/i18n/sv.ron index 5a914e423a..45071db229 100644 --- a/assets/voxygen/i18n/sv.ron +++ b/assets/voxygen/i18n/sv.ron @@ -23,7 +23,24 @@ asset_key: "voxygen.font.OpenSans-Regular", scale_ratio: 1.0, ), + "metamorph": Font ( + asset_key: "voxygen.font.Metamorphous-Regular", + scale_ratio: 1.0, + ), + "alkhemi": Font ( + asset_key: "voxygen.font.Alkhemikal", + scale_ratio: 1.0, + ), + "wizard": Font ( + asset_key: "voxygen.font.wizard", + scale_ratio: 1.0, + ), + "cyri": Font ( + asset_key: "voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", + scale_ratio: 1.0, + ), }, + string_map: { /// Start Common section // Texts used in multiple locations with the same formatting diff --git a/voxygen/src/menu/char_selection/ui/mod.rs b/voxygen/src/menu/char_selection/ui/mod.rs index d6358622cf..ac9e761fcf 100644 --- a/voxygen/src/menu/char_selection/ui/mod.rs +++ b/voxygen/src/menu/char_selection/ui/mod.rs @@ -1368,12 +1368,10 @@ impl CharSelectionUi { let font = { use std::io::Read; let mut buf = Vec::new(); - common::assets::load_file("voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", &[ - "ttf", - ]) - .unwrap() - .read_to_end(&mut buf) - .unwrap(); + common::assets::load_file(&i18n.fonts.get("cyri").unwrap().asset_key, &["ttf"]) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); ui::ice::Font::try_from_vec(buf).unwrap() }; @@ -1434,7 +1432,17 @@ impl CharSelectionUi { } pub fn update_language(&mut self, i18n: std::sync::Arc) { + let font = { + use std::io::Read; + let mut buf = Vec::new(); + common::assets::load_file(&i18n.fonts.get("cyri").unwrap().asset_key, &["ttf"]) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); + ui::ice::Font::try_from_vec(buf).unwrap() + }; self.controls.i18n = i18n; + self.ui.clear_fonts(font); self.controls.fonts = Fonts::load(&self.controls.i18n.fonts, &mut self.ui) .expect("Impossible to load fonts!"); } diff --git a/voxygen/src/menu/main/ui/mod.rs b/voxygen/src/menu/main/ui/mod.rs index 93e623e714..0790e4eb37 100644 --- a/voxygen/src/menu/main/ui/mod.rs +++ b/voxygen/src/menu/main/ui/mod.rs @@ -490,12 +490,10 @@ impl<'a> MainMenuUi { let font = { use std::io::Read; let mut buf = Vec::new(); - common::assets::load_file("voxygen.font.haxrcorp_4089_cyrillic_altgr_extended", &[ - "ttf", - ]) - .unwrap() - .read_to_end(&mut buf) - .unwrap(); + common::assets::load_file(&i18n.fonts.get("cyri").unwrap().asset_key, &["ttf"]) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); Font::try_from_vec(buf).unwrap() }; @@ -522,7 +520,17 @@ impl<'a> MainMenuUi { } pub fn update_language(&mut self, i18n: std::sync::Arc, settings: &Settings) { + let font = { + use std::io::Read; + let mut buf = Vec::new(); + common::assets::load_file(&i18n.fonts.get("cyri").unwrap().asset_key, &["ttf"]) + .unwrap() + .read_to_end(&mut buf) + .unwrap(); + Font::try_from_vec(buf).unwrap() + }; self.controls.i18n = i18n; + self.ui.clear_fonts(font); self.controls.fonts = Fonts::load(&self.controls.i18n.fonts, &mut self.ui) .expect("Impossible to load fonts!"); let language_metadatas = crate::i18n::list_localizations(); diff --git a/voxygen/src/ui/ice/cache.rs b/voxygen/src/ui/ice/cache.rs index fc38f5366a..ac8b8f87fc 100644 --- a/voxygen/src/ui/ice/cache.rs +++ b/voxygen/src/ui/ice/cache.rs @@ -69,6 +69,21 @@ impl Cache { FontId(id) } + /// Allows clearing out the fonts when switching languages + pub fn clear_fonts(&mut self, default_font: Font) { + self.glyph_brush = RefCell::new( + self.glyph_brush + .get_mut() + .to_builder() + .replace_fonts(|mut fonts| { + fonts.clear(); + fonts.push(default_font); + fonts + }) + .build(), + ); + } + pub fn graphic_cache(&self) -> &GraphicCache { &self.graphic_cache } pub fn graphic_cache_mut(&mut self) -> &mut GraphicCache { &mut self.graphic_cache } diff --git a/voxygen/src/ui/ice/mod.rs b/voxygen/src/ui/ice/mod.rs index 23b7afd976..b7f20b05e6 100644 --- a/voxygen/src/ui/ice/mod.rs +++ b/voxygen/src/ui/ice/mod.rs @@ -65,6 +65,9 @@ impl IcedUi { /// Add a new font that is referncable via the returned Id pub fn add_font(&mut self, font: RawFont) -> FontId { self.renderer.add_font(font) } + /// Allows clearing out the fonts when switching languages + pub fn clear_fonts(&mut self, default_font: Font) { self.renderer.clear_fonts(default_font); } + /// Add a new graphic that is referencable via the returned Id pub fn add_graphic(&mut self, graphic: Graphic) -> graphic::Id { self.renderer.add_graphic(graphic) diff --git a/voxygen/src/ui/ice/renderer/mod.rs b/voxygen/src/ui/ice/renderer/mod.rs index c697d36f81..20396bb0ff 100644 --- a/voxygen/src/ui/ice/renderer/mod.rs +++ b/voxygen/src/ui/ice/renderer/mod.rs @@ -146,6 +146,9 @@ impl IcedRenderer { pub fn add_font(&mut self, font: RawFont) -> FontId { self.cache.add_font(font) } + /// Allows clearing out the fonts when switching languages + pub fn clear_fonts(&mut self, default_font: Font) { self.cache.clear_fonts(default_font); } + pub fn add_graphic(&mut self, graphic: Graphic) -> graphic::Id { self.cache.add_graphic(graphic) }