summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-20 03:20:58 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-02-20 03:20:58 +0100
commit35e2049ee668791f67b5325fc156b8c042d26d49 (patch)
tree3db828501fedac26342c41fcec05d0e9a7477f0f /graphics
parent0c7f4eaab5b5c19b914a8eed548349388bbd6300 (diff)
downloadiced-35e2049ee668791f67b5325fc156b8c042d26d49.tar.gz
iced-35e2049ee668791f67b5325fc156b8c042d26d49.tar.bz2
iced-35e2049ee668791f67b5325fc156b8c042d26d49.zip
Embed Fira Sans font on Wasm builds by default
Diffstat (limited to 'graphics')
-rw-r--r--graphics/Cargo.toml1
-rw-r--r--graphics/fonts/FiraSans-Regular.ttfbin0 -> 440984 bytes
-rw-r--r--graphics/src/text.rs13
3 files changed, 14 insertions, 0 deletions
diff --git a/graphics/Cargo.toml b/graphics/Cargo.toml
index 907f3705..0ee6ff47 100644
--- a/graphics/Cargo.toml
+++ b/graphics/Cargo.toml
@@ -18,6 +18,7 @@ all-features = true
geometry = ["lyon_path"]
image = ["dep:image", "kamadak-exif"]
web-colors = []
+fira-sans = []
[dependencies]
iced_core.workspace = true
diff --git a/graphics/fonts/FiraSans-Regular.ttf b/graphics/fonts/FiraSans-Regular.ttf
new file mode 100644
index 00000000..6f806474
--- /dev/null
+++ b/graphics/fonts/FiraSans-Regular.ttf
Binary files differ
diff --git a/graphics/src/text.rs b/graphics/src/text.rs
index 217a23e2..0310ead7 100644
--- a/graphics/src/text.rs
+++ b/graphics/src/text.rs
@@ -17,6 +17,15 @@ use once_cell::sync::OnceCell;
use std::borrow::Cow;
use std::sync::{Arc, RwLock, Weak};
+/// The regular variant of the [Fira Sans] font.
+///
+/// It is loaded as part of the default fonts in Wasm builds.
+///
+/// [Fira Sans]: https://mozilla.github.io/Fira/
+#[cfg(all(target_arch = "wasm32", feature = "fira-sans"))]
+pub const FIRA_SANS_REGULAR: &'static [u8] =
+ include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice();
+
/// Returns the global [`FontSystem`].
pub fn font_system() -> &'static RwLock<FontSystem> {
static FONT_SYSTEM: OnceCell<RwLock<FontSystem>> = OnceCell::new();
@@ -27,6 +36,10 @@ pub fn font_system() -> &'static RwLock<FontSystem> {
cosmic_text::fontdb::Source::Binary(Arc::new(
include_bytes!("../fonts/Iced-Icons.ttf").as_slice(),
)),
+ #[cfg(all(target_arch = "wasm32", feature = "fira-sans"))]
+ cosmic_text::fontdb::Source::Binary(Arc::new(
+ include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice(),
+ )),
]),
version: Version::default(),
})