• Stars
    star
    717
  • Rank 63,167 (Top 2 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Font parser, shaping engine, and subsetter implemented in Rust


Allsorts

Font parser, shaping engine, and subsetter for OpenType, WOFF, and WOFF2 implemented in Rust


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

  • Parse TrueType (ttf), OpenType (otf), WOFF, and WOFF2 files.
  • Shape Arabic, Cyrillic, Greek, Hebrew, Indic scripts (Bengali, Devanagari, Gujarati, Gurmukhi, Kannada, Malayalam, Oriya, Sinhala, Tamil, Telugu), Khmer, Lao, Latin, Syriac, Thai, and other scripts.
  • Subset from TrueType, OpenType, WOFF, and WOFF2 files into OpenType.

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:

  • Shaping Mongolian, and Tibetan.
  • Apple's morx table.
  • Unicode normalisation.

Known limitations:

  • The crate is not extensively documented yet (#5).
  • Allsorts does not do font lookup/matching. For this something like font-kit is recommended.

Development Status

Allsorts is still under active development but reached its first release milestone with its inclusion in Prince 13. 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

Feature Description Default Enabled Extra Dependencies
outline Enable code for accessing glyph outlines pathfinder_geometry
flate2_zlib Use the zlib backend to flate2 zlib
flate2_rust Use the Rust backend to flate2 miniz_oxide
prince Enable Prince specific tests and code

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.

More Repositories

1

fathom

🚧 (Alpha stage software) A declarative data definition language for formally specifying binary data formats. 🚧
Rust
259
star
2

allsorts-tools

Various font tools built using Allsorts
Rust
79
star
3

prince-samples

Sample documents for Prince
HTML
39
star
4

fontconfig-rs

Safe wrapper around freedesktop.org's fontconfig library, for locating fonts on UNIX like systems.
Rust
17
star
5

unicode-general-category

Fast lookup of the Unicode General Category property for `char` in Rust.
Rust
16
star
6

glyph-names

Rust crate for mapping to glyph names according to the Adobe Glyph List Specification
Rust
15
star
7

prince-php-wrapper

PHP wrapper class for Prince HTML to PDF formatter
PHP
14
star
8

httpsrv

Mercury
8
star
9

unicode-case-mapping

Fast mapping of char to lowercase, uppercase, or titlecase in Rust.
Rust
7
star
10

prince-docs

This repository holds the documentation for Prince, a powerful converter from Web Standards to PDF. (https://www.princexml.com)
XSLT
7
star
11

doodle

Rust
6
star
12

prince-html

C
6
star
13

prince-scripts

Useful javascript helper scripts for Prince
JavaScript
6
star
14

unicode-joining-type

Fast lookup of the Unicode Joining Type property for `char` in Rust.
Rust
6
star
15

prince-tools

Visual Basic
5
star
16

corpus

OCaml
5
star
17

miscellaneous-testcases

Test cases derived from various support requests and bugs, suitable for future regression testing
HTML
4
star
18

docker-prince

Dockerfiles for building Docker images with Prince installed
Makefile
4
star
19

unicode-canonical-combining-class

Fast lookup of the Unicode Canonical Combining Class property for `char` in Rust.
Rust
4
star
20

prince-csharp-wrapper

C# wrapper for Prince
C#
3
star
21

prince-java-wrapper

Java wrapper for Prince
Java
3
star
22

preds

1
star
23

dumb-file-server

Dumbest file server
C
1
star
24

azure-prince-example

Example project using Prince to generate a PDF response that can be deployed as an app service to Microsoft Azure
Max
1
star
25

yeslogic.github.io

The YesLogic org page
1
star
26

mercury-osx-release

Repository to hold Mercury OSX builds for CI
Shell
1
star