pub fn cache<F>(
        &mut self,
        text:       &str,
        text_size:  f32,
        scale:      f32,
        offset:     Vec2<f32>,
        wrap_width: Option<f32>,

        mut callback: F,
    )
      where F: FnMut(Vec2<f32>, Vec2<f32>),
    {
        let mut iter = PlacementIter::new(text, &self.font, Scale::uniform(text_size), offset);
        iter.wrap_width = wrap_width;

        // Cache stuff on gpu
        for PlacementInfo { ref glyph, .. } in iter.clone() {
            self.gpu_cache.queue_glyph(0, glyph.clone());
        }
        let ref mut tex = self.cache_texture;
        self.gpu_cache.cache_queued(|rect, data| {
            tex.load_data_to_region(
                data,
                rect.min.x, rect.min.y,
                rect.width(), rect.height()
            );
        }).unwrap();

        // Output vertices
        for PlacementInfo { ref glyph, .. } in iter {
            if let Ok(Some((uv, pos))) = self.gpu_cache.rect_for(0, glyph) {
                let x1 = (pos.min.x as f32 - offset.x)*scale + offset.x;
                let x2 = (pos.max.x as f32 - offset.x)*scale + offset.x;
                let y1 = (pos.min.y as f32 - offset.y)*scale + offset.y;
                let y2 = (pos.max.y as f32 - offset.y)*scale + offset.y;

                callback(Vec2::new(x1, y1), Vec2::new(uv.min.x, uv.min.y));
                callback(Vec2::new(x2, y1), Vec2::new(uv.max.x, uv.min.y));
                callback(Vec2::new(x2, y2), Vec2::new(uv.max.x, uv.max.y));

                callback(Vec2::new(x1, y1), Vec2::new(uv.min.x, uv.min.y));
                callback(Vec2::new(x2, y2), Vec2::new(uv.max.x, uv.max.y));
                callback(Vec2::new(x1, y2), Vec2::new(uv.min.x, uv.max.y));
            }
        }
    }
/// Passes pairs of positions and uv coordinates to the callback. Three pairs are one triangle,
/// two triangles form one glyph.
Passes pairs of positions and uv coordinates to the callback. Three pairs are one triangle,
two triangles form one glyph.
Passes pairs of positions and uv coordinates to the callback . Three pairs are one triangle two triangles form one glyph .
pub fn cache<F>(
        &mut self,
        text:       &str,
        text_size:  f32,
        scale:      f32,
        offset:     Vec2<f32>,
        wrap_width: Option<f32>,
        mut callback: F,
    )
      where F: FnMut(Vec2<f32>, Vec2<f32>),
    {
        let mut iter = PlacementIter::new(text, &self.font, Scale::uniform(text_size), offset);
        iter.wrap_width = wrap_width;
        // Cache stuff on gpu
        for PlacementInfo { ref glyph, .. } in iter.clone() {
            self.gpu_cache.queue_glyph(0, glyph.clone());
        }
        let ref mut tex = self.cache_texture;
        self.gpu_cache.cache_queued(|rect, data| {
            tex.load_data_to_region(
                data,
                rect.min.x, rect.min.y,
                rect.width(), rect.height()
            );
        }).unwrap();
        // Output vertices
        for PlacementInfo { ref glyph, .. } in iter {
            if let Ok(Some((uv, pos))) = self.gpu_cache.rect_for(0, glyph) {
                let x1 = (pos.min.x as f32 - offset.x)*scale + offset.x;
                let x2 = (pos.max.x as f32 - offset.x)*scale + offset.x;
                let y1 = (pos.min.y as f32 - offset.y)*scale + offset.y;
                let y2 = (pos.max.y as f32 - offset.y)*scale + offset.y;
                callback(Vec2::new(x1, y1), Vec2::new(uv.min.x, uv.min.y));
                callback(Vec2::new(x2, y1), Vec2::new(uv.max.x, uv.min.y));
                callback(Vec2::new(x2, y2), Vec2::new(uv.max.x, uv.max.y));
                callback(Vec2::new(x1, y1), Vec2::new(uv.min.x, uv.min.y));
                callback(Vec2::new(x2, y2), Vec2::new(uv.max.x, uv.max.y));
                callback(Vec2::new(x1, y2), Vec2::new(uv.min.x, uv.max.y));
            }
        }
    }
pub fn cache < F > ( & mut self , text : & str , text_size : f32 , scale : f32 , offset : Vec2 < f32 > , wrap_width : Option < f32 > , mut callback : F , ) where F : FnMut ( Vec2 < f32 > , Vec2 < f32 > ) , { let mut iter = PlacementIter :: new ( text , & self . font , Scale :: uniform ( text_size ) , offset ) ; iter . wrap_width = wrap_width ; // Cache stuff on gpu for PlacementInfo { ref glyph , .. } in iter . clone ( ) { self . gpu_cache . queue_glyph ( 0 , glyph . clone ( ) ) ; } let ref mut tex = self . cache_texture ; self . gpu_cache . cache_queued ( | rect , data | { tex . load_data_to_region ( data , rect . min . x , rect . min . y , rect . width ( ) , rect . height ( ) ) ; } ) . unwrap ( ) ; // Output vertices for PlacementInfo { ref glyph , .. } in iter { if let Ok ( Some ( ( uv , pos ) ) ) = self . gpu_cache . rect_for ( 0 , glyph ) { let x1 = ( pos . min . x as f32 - offset . x ) * scale + offset . x ; let x2 = ( pos . max . x as f32 - offset . x ) * scale + offset . x ; let y1 = ( pos . min . y as f32 - offset . y ) * scale + offset . y ; let y2 = ( pos . max . y as f32 - offset . y ) * scale + offset . y ; callback ( Vec2 :: new ( x1 , y1 ) , Vec2 :: new ( uv . min . x , uv . min . y ) ) ; callback ( Vec2 :: new ( x2 , y1 ) , Vec2 :: new ( uv . max . x , uv . min . y ) ) ; callback ( Vec2 :: new ( x2 , y2 ) , Vec2 :: new ( uv . max . x , uv . max . y ) ) ; callback ( Vec2 :: new ( x1 , y1 ) , Vec2 :: new ( uv . min . x , uv . min . y ) ) ; callback ( Vec2 :: new ( x2 , y2 ) , Vec2 :: new ( uv . max . x , uv . max . y ) ) ; callback ( Vec2 :: new ( x1 , y2 ) , Vec2 :: new ( uv . min . x , uv . max . y ) ) ; } } }
Passes pairs of positions and uv coordinates to the callback.
Passes pairs of positions and uv coordinates to the callback .
&mut self
text
&str
text_size
f32
scale
f32
offset
Vec2<f32>
wrap_width
Option<f32>
callback
F
&mut self
text
&str
text_size
f32
scale
f32
offset
Vec2<f32>
wrap_width
Option<f32>
callback
F