COOLJAPAN
← All posts

OxiFont 0.2.1 Released — Pure Rust TrueType Hinting Execution Closes the Last Gap to FreeType

OxiFont 0.2.1 ships oxifont-hinting, a from-scratch Pure Rust TrueType bytecode hinting interpreter (grid-fitting VM) that never panics on hostile input, plus a WOFF2 spec-compliance fix and a closed large-allocation DoS in bundled CJK font resolution. The sovereign font layer for the COOLJAPAN ecosystem.

release oxifont pure-rust cooljapan noffi fonts typography opentype hinting security

The last piece of FreeType most “Pure Rust” font stacks still quietly keep around is the hinting bytecode interpreter.

Today we released OxiFont 0.2.1 — adding oxifont-hinting, a from-scratch, bounds-checked Pure Rust implementation of the TrueType instruction set, alongside a WOFF2 spec-compliance fix and a closed large-allocation denial-of-service in bundled CJK font resolution.

No FreeType. No hand-rolled unsafe stack machine trusting font bytes it hasn’t validated. oxifont-hinting runs entirely under #![forbid(unsafe_code)], and every stack, storage, CVT, point, and jump access it makes is bounds-checked against a typed error rather than a segfault. It compiles to a single static binary and runs anywhere Rust does — no C toolchain, no -sys crate, no build script vendoring a copy of FreeType.

Why OxiFont 0.2.1 is a game changer

Most “Pure Rust” font stacks parse TrueType tables just fine but stop short of one thing:

OxiFont 0.2.1 ends all of that:

Technical Deep Dive: the hinting VM, layer by layer

  1. Font/CVT loading (font.rs). FontProgram::load pulls fpgm/prep/cvt /hhea/hmtx out of a SfntTableMap — all optional; a glyf font with none of them is simply unhinted, not an error.
  2. Program execution (interp.rs). HintingEngine::new runs the font program once, collecting FDEF/IDEF function and instruction definitions; set_ppem rescales the CVT from font units and reruns prep from a clean slate on every size change.
  3. Full opcode dispatch (dispatch.rs, ops_arith.rs, ops_move.rs, ops_state.rs). Vector setup, point/line intersection, rounding-state selection, stack manipulation, point movement (MDAP/MDRP/MIRP/MSIRP/SHP/SHZ/…), storage/CVT read-write, arithmetic, comparisons, and delta exceptions — the complete instruction set, not a subset.
  4. IUP interpolation (ops_iup.rs). Per-contour, per-axis interpolation of points the glyph program left untouched, measured against original vs. current positions.

Getting Started

cargo add oxifont-hinting
use oxifont_core::sfnt::SfntTableMap;
use oxifont_hinting::HintingEngine;

fn run(font_bytes: &[u8]) -> Result<(), oxifont_hinting::HintingError> {
    let map = SfntTableMap::parse(font_bytes).map_err(oxifont_hinting::HintingError::from)?;
    let mut engine = HintingEngine::new(&map)?;
    engine.set_ppem(16)?;
    let glyph = engine.hint_glyph(36)?; // grid-fit glyph id 36 at 16 ppem
    for cmd in glyph.to_outline() {
        // feed `cmd` to a rasterizer …
        let _ = cmd;
    }
    Ok(())
}

oxifont-hinting is not yet re-exported from the oxifont facade crate — depend on it directly for now.

What’s New in 0.2.1

Tips

This is the foundation

OxiFont is the font foundation under OxiText (glyph metrics for layout), oxigaf (PDF CFF/Type-0 font embedding), oximedia (subtitle and OSD rendering), oxigdal-symbology (map labels), oxiphoton (image text overlay), and OxiUI (GUI text rendering) — none of them need a code change to pick up this release, only a version bump.

Repository: https://github.com/cool-japan/oxifont

Star the repo if you want TrueType hinting bytecode executed without ever linking FreeType.

The era of shipping a C hinting interpreter just to grid-fit outlines at small sizes is over. Pure Rust typography — sovereign, safe, and FFI-free.

KitaSan at COOLJAPAN OÜ July 30, 2026

↑ Back to all posts