fn layout_pending(&mut self) {
        // Nothing to do if nothing is pending
        if self.pending.len() == 0 { return; }

        // Take the pending characters to be processed
        let pending         = mem::take(&mut self.pending);

        // Shape the pending text
        let ttf_font        = self.font.ttf_font();
        let mut shaper      = self.font.allsorts_font();
        let glyphs          = shaper.map_glyphs(&pending, MatchingPresentation::NotRequired);
        let shape           = shaper.shape(glyphs, tag::LATN, Some(tag::DFLT), &gsub::Features::Mask(gsub::GsubFeatureMask::default()), true).ok()
            .unwrap_or_else(|| vec![]);

        // The scale factor is used to convert between font units and screen units
        let scale_factor    = self.em_size / self.units_per_em;

        // Generate the glyph positions
        for glyph in shape {
            // Fetch information about this glyph
            let glyph_index     = ttf_parser::GlyphId(glyph.glyph.glyph_index as _);
            let advance_x       = ttf_font.glyph_hor_advance(glyph_index);
            let advance_y       = ttf_font.glyph_ver_advance(glyph_index);
            let advance_x       = if let Some(advance) = advance_x { advance } else { 0 };
            let advance_y       = if let Some(advance) = advance_y { advance } else { 0 };

            // Adjust by any requested offset
            let (off_x, off_y)  = match glyph.placement {
                gpos::Placement::None           => (0.0, 0.0),
                gpos::Placement::Distance(x, y) => (x as f32, y as f32),
                gpos::Placement::Anchor(_ ,_)   => (0.0, 0.0), // TODO: https://docs.microsoft.com/en-us/typography/opentype/spec/gpos#lookup-type-3-cursive-attachment-positioning-subtable
            };
            let off_x           = off_x * scale_factor;
            let off_y           = off_y * scale_factor;

            // Push this glyph
            let glyph_pos       = GlyphPosition {
                id:         GlyphId(glyph.glyph.glyph_index as _),
                location:   (self.x_off + off_x, self.y_off + off_y),
                em_size:    self.em_size
            };
            self.layout.push(LayoutAction::Glyph(glyph_pos));

            // Move to the next position
            let advance_x       = (advance_x as f32) + (glyph.kerning as f32);
            let advance_y       = advance_y as f32;
            let advance_x       = advance_x * scale_factor;
            let advance_y       = advance_y * scale_factor;

            let last_x          = self.x_off;
            let last_y          = self.y_off;

            self.x_off          += advance_x + off_x;
            self.y_off          += advance_y + off_y;

            // The inner bounds just uses the x, y offsets to amend the bounding box
            self.metrics.inner_bounds = self.metrics.inner_bounds.union_bounds((Coord2(last_x as _, last_y as _), Coord2(self.x_off as _, self.y_off as _)));
        }
    }
///
/// Performs layout on the pending string
///
Performs layout on the pending string
Performs layout on the pending string
fn layout_pending(&mut self) {
        // Nothing to do if nothing is pending
        if self.pending.len() == 0 { return; }
        // Take the pending characters to be processed
        let pending         = mem::take(&mut self.pending);
        // Shape the pending text
        let ttf_font        = self.font.ttf_font();
        let mut shaper      = self.font.allsorts_font();
        let glyphs          = shaper.map_glyphs(&pending, MatchingPresentation::NotRequired);
        let shape           = shaper.shape(glyphs, tag::LATN, Some(tag::DFLT), &gsub::Features::Mask(gsub::GsubFeatureMask::default()), true).ok()
            .unwrap_or_else(|| vec![]);
        // The scale factor is used to convert between font units and screen units
        let scale_factor    = self.em_size / self.units_per_em;
        // Generate the glyph positions
        for glyph in shape {
            // Fetch information about this glyph
            let glyph_index     = ttf_parser::GlyphId(glyph.glyph.glyph_index as _);
            let advance_x       = ttf_font.glyph_hor_advance(glyph_index);
            let advance_y       = ttf_font.glyph_ver_advance(glyph_index);
            let advance_x       = if let Some(advance) = advance_x { advance } else { 0 };
            let advance_y       = if let Some(advance) = advance_y { advance } else { 0 };
            // Adjust by any requested offset
            let (off_x, off_y)  = match glyph.placement {
                gpos::Placement::None           => (0.0, 0.0),
                gpos::Placement::Distance(x, y) => (x as f32, y as f32),
                gpos::Placement::Anchor(_ ,_)   => (0.0, 0.0), // TODO: https://docs.microsoft.com/en-us/typography/opentype/spec/gpos#lookup-type-3-cursive-attachment-positioning-subtable
            };
            let off_x           = off_x * scale_factor;
            let off_y           = off_y * scale_factor;
            // Push this glyph
            let glyph_pos       = GlyphPosition {
                id:         GlyphId(glyph.glyph.glyph_index as _),
                location:   (self.x_off + off_x, self.y_off + off_y),
                em_size:    self.em_size
            };
            self.layout.push(LayoutAction::Glyph(glyph_pos));
            // Move to the next position
            let advance_x       = (advance_x as f32) + (glyph.kerning as f32);
            let advance_y       = advance_y as f32;
            let advance_x       = advance_x * scale_factor;
            let advance_y       = advance_y * scale_factor;
            let last_x          = self.x_off;
            let last_y          = self.y_off;
            self.x_off          += advance_x + off_x;
            self.y_off          += advance_y + off_y;
            // The inner bounds just uses the x, y offsets to amend the bounding box
            self.metrics.inner_bounds = self.metrics.inner_bounds.union_bounds((Coord2(last_x as _, last_y as _), Coord2(self.x_off as _, self.y_off as _)));
        }
    }
fn layout_pending ( & mut self ) { // Nothing to do if nothing is pending if self . pending . len ( ) == 0 { return ; } // Take the pending characters to be processed let pending = mem :: take ( & mut self . pending ) ; // Shape the pending text let ttf_font = self . font . ttf_font ( ) ; let mut shaper = self . font . allsorts_font ( ) ; let glyphs = shaper . map_glyphs ( & pending , MatchingPresentation :: NotRequired ) ; let shape = shaper . shape ( glyphs , tag :: LATN , Some ( tag :: DFLT ) , & gsub :: Features :: Mask ( gsub :: GsubFeatureMask :: default ( ) ) , true ) . ok ( ) . unwrap_or_else ( | | vec ! [ ] ) ; // The scale factor is used to convert between font units and screen units let scale_factor = self . em_size / self . units_per_em ; // Generate the glyph positions for glyph in shape { // Fetch information about this glyph let glyph_index = ttf_parser :: GlyphId ( glyph . glyph . glyph_index as _ ) ; let advance_x = ttf_font . glyph_hor_advance ( glyph_index ) ; let advance_y = ttf_font . glyph_ver_advance ( glyph_index ) ; let advance_x = if let Some ( advance ) = advance_x { advance } else { 0 } ; let advance_y = if let Some ( advance ) = advance_y { advance } else { 0 } ; // Adjust by any requested offset let ( off_x , off_y ) = match glyph . placement { gpos :: Placement :: None => ( 0.0 , 0.0 ) , gpos :: Placement :: Distance ( x , y ) => ( x as f32 , y as f32 ) , gpos :: Placement :: Anchor ( _ , _ ) => ( 0.0 , 0.0 ) , // TODO: https://docs.microsoft.com/en-us/typography/opentype/spec/gpos#lookup-type-3-cursive-attachment-positioning-subtable } ; let off_x = off_x * scale_factor ; let off_y = off_y * scale_factor ; // Push this glyph let glyph_pos = GlyphPosition { id : GlyphId ( glyph . glyph . glyph_index as _ ) , location : ( self . x_off + off_x , self . y_off + off_y ) , em_size : self . em_size } ; self . layout . push ( LayoutAction :: Glyph ( glyph_pos ) ) ; // Move to the next position let advance_x = ( advance_x as f32 ) + ( glyph . kerning as f32 ) ; let advance_y = advance_y as f32 ; let advance_x = advance_x * scale_factor ; let advance_y = advance_y * scale_factor ; let last_x = self . x_off ; let last_y = self . y_off ; self . x_off += advance_x + off_x ; self . y_off += advance_y + off_y ; // The inner bounds just uses the x, y offsets to amend the bounding box self . metrics . inner_bounds = self . metrics . inner_bounds . union_bounds ( ( Coord2 ( last_x as _ , last_y as _ ) , Coord2 ( self . x_off as _ , self . y_off as _ ) ) ) ; } }
Performs layout on the pending string
Performs layout on the pending string
&mut self