Crate ttf_parser

source ·
Expand description

A high-level, safe, zero-allocation TrueType font parser.

Supports TrueType, OpenType and AAT fonts.

Font parsing starts with a Face.

Features

  • A high-level API for most common properties, hiding all parsing and data resolving logic.
  • A low-level, but safe API to access TrueType tables data.
  • Highly configurable. You can disable most of the features, reducing binary size. You can also parse TrueType tables separately, without loading the whole font/face.
  • Zero heap allocations.
  • Zero unsafe.
  • Zero dependencies.
  • no_std/WASM compatible.
  • Fast.
  • Stateless. All parsing methods are immutable.
  • Simple and maintainable code (no magic numbers).

Safety

  • The library must not panic. Any panic considered as a critical bug and should be reported.
  • The library forbids unsafe code.
  • No heap allocations, so crash due to OOM is not possible.
  • All recursive methods have a depth limit.
  • Technically, should use less than 64KiB of stack in worst case scenario.
  • Most of arithmetic operations are checked.
  • Most of numeric casts are checked.

Modules

Structs

Enums

Traits

  • A trait for parsing raw binary data of fixed size.
  • A trait for glyph outline construction.

Functions