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§

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

Structs§

Class
A value of Class Definition Table.
Face
A font face handle.
GlyphId
A type-safe wrapper for glyph ID.
LineMetrics
A line metrics.
Name
A Name Record.
Names
An iterator over font’s names.
NormalizedCoordinate
A variation coordinate in a normalized coordinate system.
RasterGlyphImage
A glyph’s raster image.
Rect
A rectangle.
ScriptMetrics
A script metrics used by subscript and superscript.
Tag
A 4-byte tag.
Variation
A font variation value.
VariationAxes
An iterator over variation axes.
VariationAxis
A variation axis.

Enums§

FaceParsingError
A list of font face parsing errors.
GlyphClass
A glyph class.
PlatformId
A platform ID.
RasterImageFormat
A glyph raster image format.
TableName
A table name.
Weight
A font weight.
Width
A font width.

Traits§

OutlineBuilder
A trait for glyph outline construction.

Functions§

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