diff options
fix: format
-rw-r--r-- | build.rs | 21 | ||||
-rw-r--r-- | src/font.rs | 12 |
2 files changed, 20 insertions, 13 deletions
@@ -104,7 +104,7 @@ fn save_bits_to_file(font: &FontMetadata, char: u8, bits: &[u8]) -> io::Result<( fn to_upper_snake_with_first_upper_preceeded_by_underscore(str: String) -> String { let mut str = str; for char in "ABCDEFGHIJKLMNOPQRSTUVWXYZ".chars() { - str = str.replace(char,format!("_{char}").as_str()); + str = str.replace(char, format!("_{char}").as_str()); } str.to_uppercase() } @@ -131,7 +131,8 @@ impl BakedFont for {name}Struct {{ }} fn get_char_bytes(&self, c: char) -> &'static [u8] {{ match c as u8 {{ -"); +" + ); for char in font.unique_chars() { contents = format!( "{contents} {} => include_bytes!(\"../../assets/computed-fonts/{}/{}.bin\"), @@ -146,16 +147,19 @@ impl BakedFont for {name}Struct {{ }} pub const FONT{}: {name}Struct = {name}Struct{{ }}; -", to_upper_snake_with_first_upper_preceeded_by_underscore(name.to_string()) +", + to_upper_snake_with_first_upper_preceeded_by_underscore(name.to_string()) ); Ok(contents) } fn main() -> Result<(), Box<dyn std::error::Error>> { fs::create_dir_all("src/generated")?; - let mut modrs = format!("// Copyright is a sham this is a @generated file. + let mut modrs = format!( + "// Copyright is a sham this is a @generated file. use crate::font::BakedFont; -"); +" + ); let fonts = [ FontMetadata { name: "Galmuri", @@ -169,8 +173,11 @@ use crate::font::BakedFont; }, ]; for font in fonts { - modrs=format!("{modrs}{} -",generate_struct(&font)?); + modrs = format!( + "{modrs}{} +", + generate_struct(&font)? + ); exec(font)?; } File::create(&"src/generated/fonts.rs")?.write_all(modrs.as_bytes())?; diff --git a/src/font.rs b/src/font.rs index 92c0f6b..d82d5a9 100644 --- a/src/font.rs +++ b/src/font.rs @@ -24,13 +24,13 @@ pub struct RenderableCharacter { pub data: &'static [u8], } /** - A trait describing a generated font. - We use traits implemented by each font because it's somehow optimized better in preliminary testing(?) - */ + A trait describing a generated font. + We use traits implemented by each font because it's somehow optimized better in preliminary testing(?) +*/ pub trait BakedFont { - fn has_char(&self,character: char) -> bool; - fn get_char_bytes(&self,character: char) -> &'static [u8]; - fn get_char(&self,character: char) -> RenderableCharacter { + fn has_char(&self, character: char) -> bool; + fn get_char_bytes(&self, character: char) -> &'static [u8]; + fn get_char(&self, character: char) -> RenderableCharacter { let bytes = self.get_char_bytes(character); let width = (bytes[0] as u16) | (bytes[1] as u16 >> 8); let data = &bytes[2..]; |