diff options
-rw-r--r-- | build.rs | 14 | ||||
-rw-r--r-- | src/render.rs | 51 |
2 files changed, 60 insertions, 5 deletions
@@ -57,7 +57,8 @@ impl FontMetadata { } // TODO: do we *really* need i32 values here? wouldn't i16 be sufficient? image[2..6].copy_from_slice(&pixel_bounding_box.min.x.to_le_bytes()); - image[6..10].copy_from_slice(&(pixel_bounding_box.min.y + (scale.y / 2.0) as i32).to_le_bytes()); + image[6..10] + .copy_from_slice(&(pixel_bounding_box.min.y + (scale.y / 2.0) as i32).to_le_bytes()); image[10..14].copy_from_slice(&(glyph.h_metrics().advance_width).to_le_bytes()); positioned_glyph.draw(|gx: u32, gy: u32, v| { @@ -137,7 +138,11 @@ impl BakedFont for {name}Struct {{ }} fn has_char(&self, c: char) -> bool {{ match c as u8 {{", - format!("{}{}",font.scale.y.to_string(),if font.scale.y % 1.0 == 0.0 {".0"} else {""}) + format!( + "{}{}", + font.scale.y.to_string(), + if font.scale.y % 1.0 == 0.0 { ".0" } else { "" } + ) ); for char in font.unique_chars() { contents = format!( @@ -180,12 +185,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { fs::create_dir_all("src/generated")?; let mut modrs = "// Copyright is a sham this is a @generated file. use crate::font::BakedFont; -".to_string(); +" + .to_string(); let fonts = [ FontMetadata { name: "Galmuri", font: { Font::try_from_vec(fs::read("assets/fonts/Galmuri11.ttf")?).unwrap() }, - charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz2053: ", + charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz29053: %,", scale: Scale::uniform(20.0), }, FontMetadata { diff --git a/src/render.rs b/src/render.rs index 298b7ed..6be2ba6 100644 --- a/src/render.rs +++ b/src/render.rs @@ -200,6 +200,55 @@ pub fn render( } } } + // We did most of this at mountainbytes + { + let mut offset = 0.0; + let mut rng = rand::thread_rng(); + + for c in "we did 90% onsite at mountainbytes 2025,".chars() { + let char = FONT_GALMURI.get_char(c); + canvas + .copy( + &char + .to_texture( + texture_creator, + Color::RGB(colourthing, 64, 255 - colourthing), + ) + .unwrap(), + None, + char.to_rect( + offset as i32 + 18 + rng.gen_range(-2..2), + win_size.1 as i32 - 64 + rng.gen_range(-2..2), + ), + ) + .unwrap(); + offset += char.advance_width; + } + } + { + let mut offset = 0.0; + let mut rng = rand::thread_rng(); + + for c in "the rest 2 months ago".chars() { + let char = FONT_GALMURI.get_char(c); + canvas + .copy( + &char + .to_texture( + texture_creator, + Color::RGB(colourthing, 64, 255 - colourthing), + ) + .unwrap(), + None, + char.to_rect( + offset as i32 + 24 + rng.gen_range(-2..2), + win_size.1 as i32 - 32 + rng.gen_range(-2..2), + ), + ) + .unwrap(); + offset += char.advance_width; + } + } // Sorry for shit invite { let mut offset = 0.0; @@ -218,7 +267,7 @@ pub fn render( None, char.to_rect( offset as i32 + 18 + rng.gen_range(-2..2), - win_size.1 as i32 - 24 + rng.gen_range(-2..2), + win_size.1 as i32 - 96 + rng.gen_range(-2..2), ), ) .unwrap(); |