diff options
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -60,7 +60,7 @@ impl FontMetadata { } define_item( &mut image, - 10 + ((width as usize) * (height as usize)), + 14 + ((width as usize) * (height as usize)), 0x00, ); @@ -72,11 +72,12 @@ 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[10..14].copy_from_slice(&(glyph.h_metrics().advance_width).to_le_bytes()); positioned_glyph.draw(|gx: u32, gy: u32, v| { let bit = (v * 255.0) as u8; if gx < width { - define_item(&mut image, (10 + (gy * width) + gx) as usize, bit); + define_item(&mut image, (14 + (gy * width) + gx) as usize, bit); } }); image @@ -145,8 +146,12 @@ fn generate_struct(font: &FontMetadata) -> io::Result<String> { let mut contents = format!( "pub struct {name}Struct {{}} impl BakedFont for {name}Struct {{ + fn font_scale_y() -> f32 {{ + {} + }} fn has_char(&self, c: char) -> bool {{ - match c as u8 {{" + match c as u8 {{", + format!("{}{}",font.scale.y.to_string(),if font.scale.y % 1.0 == 0.0 {".0"} else {""}) ); for char in font.unique_chars() { contents = format!( @@ -197,7 +202,7 @@ use crate::font::BakedFont; name: "Galmuri", font: { Font::try_from_vec(fs::read("assets/fonts/Galmuri11.ttf")?).unwrap() }, charset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz2053: ", - scale: Scale::uniform(20.0), + scale: Scale::uniform(32.0), }, FontMetadata { name: "CherryBombOne", |