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§
Structs§
- BBox
- A glyph or font bounding box, in 1/1000 em.
- Character
Metric - One entry from a
StartCharMetricsblock. - Font
Metrics - All public AFM data extracted from a single
.adobe-font-metricsfile. - Kerning
Pair - One entry from a
StartKernPairsblock.
Enums§
- Base14
Font - 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
chif and only ifchis in the extended tier: i.e. a Core 14 AFM glyph that has noWinAnsibyte and therefore must be reached through a custom/Encoding/Differencesslot. The extended tier covers: - winansi_
byte - Returns the PDF
WinAnsiEncodingbyte that encodesch, orNoneifchhas no slot inWinAnsi. - winansi_
glyph_ name - Returns the PostScript glyph name assigned to PDF
WinAnsiEncodingbytecode, orNonefor unmapped codes.