use bevy::prelude::{AssetServer, Font, FontWeight, Handle, TextFont, default};
use std::path::Path;
pub const EDITOR_FONT_SIZE: f32 = 32.0;
const EDITOR_FONT_ASSET: &str = "fonts/FiraCodeNerdFontMono-Regular.ttf";
pub fn editor_font(asset_server: &AssetServer, font_size: f32) -> TextFont {
TextFont {
font: font_handle(asset_server, EDITOR_FONT_ASSET),
font_size,
weight: FontWeight(400),
..default()
}
}
fn font_handle(asset_server: &AssetServer, asset_path: &str) -> Handle<Font> {
let filesystem_path = Path::new("assets").join(asset_path);
if filesystem_path.is_file() {
asset_server.load(asset_path.to_owned())
} else {
Handle::default()
}
}