add WguiFontSystem, remove FONT_SYSTEM singleton, custom fonts, add Light font weight

there are a few gzip-compressed ttf as for now, looks like variable fonts aren't parsed properly by cosmic_text. Not sure why. Also, we probably need to have a fallback for CJK characters in the future, or just fallback to the built-in ones in the OS.
This commit is contained in:
Aleksander
2025-11-07 22:21:57 +01:00
parent d2c23ac6a9
commit 71898056f3
33 changed files with 202 additions and 65 deletions

View File

@@ -13,7 +13,6 @@ use parking_lot::Mutex;
use crate::drawing::{self};
pub static FONT_SYSTEM: LazyLock<Mutex<FontSystem>> = LazyLock::new(|| Mutex::new(FontSystem::new()));
pub static SWASH_CACHE: LazyLock<Mutex<SwashCache>> = LazyLock::new(|| Mutex::new(SwashCache::new()));
/// Used in case no `font_size` is defined
@@ -102,6 +101,7 @@ impl From<FontStyle> for Style {
#[derive(Default, Debug, Clone, Copy)]
pub enum FontWeight {
Light,
#[default]
Normal,
Bold,
@@ -110,6 +110,7 @@ pub enum FontWeight {
impl From<FontWeight> for Weight {
fn from(value: FontWeight) -> Self {
match value {
FontWeight::Light => Self::LIGHT,
FontWeight::Normal => Self::NORMAL,
FontWeight::Bold => Self::BOLD,
}