Expand description
Port of fontTools.ttLib: the Font object (TTFont), sfnt/TTC/WOFF/WOFF2
containers, table implementations, and TTX serialization.
use fontoxide_ttlib::{Font, ReadOptions, TtxOptions, tables::Head};
let data = std::fs::read("font.ttf")?;
let mut font = Font::read(data, ReadOptions::default())?;
let head: &mut Head = font.require::<Head>()?;
println!("{}", head.units_per_em);
let ttx = font.to_ttx(&TtxOptions::default())?;§Features
The features are fontTools’ extras, all on by default. Without one, fontoxide behaves as fontTools does without that Python package:
| Feature | fontTools extra (package) | Without it |
|---|---|---|
woff | woff (brotli, zopfli) | reading and writing WOFF 2.0, and WOFF 1.0 with WriteOptions::use_zopfli, fail with Error::Import |
graphite | graphite (lz4) | LZ4-compressed Silf and Glat tables are kept compressed, with a warning |
pathops | pathops (skia-pathops) | remove_overlaps and the command line remove_overlaps::main fail with Error::Import |
repacker | repacker (uharfbuzz) | GSUB and GPOS are packed with fontTools’ serializer; Font::use_harfbuzz_repacker Some(true) fails with Error::Import |
Re-exports§
pub use collection::TtCollection;pub use font::Font;pub use font::Progress;pub use font::ReadOptions;pub use font::TableKey;pub use font::TtxOptions;pub use font::WriteOptions;pub use glyph_order::GlyphOrder;pub use glyph_set::GlyphSet;pub use sfnt::Flavor;pub use sfnt::FlavorData;pub use table::DefaultTable;pub use table::Table;pub use table::TableType;pub use table::TableXml;pub use ttx::TtxFile;pub use ttx::TtxImportOptions;
Modules§
- beyond64k
- Converts between Open Font Format beyond-64k companion tables (a port of
fontTools.ttLib.beyond64k). - binary
- Big-endian binary reading and writing, the equivalent of
struct.unpack/struct.packwith>formats. - cff
- Port of
fontTools.cffLib: CFF and CFF2 font data, and Type 2 charstrings (fontTools.misc.psCharStrings), with Type 1 charstrings int1_charstring. - cli
- The command line (
fontTools.ttLib.__main__): opens fonts and collections, and saves them as one font or a collection. - collection
- Port of
fontTools.ttLib.ttCollection: TrueType / OpenType collections. - font
- Port of
fontTools.ttLib.ttFont: theFontobject (TTFont). - fonttools_
tables - Facts about fontTools’ table classes, generated from upstream.
- glyph_
order - The glyph order: glyph names by glyph ID (
TTFont.getGlyphOrderand friends). - glyph_
set - Drawing the glyphs of a font (
fontTools.ttLib.ttGlyphSet). - iup
fontTools.varLib.iup: interpolation of untouched points (IUP) and the optimizer that leaves out the deltas IUP can infer.- mac_
utils - Port of
fontTools.ttLib.macUtils: fonts in thesfntresources of Mac resource forks (.dfontfiles and font suitcases), and theres_name_or_indexargument ofTTFont(Font::open). - ot
- The machinery behind OpenType Layout and related tables
(
fontTools.ttLib.tables.otBaseandotConverters). - pens
- Pens that build glyphs:
fontTools.pens.ttGlyphPenandfontTools.pens.t2CharStringPen. They live here rather than in fontoxide-pens because they makeglyfglyphs and CFF charstrings. - remove_
overlaps - Simplifies glyphs by merging overlapping contours and components (a port of
fontTools.ttLib.removeOverlaps). - reorder_
glyphs - Reorder the glyphs of a font (
fontTools.ttLib.reorderGlyphs). - scale_
upem - Change the units-per-EM of a font (
fontTools.ttLib.scaleUpem). - sfnt
- Port of
fontTools.ttLib.sfnt: reading and writing the sfnt container (plain sfnt, TrueType collections and WOFF 1.0). WOFF 2.0 lives incrate::woff2. - sstruct
- Fixed-layout binary structures, the equivalent of
fontTools.misc.sstruct. - table
- The table interface (
DefaultTable) and the registry that maps tags to table implementations (getTableClass). - tables
- Table implementations (
fontTools.ttLib.tables). - ttx
- Reading TTX documents (
fontTools.misc.xmlReader.XMLReader, the TTX-specific part), and the file names of TTX dumps split into several files (saveXML(splitTables=True, splitGlyphs=True)). - var
- The parts of
fontTools.varLibthat ttLib relies on to evaluate variations at a location:models.supportScalar,iup.iup_delta, and the instancers ofvarStoreandmultiVarStore. - woff2
- WOFF 2.0 (
fontTools.ttLib.woff2). - woff2_
cli - The command line of
fontTools.ttLib.woff2(main,compressanddecompress): compresses fonts to WOFF 2.0 and decompresses them.
Structs§
- Tag
- A four-byte OpenType tag (
Tag).
Enums§
- Error
- Errors from reading, writing or converting fonts.
Constants§
- FONTTOOLS_
VERSION - The fontTools release whose behavior this version matches.
Functions§
- set_
clock - Sets the clock of
timestamp_now, a function returning the seconds since the Unix epoch, in place of the system clock.
Type Aliases§
- Result
- Shorthand for
Result<T, fontoxide_ttlib::Error>.