From bad46d272223482bf53f56efa11df82eb41a467d Mon Sep 17 00:00:00 2001 From: Jasper Bekkers Date: Fri, 18 Nov 2022 11:33:49 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=8D=AE=20Add=20custom=20font=20suppor?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/font/mod.rs | 2 ++ src/font/system/no_std.rs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/font/mod.rs b/src/font/mod.rs index f393894a1e..e665889fab 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -29,6 +29,8 @@ impl<'a> Font<'a> { } #[cfg(feature = "std")] fontdb::Source::SharedFile(_path, data) => data.deref().as_ref(), + #[cfg(not(feature = "std"))] + _ => { todo!(""); } }; Some(Self { diff --git a/src/font/system/no_std.rs b/src/font/system/no_std.rs index ce12475395..fff130831f 100644 --- a/src/font/system/no_std.rs +++ b/src/font/system/no_std.rs @@ -16,13 +16,10 @@ pub struct FontSystem{ impl FontSystem { pub fn new() -> Self { - //TODO: get locale from argument? let locale = "en-US".to_string(); - //TODO: allow loading fonts from memory let mut db = fontdb::Database::new(); { - //TODO: configurable default fonts db.set_monospace_family("Fira Mono"); db.set_sans_serif_family("Fira Sans"); db.set_serif_family("DejaVu Serif"); @@ -34,6 +31,13 @@ impl FontSystem { } } + pub fn new_with_locale_and_db(locale: &str, db: fontdb::Database) -> Self { + Self { + locale: locale.to_string(), + db + } + } + pub fn locale(&self) -> &str { &self.locale } From d1e971152efbf22dce90238d19236b01d9f6898b Mon Sep 17 00:00:00 2001 From: Jasper Bekkers Date: Mon, 21 Nov 2022 12:00:54 +0100 Subject: [PATCH 2/2] Revert incorrect change --- src/font/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/font/mod.rs b/src/font/mod.rs index e665889fab..f393894a1e 100644 --- a/src/font/mod.rs +++ b/src/font/mod.rs @@ -29,8 +29,6 @@ impl<'a> Font<'a> { } #[cfg(feature = "std")] fontdb::Source::SharedFile(_path, data) => data.deref().as_ref(), - #[cfg(not(feature = "std"))] - _ => { todo!(""); } }; Some(Self {