Crate opentype [] [src]

A parser for OpenType fonts.

Example

extern crate opentype;
extern crate truetype;

use opentype::File;
use truetype::NamingTable;

let path = "SourceSerifPro-Regular.otf";
let file = File::open(path).unwrap();

match file.font_header {
    Some(ref table) => assert_eq!(table.unitsPerEm, 1000),
    _ => unreachable!(),
}
match file.horizontal_header {
    Some(ref table) => assert_eq!(table.Ascender, 918),
    _ => unreachable!(),
}
match file.naming_table {
    Some(NamingTable::Format0(ref table)) => {
        let strings = table.strings().unwrap();
        assert_eq!(&strings[1], "Source Serif Pro");
        assert_eq!(&strings[9], "Frank Grießhammer");
    },
    _ => unreachable!(),
}

Structs

File

A font file.

Type Definitions

Error

An error.

Result

A result.