pub struct Font<'a> { /* private fields */ }
Implementations§
Source§impl<'a> Font<'a>
impl<'a> Font<'a>
Sourcepub fn render_glyph(&self, glyph_id: u16, size: u32) -> Option<GlyphBitmap>
pub fn render_glyph(&self, glyph_id: u16, size: u32) -> Option<GlyphBitmap>
Examples found in repository?
examples/render.rs (line 47)
30fn main() {
31 let mut args = std::env::args();
32 let _ = args.next();
33 let filename = args.next().unwrap();
34 let glyph_id: u16 = args.next().unwrap().parse().unwrap();
35 let out_filename = args.next().unwrap();
36 let mut f = File::open(&filename).unwrap();
37 let mut data = Vec::new();
38 match f.read_to_end(&mut data) {
39 Err(e) => println!("failed to read {}, {}", filename, e),
40 Ok(_) => match parse(&data) {
41 Ok(font) => {
42 if out_filename == "__bench__" {
43 for size in 1..201 {
44 let start = SystemTime::now();
45 let n_iter = 1000;
46 for _ in 0..n_iter {
47 match font.render_glyph(glyph_id, size) {
48 Some(_glyph) => (),
49 None => (),
50 }
51 }
52 let elapsed = start.elapsed().unwrap();
53 let elapsed =
54 elapsed.as_secs() as f64 + 1e-9 * (elapsed.subsec_nanos() as f64);
55 println!("{} {}", size, elapsed * (1e6 / n_iter as f64));
56 }
57 } else {
58 match font.render_glyph(glyph_id, 400) {
59 Some(glyph) => dump_pgm(&glyph, &out_filename),
60 None => println!("failed to render {} {}", filename, glyph_id),
61 }
62 }
63 }
64 Err(_) => println!("failed to parse {}", filename),
65 },
66 }
67}
pub fn lookup_glyph_id(&self, code_point: u32) -> Option<u16>
Auto Trait Implementations§
impl<'a> Freeze for Font<'a>
impl<'a> RefUnwindSafe for Font<'a>
impl<'a> Send for Font<'a>
impl<'a> Sync for Font<'a>
impl<'a> Unpin for Font<'a>
impl<'a> UnwindSafe for Font<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more