Skip to main content

Crate sr_aef

Crate sr_aef 

Source
Expand description

§sr-aef

sr-aef “uncompiles” an OpenType/TrueType font back into Adobe Feature File (fea) source code. It reads the OpenType layout tables (GSUB, GPOS and, optionally, GDEF) out of a compiled binary font and reconstructs an equivalent feature file using the fea_rs_ast AST.

Because binary fonts lose the original structure of their layout code (lookup splitting, class naming, comments, …), the output is a faithful functional reconstruction rather than a byte-for-byte copy of the original source.

The main entry points are uncompile, uncompile_bytes and uncompile_context:

use sr_aef::{fea_rs_ast::AsFea, uncompile_bytes};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let data = std::fs::read("MyFont.ttf")?;
    // `true` also uncompiles the GDEF table.
    let feature_file = uncompile_bytes(&data, true)?;
    println!("{}", feature_file.as_fea(""));
    Ok(())
}

The crate also powers the TrueType round-trip in babelfont.

Re-exports§

pub use fea_rs_ast;
pub use skrifa;

Structs§

UncompileContext
The context object that holds all the information we need when uncompiling a font.

Functions§

uncompile
Uncompile a TTF font into a fea file.
uncompile_bytes
Uncompile a TTF font from a byte slice into a fea file. See uncompile() for details.
uncompile_context
Uncompile a TTF font to a context object.
unique_glyph_names
The glyph names the uncompiled features use: the post table’s, valid in a feature file and unique.