diff --git a/textium/src/rasterizer.rs b/textium/src/rasterizer.rs index db33635..1fae4b6 100644 --- a/textium/src/rasterizer.rs +++ b/textium/src/rasterizer.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use ::{FontAtlas, GlyphMetadata}; use ::geometry::Rect; use ::texture::{Buffer2d, Bitmap}; -use ::packer::SkylinePacker; +use ::packer::{Packer, GrowingPacker, SkylinePacker}; pub struct Font<'a> { font: rusttype::Font<'a> @@ -27,7 +27,7 @@ impl<'a> Font<'a> { /// `width` and `height` are the starting size of the bitmap. /// /// The packer may enlarge the bitmap beyond its initial dimensions in order to fit all glyphs. - pub fn make_atlas(&self, chrs: I, scale: f32, margin: u32, width: usize, height: usize) + pub fn make_atlas(&self, chrs: I, scale: f32, margin: usize, width: usize, height: usize) -> (FontAtlas, Bitmap, f32) where I: Iterator { @@ -36,7 +36,7 @@ impl<'a> Font<'a> { packer.set_margin(margin); for chr in chrs { if let Some((mut info, rendered)) = self.rasterize_char(chr, scale) { - let r = packer.pack_resize(&rendered); + let r = packer.pack_resize(&rendered, |(w, h)| (w*2, h*2)); info.bounding_box = r; atlas.glyph_data.insert(chr, info); } else if chr == ' ' { @@ -83,8 +83,8 @@ impl<'a> Font<'a> { let data = GlyphMetadata { scale: scale, bounding_box: Rect { - x: bbox.min.x as usize, - y: bbox.min.y as usize, + x: 0_usize, + y: 0_usize, w: bbox.width() as usize, h: bbox.height() as usize, },