diff --git a/Cargo.toml b/Cargo.toml index 5961516..2506361 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,7 @@ const_format = { version = "0.2.22", default-features = false, features = ["fmt" cfg-if = "1.0.0" exmex = { git = "https://github.com/Titaniumtown/exmex.git", branch = "main", features = ["partial"] } lazy_static = "1.4.0" +tar = "0.4.38" [build-dependencies] shadow-rs = "0.9" diff --git a/assets/fonts.tar b/assets/fonts.tar new file mode 100644 index 0000000..37070fd Binary files /dev/null and b/assets/fonts.tar differ diff --git a/assets/fonts/Hack-Regular.ttf b/assets/fonts/Hack-Regular.ttf deleted file mode 100644 index 92a90cb..0000000 Binary files a/assets/fonts/Hack-Regular.ttf and /dev/null differ diff --git a/assets/fonts/NotoEmoji-Regular.ttf b/assets/fonts/NotoEmoji-Regular.ttf deleted file mode 100644 index 19b7bad..0000000 Binary files a/assets/fonts/NotoEmoji-Regular.ttf and /dev/null differ diff --git a/assets/fonts/Ubuntu-Light.ttf b/assets/fonts/Ubuntu-Light.ttf deleted file mode 100644 index 0e9f90d..0000000 Binary files a/assets/fonts/Ubuntu-Light.ttf and /dev/null differ diff --git a/src/egui_app.rs b/src/egui_app.rs index aec0f90..53d2823 100644 --- a/src/egui_app.rs +++ b/src/egui_app.rs @@ -14,6 +14,7 @@ use include_flate::flate; use instant::Duration; use shadow_rs::shadow; use std::collections::BTreeMap; +use std::io::Read; use std::ops::{BitXorAssign, RangeInclusive}; shadow!(build); @@ -42,21 +43,47 @@ const DEFAULT_MAX_X: f64 = 10.0; const DEFAULT_INTEGRAL_NUM: usize = 100; // Font Data -flate!(static UBUNTU_LIGHT_FILE: [u8] from "assets/fonts/Ubuntu-Light.ttf"); -flate!(static NOTOEMOJI_FILE: [u8] from "assets/fonts/NotoEmoji-Regular.ttf"); -flate!(static HACK_FILE: [u8] from "assets/fonts/Hack-Regular.ttf"); +flate!(static FONTS_FILE: [u8] from "assets/fonts.tar"); lazy_static::lazy_static! { static ref FONT_DEFINITIONS: FontDefinitions = { + let mut tar_archive = tar::Archive::new(&**FONTS_FILE); + + let mut ubuntu_light: Result = Err(""); + let mut notoemoji: Result = Err(""); + let mut hack: Result = Err(""); + + for file in tar_archive.entries().unwrap() { + let mut file = file.unwrap(); + let mut data: Vec = Vec::new(); + file.read_to_end(&mut data).unwrap(); + let path = &file.header().path().unwrap(); + + match (path).to_string_lossy().as_ref() { + "Hack-Regular.ttf" => { + hack = Ok(FontData::from_owned(data)) + }, + "NotoEmoji-Regular.ttf" => { + notoemoji = Ok(FontData::from_owned(data)) + }, + "Ubuntu-Light.ttf" => { + ubuntu_light = Ok(FontData::from_owned(data)) + }, + _ => { + panic!("Other files in this archive!!"); + } + } + } + let mut font_data: BTreeMap = BTreeMap::new(); let mut families = BTreeMap::new(); font_data.insert( "Hack".to_owned(), - FontData::from_static(&HACK_FILE), + hack.unwrap(), ); - font_data.insert("Ubuntu-Light".to_owned(), FontData::from_static(&UBUNTU_LIGHT_FILE)); - font_data.insert("NotoEmoji-Regular".to_owned(), FontData::from_static(&NOTOEMOJI_FILE)); + font_data.insert("Ubuntu-Light".to_owned(), ubuntu_light.unwrap()); + font_data.insert("NotoEmoji-Regular".to_owned(), notoemoji.unwrap()); families.insert( FontFamily::Monospace,