Skip to content

Commit

Permalink
Embed and use Fira Sans as default font when testing
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Dec 12, 2024
1 parent 7683bd2 commit 6572909
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ pkg/
Cargo.lock
dist/
traces/
*.sha256
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ all-features = true
maintenance = { status = "actively-developed" }

[features]
default = ["wgpu", "tiny-skia", "fira-sans", "auto-detect-theme"]
default = ["wgpu", "tiny-skia", "auto-detect-theme"]
# Enables the `wgpu` GPU-accelerated renderer backend
wgpu = ["iced_renderer/wgpu", "iced_widget/wgpu"]
# Enables the `tiny-skia` software renderer backend
Expand Down Expand Up @@ -53,13 +53,13 @@ smol = ["iced_futures/smol"]
system = ["iced_winit/system"]
# Enables broken "sRGB linear" blending to reproduce color management of the Web
web-colors = ["iced_renderer/web-colors"]
# Enables the WebGL backend, replacing WebGPU
# Enables the WebGL backend
webgl = ["iced_renderer/webgl"]
# Enables syntax highligthing
highlighter = ["iced_highlighter", "iced_widget/highlighter"]
# Enables the advanced module
advanced = ["iced_core/advanced", "iced_widget/advanced"]
# Embeds Fira Sans as the default font on Wasm builds
# Embeds Fira Sans into the final application; useful for testing and Wasm builds
fira-sans = ["iced_renderer/fira-sans"]
# Auto-detects light/dark mode for the built-in theme
auto-detect-theme = ["iced_core/auto-detect-theme"]
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ iced.workspace = true

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced.workspace = true
iced.features = ["webgl"]
iced.features = ["webgl", "fira-sans"]
2 changes: 1 addition & 1 deletion examples/todos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tracing-subscriber = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced.workspace = true
iced.features = ["debug", "webgl"]
iced.features = ["debug", "webgl", "fira-sans"]

uuid = { version = "1.0", features = ["js"] }
web-sys = { workspace = true, features = ["Window", "Storage"] }
Expand Down
1 change: 1 addition & 0 deletions examples/todos/snapshots/creates_a_new_task.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b41c73d214894bf5f94f787e5f265cff6500822b2d4a29a4ac0c847a71db7123
2 changes: 1 addition & 1 deletion examples/tour/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tracing-subscriber = "0.3"

[target.'cfg(target_arch = "wasm32")'.dependencies]
iced.workspace = true
iced.features = ["image", "debug", "webgl"]
iced.features = ["image", "debug", "webgl", "fira-sans"]

console_error_panic_hook = "0.1"
console_log = "1.0"
6 changes: 3 additions & 3 deletions graphics/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ impl Text {
/// 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] =
#[cfg(feature = "fira-sans")]
pub const FIRA_SANS_REGULAR: &[u8] =
include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice();

/// Returns the global [`FontSystem`].
Expand All @@ -163,7 +163,7 @@ 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"))]
#[cfg(feature = "fira-sans")]
cosmic_text::fontdb::Source::Binary(Arc::new(
include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice(),
)),
Expand Down
2 changes: 1 addition & 1 deletion test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ iced_runtime.workspace = true
iced_tiny_skia.workspace = true

iced_renderer.workspace = true
iced_renderer.features = ["tiny-skia"]
iced_renderer.features = ["tiny-skia", "fira-sans"]

png.workspace = true
sha2.workspace = true
2 changes: 1 addition & 1 deletion test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn interface<'a, Message, Theme>(
let size = Size::new(512.0, 512.0);

let mut renderer = Renderer::Secondary(tiny_skia::Renderer::new(
Font::default(),
Font::with_name("Fira Sans"),
Pixels(16.0),
));

Expand Down

0 comments on commit 6572909

Please sign in to comment.