JFLib

pdf/src/font.rs#

Source: lib/pdf/src/font.rs

font -- TrueType / OpenType fonts for a document: their metrics, the glyphs a document uses,
and what goes into the file: a Type0 font with Identity-H encoding over a CIDFont whose CIDs
are the font's glyph ids, a subset of the font program (TrueType: unused glyphs emptied in
glyf; CFF: unused charstrings replaced by endchar, cff.rs), the widths (W) and a ToUnicode
CMap for search and copy.

Glyph ids stay as they are (CIDToGIDMap /Identity), so nothing in the content stream depends on
which glyphs the document uses; the emptied entries of glyf, loca and hmtx compress to
almost nothing.
  • struct FontMetrics the vertical metrics of a font in its own units (Document::font_metrics)
    • units_per_em: u16
    • ascent: i16 -- above the baseline (positive)
    • descent: i16 -- below the baseline (negative)
    • line_gap: i16
    • cap_height: i16
    • x_height: i16
    • glyphs: u16 -- how many glyphs the font has

Source: docs/API.md in the JFLib repository.