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.
Structs§
- BBox
- A font or glyph bounding box, with ordinary
f32precision limits. - Character
Metric - One character record; missing advances stay absent until resolved against the font.
- Composite
- A
CCconstruction recipe; it does not synthesize outlines or character metrics. - Composite
Component - One
PCCcomponent in a composite definition. - Direction
Metrics - Authored metrics for one writing direction. Shared blocks populate both entries.
- Font
Metrics - Parsed AFM metric data. Optional authored fields retain absence; accessors resolve defaults.
- Kerning
Pair - A complete pair adjustment in one writing direction.
- Ligature
- One
L successor ligaturerule. Every rule on a character is retained in order. - Source
Record - Comment or uninterpreted extension data, ordered by appearance in the source.
- Track
Kern - One track-kerning curve, retained as its degree and endpoint values.
- Vector
- A point or displacement in AFM units (1/1000 of the font scale).
Enums§
- Base14
Font - One of the 14 standard PDF fonts every conformant PDF reader ships built in (PDF 1.7 §9.6.2.2).
- Character
Code - An encoded character number; hexadecimal digits are retained without angle brackets. These values are encoding-specific and are not Unicode scalar values.
- Direction
- AFM writing direction, independent of the sign or axis of an advance vector.
- Kerning
Operands - Pair operands retain the distinction between glyph names and encoded hexadecimal values.
- Metrics
Sets MetricsSetsorStartDirectionselector; 2 applies to both directions.- Record
Context - Location of a comment or unrecognized record within the parsed AFM structure.
Constants§
- COURIER_
BOLDOBLIQUE_ 🔒CHARS - COURIER_
BOLDOBLIQUE_ 🔒COMPOSITES - COURIER_
BOLDOBLIQUE_ 🔒KERNS - COURIER_
BOLDOBLIQUE_ 🔒NAME_ WIDTHS - COURIER_
BOLDOBLIQUE_ 🔒RECORDS - COURIER_
BOLDOBLIQUE_ 🔒TRACKS - COURIER_
BOLDOBLIQUE_ 🔒WINANSI - COURIER_
BOLD_ 🔒CHARS - COURIER_
BOLD_ 🔒COMPOSITES - COURIER_
BOLD_ 🔒KERNS - COURIER_
BOLD_ 🔒NAME_ WIDTHS - COURIER_
BOLD_ 🔒RECORDS - COURIER_
BOLD_ 🔒TRACKS - COURIER_
BOLD_ 🔒WINANSI - COURIER_
CHARS 🔒 - COURIER_
COMPOSITES 🔒 - COURIER_
KERNS 🔒 - COURIER_
NAME_ 🔒WIDTHS - COURIER_
OBLIQUE_ 🔒CHARS - COURIER_
OBLIQUE_ 🔒COMPOSITES - COURIER_
OBLIQUE_ 🔒KERNS - COURIER_
OBLIQUE_ 🔒NAME_ WIDTHS - COURIER_
OBLIQUE_ 🔒RECORDS - COURIER_
OBLIQUE_ 🔒TRACKS - COURIER_
OBLIQUE_ 🔒WINANSI - COURIER_
RECORDS 🔒 - COURIER_
TRACKS 🔒 - COURIER_
WINANSI 🔒 - HELVETICA_
BOLDOBLIQUE_ 🔒CHARS - HELVETICA_
BOLDOBLIQUE_ 🔒COMPOSITES - HELVETICA_
BOLDOBLIQUE_ 🔒KERNS - HELVETICA_
BOLDOBLIQUE_ 🔒NAME_ WIDTHS - HELVETICA_
BOLDOBLIQUE_ 🔒RECORDS - HELVETICA_
BOLDOBLIQUE_ 🔒TRACKS - HELVETICA_
BOLDOBLIQUE_ 🔒WINANSI - HELVETICA_
BOLD_ 🔒CHARS - HELVETICA_
BOLD_ 🔒COMPOSITES - HELVETICA_
BOLD_ 🔒KERNS - HELVETICA_
BOLD_ 🔒NAME_ WIDTHS - HELVETICA_
BOLD_ 🔒RECORDS - HELVETICA_
BOLD_ 🔒TRACKS - HELVETICA_
BOLD_ 🔒WINANSI - HELVETICA_
CHARS 🔒 - HELVETICA_
COMPOSITES 🔒 - HELVETICA_
KERNS 🔒 - HELVETICA_
NAME_ 🔒WIDTHS - HELVETICA_
OBLIQUE_ 🔒CHARS - HELVETICA_
OBLIQUE_ 🔒COMPOSITES - HELVETICA_
OBLIQUE_ 🔒KERNS - HELVETICA_
OBLIQUE_ 🔒NAME_ WIDTHS - HELVETICA_
OBLIQUE_ 🔒RECORDS - HELVETICA_
OBLIQUE_ 🔒TRACKS - HELVETICA_
OBLIQUE_ 🔒WINANSI - HELVETICA_
RECORDS 🔒 - HELVETICA_
TRACKS 🔒 - HELVETICA_
WINANSI 🔒 - SYMBOL_
CHARS 🔒 - SYMBOL_
COMPOSITES 🔒 - SYMBOL_
KERNS 🔒 - SYMBOL_
RECORDS 🔒 - SYMBOL_
TRACKS 🔒 - TIMES_
BOLDITALIC_ 🔒CHARS - TIMES_
BOLDITALIC_ 🔒COMPOSITES - TIMES_
BOLDITALIC_ 🔒KERNS - TIMES_
BOLDITALIC_ 🔒NAME_ WIDTHS - TIMES_
BOLDITALIC_ 🔒RECORDS - TIMES_
BOLDITALIC_ 🔒TRACKS - TIMES_
BOLDITALIC_ 🔒WINANSI - TIMES_
BOLD_ 🔒CHARS - TIMES_
BOLD_ 🔒COMPOSITES - TIMES_
BOLD_ 🔒KERNS - TIMES_
BOLD_ 🔒NAME_ WIDTHS - TIMES_
BOLD_ 🔒RECORDS - TIMES_
BOLD_ 🔒TRACKS - TIMES_
BOLD_ 🔒WINANSI - TIMES_
ITALIC_ 🔒CHARS - TIMES_
ITALIC_ 🔒COMPOSITES - TIMES_
ITALIC_ 🔒KERNS - TIMES_
ITALIC_ 🔒NAME_ WIDTHS - TIMES_
ITALIC_ 🔒RECORDS - TIMES_
ITALIC_ 🔒TRACKS - TIMES_
ITALIC_ 🔒WINANSI - TIMES_
ROMAN_ 🔒CHARS - TIMES_
ROMAN_ 🔒COMPOSITES - TIMES_
ROMAN_ 🔒KERNS - TIMES_
ROMAN_ 🔒NAME_ WIDTHS - TIMES_
ROMAN_ 🔒RECORDS - TIMES_
ROMAN_ 🔒TRACKS - TIMES_
ROMAN_ 🔒WINANSI - ZAPFDINGBATS_
CHARS 🔒 - ZAPFDINGBATS_
COMPOSITES 🔒 - ZAPFDINGBATS_
KERNS 🔒 - ZAPFDINGBATS_
RECORDS 🔒 - ZAPFDINGBATS_
TRACKS 🔒
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 extended-tier PostScript glyph name for
ch. - 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.