fontoxide-ttlib
A Rust port of fontTools.ttLib:
the Font object (TTFont), reading and writing sfnt, TTC, WOFF and WOFF2
files, the table implementations, and TTX serialization. It is part of
fontoxide, a port of fontTools to Rust.
Most projects should depend on the fontoxide
crate, which re-exports this one as fontoxide::ttlib (always included). Depend on
this crate directly to keep the dependency tree small.
Example
use ;
let data = read?;
let mut font = read?;
let head: &mut Head = font.?;
println!;
let ttx = font.to_ttx?;
# Ok::
Features
The features are fontTools' extras, all on by default. Without one, the crate behaves as fontTools does without that Python package:
| Feature | fontTools extra (package) | Without it |
|---|---|---|
woff |
woff (brotli, zopfli) |
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 fails with Error::Import |
repacker |
repacker (uharfbuzz) |
GSUB and GPOS are packed with fontTools' own serializer |
Compatibility
This version follows fontTools 4.69.1. The TTX dumps, binary round trips and
fonts compiled from TTX are the same as fontTools', byte for byte, as checked
against fontTools on a corpus of fonts. Compressed data (WOFF 2.0, WOFF 1.0 with
zopfli, LZ4 in Graphite tables) decompresses to the same content, but the
compressed bytes can differ; remove_overlaps gives a geometrically equivalent
result, not an identical one. Differences from fontTools are listed in
COMPATIBILITY.md.
The crate is pure safe Rust and builds for wasm32-unknown-unknown.
License
MIT, like fontTools. See LICENSE.