Crate ttf_parser

source ·
Expand description

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

Features

  • A high-level API, for people who doesn’t know how TrueType works internally. Basically, no direct access to font tables.
  • Zero heap allocations.
  • Zero unsafe.
  • Zero dependencies.
  • no_std/WASM compatible.
  • Fast.
  • Stateless. All parsing methods are immutable methods.
  • 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 the 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

A character to glyph index mapping table implementation.
A kerning table implementation.
A list of name ID’s.
Binary parsing utils.

Structs

A font face handle.
A type-safe wrapper for glyph ID.
A line metrics.
An iterator over font’s names.
A variation coordinate in a normalized coordinate system.
A glyph’s raster image.
A rectangle.
A script metrics used by subscript and superscript.
A 4-byte tag.
A font variation value.
An iterator over variation axes.

Enums

A list of font face parsing errors.
A glyph raster image format.
A table name.
A font weight.
A font width.

Traits

A trait for glyph outline construction.

Functions

Returns the number of fonts stored in a TrueType font collection.