Fontdue is a simple,
no_std, pure Rust, truetype font parser and rasterizer. It aims to support all valid (unicode encoded) TrueType fonts correctly. It aims to make interacting with fonts as fast as possible. This includes getting layout information and rasterization.
A non-goal of this library is to be allocation free and have a fast/"zero cost" initial load. This libary does make allocations and depends on the
alloc crate. Fonts are fully parsed on creation and relevant information is stored in a more conveinent to accesss format. Unlike other font libraries, the font structures have no lifetime dependencies since it allocates its own space.
Ideally, font loading should be faster in the future, but making the loading process correct and readable was the initial priority.
cmapCharacter to glyph mapping (Unicode only)
- Supports popular formats 0, 4, 6, 10, 12, 13
- Planned support: formats 2, 8, 14
- Planned support: Compound glyph matched points, compound glyph scaled offset
headGeneral font information
hheaGeneral horizontal layout
hmtxGlyph horizontal layout
locaGlyph outline offsets and lengths
maxpMaximum values used for the font
Planned support for:
kernKerning pair layout
vheaGeneral vertical layout
vmtxGlyph vertical layout
Fastest rasterizing in the west.
Here are some benchmarks. They generate the layout metrics and bitmap for the letter 'g' are different sizes. This is going straight from the character 'g' to the metrics and bitmap, which is how the majority of people will interact with a font library.
Fontdue: Metrics and rasterize 'g' at 12px time: [1.9893 us 2.0058 us 2.0241 us] Fontdue: Metrics and rasterize 'g' at 24px time: [2.8187 us 2.8463 us 2.8767 us]
For benchmarks, you often see the lookup step skipped and instead just see the direct glyph index to output. Below are those benchmarks. Indexed benchmarks aren't typically representative of real world performance.
Fontdue: Metrics and rasterize 'g' indexed at 12px time: [1.9635 us 1.9878 us 2.0167 us] Fontdue: Metrics and rasterize 'g' indexed at 24px time: [2.7852 us 2.8059 us 2.8312 us]
Other popular font library.
RustType: Metrics and rasterize 'g' at 12px time: [9.7445 us 9.7559 us 9.7690 us] RustType: Metrics and rasterize 'g' at 24px time: [13.515 us 13.540 us 13.569 us]
Inspired by how simple the wonderful
rusttype crate made font parsing look. Rasterizer from the