pub fn layout_paragraph<F, SF>(font: SF, position: Point, text: &str, target: &mut Vec<Glyph>)
where
    F: Font,
    SF: ScaleFont<F>,
{
    let v_advance = font.height() + font.line_gap();
    let mut caret = position + point(0.0, font.ascent());
    let mut last_glyph: Option<Glyph> = None;
    for c in text.chars() {
        if c.is_control() {
            if c == '\n' {
                caret = point(position.x, caret.y + v_advance);
                last_glyph = None;
            }
            continue;
        }
        let mut glyph = font.scaled_glyph(c);
        if let Some(previous) = last_glyph.take() {
            caret.x += font.kern(previous.id, glyph.id);
        }
        glyph.position = caret;

        last_glyph = Some(glyph.clone());
        caret.x += font.h_advance(glyph.id);

        target.push(glyph);
    }
}
/// Simple paragraph layout for glyphs into `target`.
/// Taken from https://github.com/alexheretic/ab-glyph/blob/master/dev/src/layout.rs
Simple paragraph layout for glyphs into `target`.
Simple paragraph layout for glyphs into ` target ` .
pub fn layout_paragraph<F, SF>(font: SF, position: Point, text: &str, target: &mut Vec<Glyph>)
where
    F: Font,
    SF: ScaleFont<F>,
{
    let v_advance = font.height() + font.line_gap();
    let mut caret = position + point(0.0, font.ascent());
    let mut last_glyph: Option<Glyph> = None;
    for c in text.chars() {
        if c.is_control() {
            if c == '\n' {
                caret = point(position.x, caret.y + v_advance);
                last_glyph = None;
            }
            continue;
        }
        let mut glyph = font.scaled_glyph(c);
        if let Some(previous) = last_glyph.take() {
            caret.x += font.kern(previous.id, glyph.id);
        }
        glyph.position = caret;
        last_glyph = Some(glyph.clone());
        caret.x += font.h_advance(glyph.id);
        target.push(glyph);
    }
}
pub fn layout_paragraph < F , SF > ( font : SF , position : Point , text : & str , target : & mut Vec < Glyph > ) where F : Font , SF : ScaleFont < F > , { let v_advance = font . height ( ) + font . line_gap ( ) ; let mut caret = position + point ( 0.0 , font . ascent ( ) ) ; let mut last_glyph : Option < Glyph > = None ; for c in text . chars ( ) { if c . is_control ( ) { if c == '\n' { caret = point ( position . x , caret . y + v_advance ) ; last_glyph = None ; } continue ; } let mut glyph = font . scaled_glyph ( c ) ; if let Some ( previous ) = last_glyph . take ( ) { caret . x += font . kern ( previous . id , glyph . id ) ; } glyph . position = caret ; last_glyph = Some ( glyph . clone ( ) ) ; caret . x += font . h_advance ( glyph . id ) ; target . push ( glyph ) ; } }
Simple paragraph layout for glyphs into `target`.
Simple paragraph layout for glyphs into ` target ` .
font
SF
position
Point
text
&str
target
&mut Vec<Glyph>
font
SF
position
Point
text
&str
target
&mut Vec<Glyph>