Safe, fast and memory efficient OpenType font file parser
The OpenType font format is an extension of the TrueType font format, adding support for PostScript font data. The OpenType font format was developed jointly by Microsoft and Adobe. OpenType fonts and the operating system services which support OpenType fonts provide users with a simple way to install and use fonts, whether the fonts contain TrueType outlines or CFF (PostScript) outlines.
See OpenType® specification for details.
extern crate opentype_rs as otf;
use otf::OpenTypeFontFile;
use otf::tables::TableTag;
use otf::tables::head::FontHeaderTable;
use otf::tables::name::NamingTable;
use otf::traits::TableParser;
fn main() {
let buf = include_bytes!("../fonts/Roboto/Roboto-Regular.ttf") as &[u8];
let otff = OpenTypeFontFile::parse(buf).unwrap();
for font in otff {
for table in font.iter() {
match table.tag() {
TableTag::Head => {
let font_header_table = FontHeaderTable::parse_table(&table).unwrap();
assert_eq!(font_header_table.font_revision(), 140050);
},
TableTag::Name => {
let naming_table = NamingTable::parse_table(&table).unwrap();
assert_eq!(naming_table.string_offset(), 318);
},
_ => {}
}
}
}
}
- cmap: Character to glyph mapping
- head: Font header
- hhea: Horizontal header
- hmtx: Horizontal metrics
- maxp: Maximum profile
- name: Naming table
- OS/2: OS/2 and Windows specific metrics
- post: PostScript information
- cvt: Control Value Table (optional table)
- fpgm: Font program (optional table)
- glyf: Glyph data
- loca: Index to location
- prep: CVT Program (optional table)
- gasp: Grid-fitting/Scan-conversion (optional table)
- CFF: Compact Font Format 1.0
- CFF2: Compact Font Format 2.0
- VORG: Vertical Origin (optional table)
- SVG: The SVG (Scalable Vector Graphics) table
- EBDT: Embedded bitmap data
- EBLC: Embedded bitmap location data
- EBSC: Embedded bitmap scaling data
- CBDT: Color bitmap data
- CBLC: Color bitmap location data
- sbix: Standard bitmap graphics
- BASE: Baseline data
- GDEF: Glyph definition data
- GPOS: Glyph positioning data
- GSUB: Glyph substitution data
- JSTF: Justification data
- MATH: Math layout data
- avar: Axis variations
- cvar: CVT variations (TrueType outlines only)
- fvar: Font variations
- gvar: Glyph variations (TrueType outlines only)
- HVAR: Horizontal metrics variations
- MVAR: Metrics variations
- STAT: Style attributes (required for variable fonts, optional for non-variable fonts)
- VVAR: Vertical metrics variations
- COLR: Color table
- CPAL: Color palette table
- CBDT: Color bitmap data
- CBLC: Color bitmap location data
- sbix: Standard bitmap graphics
- SVG: The SVG (Scalable Vector Graphics) table
- DSIG: Digital signature
- hdmx: Horizontal device metrics
- kern: Kerning
- LTSH: Linear threshold data
- MERG: Merge
- meta: Metadata
- STAT: Style attributes
- PCLT: PCL 5 data
- VDMX: Vertical device metrics
- vhea: Vertical Metrics header
- vmtx: Vertical Metrics
opentype-rs is distributed under the terms of the MIT license.
See LICENSE-MIT for details.