fontoxide_ttlib/lib.rs
1//! Port of `fontTools.ttLib`: the [`Font`] object (`TTFont`), sfnt/TTC/WOFF/WOFF2
2//! containers, table implementations, and TTX serialization.
3//!
4//! ```no_run
5//! use fontoxide_ttlib::{Font, ReadOptions, TtxOptions, tables::Head};
6//!
7//! let data = std::fs::read("font.ttf")?;
8//! let mut font = Font::read(data, ReadOptions::default())?;
9//! let head: &mut Head = font.require::<Head>()?;
10//! println!("{}", head.units_per_em);
11//! let ttx = font.to_ttx(&TtxOptions::default())?;
12//! # Ok::<(), Box<dyn std::error::Error>>(())
13//! ```
14//!
15//! # Features
16//!
17//! The features are fontTools' extras, all on by default. Without one,
18//! fontoxide behaves as fontTools does without that Python package:
19//!
20//! | Feature | fontTools extra (package) | Without it |
21//! |------------|---------------------------|------------|
22//! | `woff` | `woff` (brotli, zopfli) | reading and writing WOFF 2.0, and WOFF 1.0 with [`WriteOptions::use_zopfli`], fail with [`Error::Import`] |
23//! | `graphite` | `graphite` (lz4) | LZ4-compressed `Silf` and `Glat` tables are kept compressed, with a warning |
24//! | `pathops` | `pathops` (skia-pathops) | [`remove_overlaps`](remove_overlaps::remove_overlaps) and the command line [`remove_overlaps::main`] fail with [`Error::Import`] |
25//! | `repacker` | `repacker` (uharfbuzz) | `GSUB` and `GPOS` are packed with fontTools' serializer; [`Font::use_harfbuzz_repacker`] `Some(true)` fails with [`Error::Import`] |
26
27#![forbid(unsafe_code)]
28
29pub mod beyond64k;
30pub mod binary;
31pub mod cff;
32pub mod cli;
33pub mod collection;
34mod error;
35pub mod font;
36mod generated;
37pub mod glyph_order;
38pub mod glyph_set;
39pub mod iup;
40pub mod mac_utils;
41pub mod ot;
42pub mod pens;
43pub mod remove_overlaps;
44pub mod reorder_glyphs;
45pub mod scale_upem;
46pub mod sfnt;
47pub mod sstruct;
48pub mod table;
49pub mod tables;
50pub mod ttx;
51pub mod var;
52pub mod woff2;
53pub mod woff2_cli;
54
55pub use collection::TtCollection;
56pub use error::{Error, Result};
57pub use font::{Font, Progress, ReadOptions, TableKey, TtxOptions, WriteOptions};
58pub use fontoxide_misc::Tag;
59pub use fontoxide_misc::time_tools::set_clock;
60pub use glyph_order::GlyphOrder;
61pub use glyph_set::GlyphSet;
62pub use sfnt::{Flavor, FlavorData};
63pub use table::{DefaultTable, Table, TableType, TableXml};
64pub use ttx::{TtxFile, TtxImportOptions};
65
66/// The fontTools release whose behavior this version matches.
67pub const FONTTOOLS_VERSION: &str = "4.69.1";
68
69/// Facts about fontTools' table classes, generated from upstream.
70pub mod fonttools_tables {
71 pub use crate::generated::tables::{FONTTOOLS_TABLES, dependencies};
72}