1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
//! Parser for OpenType fonts.
//!
//! ## Example
//!
//! ```
//! 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 path = "tests/fixtures/SourceSerifPro-Regular.otf";
//! let mut tape = ok!(std::fs::File::open(path));
//! let File { mut fonts } = ok!(File::read(&mut tape));
//!
//! let font_header: FontHeader = ok!(ok!(fonts[0].take(&mut tape)));
//! assert_eq!(font_header.units_per_em, 1000);
//!
//! let horizontal_header: HorizontalHeader = ok!(ok!(fonts[0].take(&mut tape)));
//! assert_eq!(horizontal_header.ascender, 918);
//!
//! let naming_table: NamingTable = ok!(ok!(fonts[0].take(&mut tape)));
//! let names = naming_table
//! .iter()
//! .map(|((name_id, _), value)| (name_id, value))
//! .collect::<std::collections::HashMap<_, _>>();
//! assert_eq!(ok!(names[&NameID::FullFontName].as_ref()), "Source Serif Pro");
//! assert_eq!(ok!(names[&NameID::DesignerName].as_ref()), "Frank Grießhammer");
//! ```
pub extern crate postscript;
pub extern crate truetype;
#[macro_use(
dereference,
flags,
jump_take,
jump_take_maybe,
jump_take_given,
raise,
table
)]
extern crate typeface;
pub mod font_variations;
pub mod glyph_definition;
pub mod glyph_positioning;
pub mod glyph_substitution;
pub mod layout;
pub mod variations;
mod file;
mod font;
mod table;
pub use typeface::{Error, Result, Tape, Value, Walue};
pub use file::File;
pub use font::Font;
pub use font_variations::FontVariations;
pub use glyph_definition::GlyphDefinition;
pub use glyph_positioning::GlyphPositioning;
pub use glyph_substitution::GlyphSubstitution;
pub use table::Table;
/// Check if a tag is recognized.
#[inline]
pub fn accept(tag: &truetype::Tag) -> bool {
matches!(&tag.0, b"ttcf") || truetype::accept(tag)
}