Name Description Size Coverage
array.rs Custom array types 7227 -
codegen_test.rs A module used to test codegen. This imports a single codegen output; while modifying the codegen crate, this file can be regenerated to check that changes compile, without needing to rebuild everything. To rebuild this input and test it, run: $ cargo run --bin=codegen resources/test_plan.toml && cargo test 11910 -
collections -
collections.rs Data structures useful for font work. 155 -
font_data.rs raw font bytes 12190 -
lib.rs Reading OpenType tables This crate provides memory safe zero-allocation parsing of font files. It is unopinionated, and attempts to provide raw access to the underlying font data as it is described in the [OpenType specification][spec]. This crate is intended for use by other parts of a font stack, such as a shaping engine or a glyph rasterizer. In addition to raw data access, this crate may also provide reference implementations of algorithms for interpreting that data, where such an implementation is required for the data to be useful. For instance, we provide functions for [mapping codepoints to glyph identifiers][cmap-impl] using the `cmap` table, or for [decoding entries in the `name` table][NameString]. For higher level/more ergonomic access to font data, you may want to look into using [`skrifa`] instead. ## Structure & codegen The root [`tables`] module contains a submodule for each supported [table][table-directory], and that submodule contains items for each table, record, flagset or enum described in the relevant portion of the spec. The majority of the code in the tables module is auto-generated. For more information on our use of codegen, see the [codegen tour]. # Related projects - [`write-fonts`] is a companion crate for creating/modifying font files - [`skrifa`] provides access to glyph outlines and metadata (in the same vein as [freetype]) # Example ```no_run # let path_to_my_font_file = std::path::Path::new(""); use read_fonts::{FontRef, TableProvider}; let font_bytes = std::fs::read(path_to_my_font_file).unwrap(); // Single fonts only. for font collections (.ttc) use FontRef::from_index let font = FontRef::new(&font_bytes).expect("failed to read font data"); let head = font.head().expect("missing 'head' table"); let maxp = font.maxp().expect("missing 'maxp' table"); println!("font version {} containing {} glyphs", head.font_revision(), maxp.num_glyphs()); ``` [spec]: https://learn.microsoft.com/en-us/typography/opentype/spec/ [codegen-tour]: https://github.com/googlefonts/fontations/blob/main/docs/codegen-tour.md [cmap-impl]: tables::cmap::Cmap::map_codepoint [`write-fonts`]: https://docs.rs/write-fonts/ [`skrifa`]: https://docs.rs/skrifa/ [freetype]: http://freetype.org [codegen tour]: https://github.com/googlefonts/fontations/blob/main/docs/codegen-tour.md [NameString]: tables::name::NameString [table-directory]: https://learn.microsoft.com/en-us/typography/opentype/spec/otff#table-directory 19072 -
model -
model.rs Higher level interface for accessing font data. 443 -
offset.rs Handling offsets 2803 -
offset_array.rs Arrays of offsets with dynamic resolution This module provides a number of types that wrap arrays of offsets, dynamically resolving individual offsets as they are accessed. 6453 -
ps -
ps.rs PostScript fonts. 211 -
read.rs Traits for interpreting font data 7571 -
table_provider.rs a trait for things that can serve font tables 9572 -
table_ref.rs 307 -
tables -
tables.rs The various font tables 1578 -
tests -
traversal.rs Experimental generic traversal of font tables. This module defines functionality that allows untyped access to font table data. This is used as the basis for things like debug printing. The basis of traversal is the [`SomeTable`] trait, which is implemented for all font tables. This trait provides the table's name, as well as ordered access to the table's fields. Using this, it is possible to iterate through a table and its subtables, records, and values. # Warning This functionality is considered experimental, and the API may break or be removed without warning. 20375 -