The package provides a parser for OpenType fonts. It might be helpful to have a
look at a higher-level parser called font
, which internally relies on
this package.
```rust extern crate opentype; extern crate truetype;
use opentype::File; use truetype::NamingTable;
let path = "SourceSerifPro-Regular.otf"; let file = File::open(path).unwrap(); let font = &file[0];
asserteq!(font.fontheader.asref().unwrap().unitsperem, 1000); asserteq!(font.horizontalheader.asref().unwrap().ascender, 918); let strings = match font.namingtable { Some(NamingTable::Format0(ref table)) => table.strings().unwrap(), _ => unreachable!(), }; asserteq!(&strings[1], "Source Serif Pro"); assert_eq!(&strings[9], "Frank Grießhammer"); ```
Your contribution is highly appreciated. Do not hesitate to open an issue or a pull request. Note that any contribution submitted for inclusion in the project will be licensed according to the terms given in LICENSE.md.