Text layout for rusttype.
```rust use glyphbrushlayout::*;
let dejavu = Font::frombytes(&includebytes!("DejaVuSans.ttf")[..])?; let garamond = Font::frombytes(&includebytes!("GaramondNo8-Reg.ttf")[..])?;
// Simple vec font mapping: FontId(0) -> deja vu sans, FontId(1) -> garamond let fonts = vec![dejavu, garamond];
// Layout "hello glyphbrushlayout" on an unbounded line with the second // word suitably bigger, greener and serif-ier. let glyphs = Layout::default().calculateglyphs( &fonts, &SectionGeometry { screenposition: (150.0, 50.0), ..SectionGeometry::default() }, &[ SectionText { text: "hello ", scale: Scale::uniform(20.0), ..SectionText::default() }, SectionText { text: "glyphbrushlayout", scale: Scale::uniform(25.0), font_id: FontId(1), color: [0.0, 1.0, 0.0, 1.0], }, ], );
assert_eq!(glyphs.len(), 23);
let (oglyph, glyph4color, glyph4font) = &glyphs[4]; asserteq!(oglyph.id(), fonts[0].glyph('o').id()); asserteq!(glyph_4_color, [0.0, 0.0, 0.0, 1.0]); assert_eq!(glyph4font, FontId(0));
let (sglyph, glyph14color, glyph14font) = &glyphs[14]; asserteq!(sglyph.id(), fonts[1].glyph('s').id()); asserteq!(glyph_14_color, [0.0, 1.0, 0.0, 1.0]); assert_eq!(glyph14font, FontId(1)); ```