Skip to content

Commit

Permalink
statically include font for wasm support
Browse files Browse the repository at this point in the history
  • Loading branch information
tasgon committed Aug 9, 2023
1 parent 03d599d commit 7212d2b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions examples/fonts.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{fs, io};

use bevy::prelude::*;
use bevy_iced::iced::{
font,
Expand All @@ -9,15 +7,16 @@ use bevy_iced::iced::{
use bevy_iced::{iced, IcedContext, IcedPlugin};

const ALPHAPROTA_FONT: Font = Font::with_name("Alpha Prota");
const ALPHAPROTA_FONT_BYTES: &'static [u8] = include_bytes!("../assets/fonts/AlphaProta.ttf");

#[derive(Event)]
pub enum UiMessage {}

pub fn main() -> io::Result<()> {
pub fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(IcedPlugin {
fonts: vec![fs::read("assets/fonts/AlphaProta.ttf")?.leak()],
fonts: vec![ALPHAPROTA_FONT_BYTES],
settings: iced::Settings {
default_text_size: 40.0,
default_font: ALPHAPROTA_FONT,
Expand All @@ -27,8 +26,6 @@ pub fn main() -> io::Result<()> {
.add_event::<UiMessage>()
.add_systems(Update, ui_system)
.run();

Ok(())
}

fn ui_system(mut ctx: IcedContext<UiMessage>) {
Expand Down

0 comments on commit 7212d2b

Please sign in to comment.