Skip to main content

Babelfont

crates.io docs.rs

Babelfont is a Rust library for working with font source files from different font editing software. It provides a unified interface to load, examine, manipulate, and convert fonts between various formats, abstracting over the differences between font editors' native representations.

Features

  • Multi-format Support: Load and save fonts in UFO, DesignSpace, Glyphs, FontLab VFJ, FontForge, and Babelfont's own JSON format
  • Format Conversion: Convert fonts between different editor formats seamlessly
  • Font Manipulation: Apply filters to subset, scale, or otherwise transform fonts
  • JSON Serialization: Full serialization/deserialization of Babelfont's internal representation
  • Variable Font Support: Full support for variable/multiple master fonts with axes, masters, and instances
  • TTF Compilation: Compile fonts to binary OpenType/TrueType output
  • Optional Format Support: Fine-grained feature flags let you pull in only the format support you need

Status

Babelfont is in early development. While the core architecture and many features are implemented, some format support and filters are still works in progress.

  • Glyphs file format: Mostly complete for reading and writing Glyphs 2 and Glyphs 3 files.
  • UFO/DesignSpace: Reading support is implemented; writing support is in progress.
  • FontLab VFJ: Very basic reading support is implemented; writing support is planned.
  • Fontra: Basic reading and writing support is implemented.

Installation

Add this to your Cargo.toml:

[dependencies]
babelfont = "0.2"

Feature Flags

By default, all major format support is enabled. You can customize which formats are supported:

[dependencies]
babelfont = { version = "0.2", default-features = false, features = ["glyphs", "ufo"] }

Available features (all enabled by default unless noted):

  • glyphs - Support for Glyphs 2 and Glyphs 3 files (.glyphs and .glyphspackage)
  • ufo - Support for UFO and DesignSpace formats
  • fontlab - Support for FontLab VFJ (JSON) format
  • fontforge - Support for FontForge SplineFont formats (.sfd, .sfdir)
  • fontra - Support for Fontra format
  • robocjk - Support for the RoboCJK subset workflow format
  • ttf / fontir - Compilation to binary font formats (.ttf)
  • types - Typeshare annotations for generating TypeScript type definitions of the JSON format
  • rayon - Rayon-based parallelism in norad
  • cli - Command-line interface (builds the babelfont binary; not in default features)
  • linesweeper - Overlap-removal filters (requires external binaries)

Quick Start

Loading and Converting Fonts

use babelfont::{load, BabelfontError};

fn main() -> Result<(), BabelfontError> {
    // Load a font from any supported format
    let font = load("MyFont.designspace")?;

    // Convert to Glyphs format
    font.save("MyFont.glyphs")?;

    // Or save as JSON
    font.save("MyFont.babelfont")?;

    Ok(())
}

Subsetting with Filters

use babelfont::{load, BabelfontError};
use babelfont::filters::{FontFilter, RetainGlyphs};

fn main() -> Result<(), BabelfontError> {
    // Load a DesignSpace file
    let mut font = load("MyFont.designspace")?;

    // Create a filter to retain only certain glyphs
    let filter = RetainGlyphs::new(vec![
        "A".to_string(),
        "B".to_string(),
        "C".to_string(),
        "space".to_string(),
    ]);

    // Apply the filter
    filter.apply(&mut font)?;

    // Save as a Glyphs file
    font.save("MyFont-Subset.glyphs")?;

    Ok(())
}

Inspecting Font Metadata

use babelfont::load;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let font = load("MyFont.ufo")?;

    // Access font metadata
    println!("Font family: {}", font.names.family_name);
    println!("Units per em: {}", font.upm);
    println!("Number of glyphs: {}", font.glyphs.len());

    // Iterate over axes in a variable font
    for axis in &font.axes {
        println!("Axis: {} ({} to {})", axis.name, axis.min, axis.max);
    }

    // Access specific glyphs
    if let Some(glyph) = font.glyphs.get("A") {
        println!("Glyph 'A' has {} layers", glyph.layers.len());

        for layer in &glyph.layers {
            println!("  Layer: {:?}", layer.id);
        }
    }

    Ok(())
}

Supported Formats

The input and output formats available depend on which feature flags are enabled:

Format Extension Feature Flag
UFO .ufo ufo
DesignSpace .designspace ufo
Glyphs 2/3 .glyphs glyphs
Glyphs Package .glyphspackage glyphs
FontLab VFJ .vfj fontlab
FontForge .sfd / .sfdir fontforge
Fontra .fontra fontra
Babelfont JSON .babelfont (always)
TrueType/OpenType .ttf / .otf ttf / fontir

JSON Serialization

One of Babelfont's unique features is its ability to serialize and deserialize its internal representation to and from JSON. This provides a format-agnostic way to store and exchange font data.

The JSON format is complete and lossless, meaning you can:

  • Convert any supported format to JSON and back without data loss
  • Use JSON as an intermediate format when converting between editor formats
  • Inspect the complete font structure in a human-readable format
  • Create programmatic workflows using standard JSON tools

Example:

use babelfont::load;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load from Glyphs
    let font = load("MyFont.glyphs")?;

    // Save as JSON
    font.save("MyFont.babelfont")?;

    // Load from JSON
    let font2 = load("MyFont.babelfont")?;

    // Convert to DesignSpace
    font2.save("MyFont.designspace")?;

    Ok(())
}

Font Filters

Babelfont includes several built-in filters for font manipulation:

  • RetainGlyphs - Keep only specified glyphs, removing all others. Components referencing removed glyphs are automatically decomposed.
  • DropAxis - Remove a variable font axis
  • DropInstances - Remove named instances
  • DropKerning - Remove all kerning data
  • DropFeatures - Remove OpenType feature code
  • DropGuides - Remove all guidelines
  • DropSparseMasters - Convert sparse masters to associated layers
  • ResolveIncludes - Resolve feature file include statements
  • ExpandGlyphs3Predicates - Replace Glyphs 3 glyph predicates ($[...]) in feature code with the glyphs they select
  • ScaleUpem - Scale the units-per-em value

Filters can be chained together:

use babelfont::{load, filters::*};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut font = load("MyFont.glyphs")?;

    // Apply multiple filters
    RetainGlyphs::new(vec!["A".into(), "B".into()]).apply(&mut font)?;
    DropGuides.apply(&mut font)?;
    DropKerning.apply(&mut font)?;

    font.save("MyFont-Filtered.glyphs")?;
    Ok(())
}

Core Types

  • Font - The main font structure containing all font data
  • Glyph - A single glyph with its layers and metadata
  • Layer - A glyph's outline in a particular master
  • Master - A design master in a variable/multiple master font
  • Axis - A variation axis definition
  • Instance - A named instance (static font variant)
  • Features - OpenType feature code representation
  • Shape - A path or component in a glyph layer

Command-Line Interface

With the cli feature enabled, Babelfont also provides a command-line tool:

# Convert between formats
babelfont MyFont.glyphs MyFont.babelfont

# Apply filters
babelfont MyFont.babelfont Subset.babelfont --filter dropaxis=wdth --filter retainglyphs=A,B,C

# Compile to TTF
babelfont Subset.babelfont Subset.ttf

Install it from source with:

cargo install babelfont --features cli

or from PyPI:

pip install babelfont-rs
  • fontmerge - merge selected glyphs and layout features from one font into another
  • sr-aef - "uncompile" OpenType layout tables back into feature file (fea) source

Babelfont is based on the Python babelfont library. Additional development is now happening here, rather than in the original Python version.

License

Babelfont is available under the MIT or Apache-2.0 licenses, at your option. See LICENSE-MIT and LICENSE-APACHE.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues on GitHub.

Metadata

Release files for babelfont-rs 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for babelfont-rs 0.2.7
File Size Uploaded Provenance Actions
babelfont_rs-0.2.7.tar.gz 1.8 MB With provenance Details for babelfont_rs-0.2.7.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for babelfont-rs 0.2.7
File Actions
babelfont_rs-0.2.7-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for babelfont_rs-0.2.7-py3-none-win_amd64.whl
babelfont_rs-0.2.7-py3-none-win32.whl Python 3 none Windows x86-32 Details for babelfont_rs-0.2.7-py3-none-win32.whl
babelfont_rs-0.2.7-py3-none-musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64 Details for babelfont_rs-0.2.7-py3-none-musllinux_1_1_x86_64.whl
babelfont_rs-0.2.7-py3-none-musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64 Details for babelfont_rs-0.2.7-py3-none-musllinux_1_1_aarch64.whl
babelfont_rs-0.2.7-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details for babelfont_rs-0.2.7-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
babelfont_rs-0.2.7-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details for babelfont_rs-0.2.7-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
babelfont_rs-0.2.7-py3-none-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl Python 3 none macOS 10.12+ universal2 (ARM64, x86-64), macOS 11.0+ ARM64, macOS 10.12+ x86-64 Details for babelfont_rs-0.2.7-py3-none-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 87.3 MB

Release files / babelfont_rs-0.2.7.tar.gz

Download URL babelfont_rs-0.2.7.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
148cd129cf34b16aa46dc380840a69b4a8beda54b28c5eb9d9285b6f224fad59
BLAKE2b-256 checksum
How to use checksums
f0a7e4ba25655ba7e7781a049699f6d2cfaabe8d349489626f48955d90e465ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-win_amd64.whl

Download URL babelfont_rs-0.2.7-py3-none-win_amd64.whl
Size 10.1 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
16c6bfc1cb5416ddf362be9a5c88189c6a1ae3916fcebbdf10fb52b40b1531d7
BLAKE2b-256 checksum
How to use checksums
04d03722de01f6d59b63c819b22e9c3dcd83188f67ff5599fbddf1290fd463dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-win32.whl

Download URL babelfont_rs-0.2.7-py3-none-win32.whl
Size 9.1 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
4eb2d56efdf432b1694844f0e8b3b0f1ab735b6c3fd58c3f42352b5ba0572a7d
BLAKE2b-256 checksum
How to use checksums
506614141f2428c1b7015bd2ebc522cc0b1948849fea4fead9ab99c01544925f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-musllinux_1_1_x86_64.whl

Download URL babelfont_rs-0.2.7-py3-none-musllinux_1_1_x86_64.whl
Size 11.5 MB
Tags Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
e2fd65a9f5fc19e325a9b9cdb00de29b85476b23c00266fca8c2c036530d888c
BLAKE2b-256 checksum
How to use checksums
4a7d6af2adc543e16f1a27fcc6eb317dfc2eea0eb195c2d7c35830d5b1faca47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-musllinux_1_1_aarch64.whl

Download URL babelfont_rs-0.2.7-py3-none-musllinux_1_1_aarch64.whl
Size 11.0 MB
Tags Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
680cca3120e16d2b3e1d3b8b04ac67b4ab75a6061a1884824c082d1278b54127
BLAKE2b-256 checksum
How to use checksums
41525029e76efd6c1769393f9ee30541515fec86fb10dead927001aa04b45ead
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL babelfont_rs-0.2.7-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 11.3 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
bb64035c19129865ea31abf58e269546b2271be34426455fd602d757498d8365
BLAKE2b-256 checksum
How to use checksums
b4c285a8ebfaa63dd4c889a96ab8c3d1db2e7cf774dd0cc4c857285a1edb7f7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL babelfont_rs-0.2.7-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 11.2 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
0b1dede21ad8855df7a841d2c49db19838e23db5a10739b3d71079476aab0c55
BLAKE2b-256 checksum
How to use checksums
36b4df850d3aea242424084d4d20b9170b4f92c883a2f4c26313849f5087aac0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / babelfont_rs-0.2.7-py3-none-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL babelfont_rs-0.2.7-py3-none-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 21.2 MB
Tags Python 3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3b3f4232c104a7eca4469f8dceed6ca29b5563ef2d85c7062835498e5e1eaf17
BLAKE2b-256 checksum
How to use checksums
f1ec684f497d8b95b926b6bcdf5065c07d418e961770920e44f1cb54dd5a41e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for babelfont-rs 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 8 files in this release have been uploaded with provenance metadata.

Select from 8 files

Attestation for babelfont_rs-0.2.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page