@ -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 < I > ( & self , chrs : I , scale : f32 , margin : u32 , width : usize , height : usize )
pub fn make_atlas < I > ( & self , chrs : I , scale : f32 , margin : usize , width : usize , height : usize )
-> ( FontAtlas , Bitmap < u8 > , f32 )
where I : Iterator < Item = char >
{
@ -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 ,
} ,