Crate ttf_parser[][src]

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

An Axis Variations Table implementation.

A Color Bitmap Data Table implementation.

A Compact Font Format Table implementation.

A Font Variations Table implementation.

A Glyph Definition Table implementation.

A Glyph Data Table implementation.

A Glyph Positioning Table implementation.

A Glyph Substitution Table implementation.

A Glyph Variations Table implementation.

A Font Header Table implementation.

A Horizontal Header Table implementation.

A Kerning Table implementation.

An Index to Location Table implementation.

A Maximum Profile Table implementation.

A Metrics Variations Table implementation.

A Naming Table implementation.

A list of name ID’s.

This module contains OpenType Layout tables implementation.

Binary parsing utils.

A PostScript Table implementation.

An SVG Table implementation.

A Vertical Header Table implementation.

A Vertical Origin Table implementation.

Structs

A font face.

Parsed face tables.

A type-safe wrapper for glyph ID.

A line metrics.

A variation coordinate in a normalized coordinate system.

A glyph’s raster image.

A list of all supported tables as raw data.

A rectangle.

A script metrics used by subscript and superscript.

A 4-byte tag.

A font variation value.

Enums

A list of errors that can occur during a CFF glyph outlining.

A list of font face parsing errors.

A glyph raster image format.

A face style.

A face weight.

A face width.

Traits

A trait for glyph outline construction.

Functions

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