Skip to main content

Crate pdf_base14_metrics

Crate pdf_base14_metrics 

Source
Expand description

Pre-parsed Adobe Core 14 PDF font metrics.

The 14 PostScript faces every PDF 1.7-conformant viewer ships built-in: Helvetica × 4, Times × 4, Courier × 4, Symbol, ZapfDingbats: exposed as &'static FontMetrics<'static> constants that cost nothing at runtime. The AFM files are vendored from tecnickcom/tc-font-core14-afms under data/, parsed by the sibling adobe-font-metrics crate at build time (see build.rs), and baked into Rust statics in $OUT_DIR/baked.rs.

§Quick start

use pdf_base14_metrics::Base14Font;

// Look up a glyph width by PostScript name.
assert_eq!(Base14Font::Helvetica.glyph_width("A"), Some(667.0));

// Or via PDF `WinAnsiEncoding` byte (Latin faces only).
assert_eq!(Base14Font::Helvetica.winansi_width(b'A'), Some(667.0));

// Iterate every Core 14 face in stable order.
for f in Base14Font::ALL {
    let m = f.metrics();
    assert!(!m.character_metrics.is_empty());
}

§Encoding caveat: Symbol and ZapfDingbats

Base14Font::winansi_width returns None for Base14Font::Symbol and Base14Font::ZapfDingbats: those fonts use their own PostScript encodings (Greek/math operators and named dingbats respectively), not WinAnsi. Querying them through a Latin-1 byte would be a category error; the byte 0x41 is "A" in WinAnsi but "Alpha" in Symbol. Callers must reach for the per-glyph Base14Font::glyph_width API for those two fonts.

§License

The crate’s Rust source is MIT. The 14 vendored AFM files in data/afm/ ship under Adobe’s permissive Core 14 AFM license (APAFML); see LICENSE-APAFML in the crate root. The combined SPDX expression is MIT AND APAFML.

Modules§

agl_subset 🔒
winansi_char_map 🔒
winansi_table 🔒

Structs§

BBox
A glyph or font bounding box, in 1/1000 em.
CharacterMetric
One entry from a StartCharMetrics block.
FontMetrics
All public AFM data extracted from a single .adobe-font-metrics file.
KerningPair
One entry from a StartKernPairs block.

Enums§

Base14Font
One of the 14 standard PDF fonts every conformant PDF reader ships built in (PDF 1.7 §9.6.2.2).

Constants§

COURIER_BOLDOBLIQUE_CHARS 🔒
COURIER_BOLDOBLIQUE_KERNS 🔒
COURIER_BOLDOBLIQUE_NAME_WIDTHS 🔒
COURIER_BOLDOBLIQUE_WINANSI 🔒
COURIER_BOLD_CHARS 🔒
COURIER_BOLD_KERNS 🔒
COURIER_BOLD_NAME_WIDTHS 🔒
COURIER_BOLD_WINANSI 🔒
COURIER_CHARS 🔒
COURIER_KERNS 🔒
COURIER_NAME_WIDTHS 🔒
COURIER_OBLIQUE_CHARS 🔒
COURIER_OBLIQUE_KERNS 🔒
COURIER_OBLIQUE_NAME_WIDTHS 🔒
COURIER_OBLIQUE_WINANSI 🔒
COURIER_WINANSI 🔒
HELVETICA_BOLDOBLIQUE_CHARS 🔒
HELVETICA_BOLDOBLIQUE_KERNS 🔒
HELVETICA_BOLDOBLIQUE_NAME_WIDTHS 🔒
HELVETICA_BOLDOBLIQUE_WINANSI 🔒
HELVETICA_BOLD_CHARS 🔒
HELVETICA_BOLD_KERNS 🔒
HELVETICA_BOLD_NAME_WIDTHS 🔒
HELVETICA_BOLD_WINANSI 🔒
HELVETICA_CHARS 🔒
HELVETICA_KERNS 🔒
HELVETICA_NAME_WIDTHS 🔒
HELVETICA_OBLIQUE_CHARS 🔒
HELVETICA_OBLIQUE_KERNS 🔒
HELVETICA_OBLIQUE_NAME_WIDTHS 🔒
HELVETICA_OBLIQUE_WINANSI 🔒
HELVETICA_WINANSI 🔒
SYMBOL_CHARS 🔒
SYMBOL_KERNS 🔒
TIMES_BOLDITALIC_CHARS 🔒
TIMES_BOLDITALIC_KERNS 🔒
TIMES_BOLDITALIC_NAME_WIDTHS 🔒
TIMES_BOLDITALIC_WINANSI 🔒
TIMES_BOLD_CHARS 🔒
TIMES_BOLD_KERNS 🔒
TIMES_BOLD_NAME_WIDTHS 🔒
TIMES_BOLD_WINANSI 🔒
TIMES_ITALIC_CHARS 🔒
TIMES_ITALIC_KERNS 🔒
TIMES_ITALIC_NAME_WIDTHS 🔒
TIMES_ITALIC_WINANSI 🔒
TIMES_ROMAN_CHARS 🔒
TIMES_ROMAN_KERNS 🔒
TIMES_ROMAN_NAME_WIDTHS 🔒
TIMES_ROMAN_WINANSI 🔒
ZAPFDINGBATS_CHARS 🔒
ZAPFDINGBATS_KERNS 🔒

Statics§

COURIER 🔒
COURIER_BOLD 🔒
COURIER_BOLDOBLIQUE 🔒
COURIER_OBLIQUE 🔒
HELVETICA 🔒
HELVETICA_BOLD 🔒
HELVETICA_BOLDOBLIQUE 🔒
HELVETICA_OBLIQUE 🔒
SYMBOL 🔒
TIMES_BOLD 🔒
TIMES_BOLDITALIC 🔒
TIMES_ITALIC 🔒
TIMES_ROMAN 🔒
ZAPFDINGBATS 🔒

Functions§

extended_glyph_name
Returns the PostScript glyph name for ch if and only if ch is in the extended tier: i.e. a Core 14 AFM glyph that has no WinAnsi byte and therefore must be reached through a custom /Encoding /Differences slot. The extended tier covers:
winansi_byte
Returns the PDF WinAnsiEncoding byte that encodes ch, or None if ch has no slot in WinAnsi.
winansi_glyph_name
Returns the PostScript glyph name assigned to PDF WinAnsiEncoding byte code, or None for unmapped codes.