OpenType Package Documentation Build

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.

Example

```rust use opentype::File; use opentype::truetype::{FontHeader, HorizontalHeader}; use opentype::truetype::naming_table::{NameID, NamingTable};

macro_rules! ok(($result:expr) => ($result.unwrap()));

let path = "SourceSerifPro-Regular.otf"; let mut tape = ok!(std::fs::File::open(path)); let File { mut fonts } = ok!(File::read(&mut tape));

let fontheader: FontHeader = ok!(ok!(fonts[0].take(&mut tape))); asserteq!(fontheader.unitsper_em, 1000);

let horizontalheader: HorizontalHeader = ok!(ok!(fonts[0].take(&mut tape))); asserteq!(horizontal_header.ascender, 918);

let namingtable: NamingTable = ok!(ok!(fonts[0].take(&mut tape))); let names = namingtable .iter() .map(|((nameid, _), value)| (nameid, value)) .collect::>(); asserteq!(ok!(names[&NameID::FullFontName].asref()), "Source Serif Pro"); asserteq!(ok!(names[&NameID::DesignerName].asref()), "Frank Grießhammer"); ```

Contribution

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.