Home

Awesome

<h1 align="center"> <img src="https://github.com/yeslogic/allsorts/raw/master/allsorts.svg?sanitize=1" alt=""><br> Allsorts </h1> <div align="center"> <strong>Font parser, shaping engine, and subsetter for OpenType, WOFF, and WOFF2 implemented in Rust</strong> </div> <br> <div align="center"> <a href="https://github.com/yeslogic/allsorts/actions/workflows/ci.yml"> <img src="https://github.com/yeslogic/allsorts/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a> <a href="https://docs.rs/allsorts"> <img src="https://docs.rs/allsorts/badge.svg" alt="Documentation"> </a> <a href="https://crates.io/crates/allsorts"> <img src="https://img.shields.io/crates/v/allsorts.svg" alt="Version"> </a> <a href="https://github.com/yeslogic/allsorts/blob/master/LICENSE"> <img src="https://img.shields.io/crates/l/allsorts.svg" alt="License"> </a> </div> <br>

Allsorts is a font parser, shaping engine, and subsetter for OpenType, WOFF, and WOFF2 written entirely in Rust. It was extracted from Prince, a tool that typesets and lays out HTML and CSS documents into PDF.

The Allsorts shaping engine was developed in conjunction with a specification for OpenType shaping, which aims to specify OpenType font shaping behaviour.

Features

What is font shaping?

Font shaping is the process of taking text in the form of Unicode codepoints and a font, and laying out glyphs from the font according to the text. This involves honouring kerning, ligatures, and substitutions specified by the font. For some languages this is relatively straightforward. For others, such as Indic scripts it is quite complex. After shaping, another library such as Pathfinder or FreeType is responsible for rendering the glyphs. To learn more about text rendering, Andrea Cognolato has a good overview of modern font rending on Linux. The concepts remain similar on other platforms.

Examples

Refer to the Allsorts Tools repository for a set of tools that exercise Allsorts font parsing, shaping, and subsetting.

Unimplemented Features / Known Issues

We don't currently support:

Known limitations:

Development Status

Allsorts is still under active development but reached its first release milestone with its inclusion in Prince 13 in 2019. In Prince it is responsible for all font loading, and font shaping.

Currently, the font parsing code is handwritten. It is planned for this to eventually be replaced by machine generated code via our declarative data definition language project.

Platform Support

Allsorts CI runs tests on Linux, macOS, and Windows. Via Prince it is also built for FreeBSD.

Building and Testing

Minimum Supported Rust Version: 1.66.0

To build the crate ensure you have Rust 1.66.0 or newer installed.

Build with cargo build and run the tests with cargo test.

Cargo Features

FeatureDescriptionDefault EnabledExtra Dependencies
outlineEnable code for accessing glyph outlines
flate2_zlibUse the zlib backend to flate2zlib
flate2_rustUse the Rust backend to flate2miniz_oxide
princeEnable Prince specific tests and code
specimenEnable module for generating HTML font specimensupon, unicode-blocks

Note: In our testing the zlib flate2 backend was faster but you may prefer the Rust backend for a pure Rust solution when compiling to WASM or similar.

Contributing

Contributions are welcome, please refer to the contributing document for more details.

Code of Conduct

We aim to uphold the Rust community standards:

We are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, disability, ethnicity, religion, or similar personal characteristic.

We follow the Rust code of conduct.

Acknowledgements

License

Allsorts is distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.