Skip to main content

Crate pdfboss_encoding

Crate pdfboss_encoding 

Source
Expand description

Shared PDF font-encoding tables (WinAnsi / MacRoman / Standard, from ISO 32000 Appendix D), glyph-name-to-Unicode resolution over the Adobe Glyph List, and the built-in encoding of a Type 1 font program, consumed by the pdfboss text-extraction and rendering crates.

Functions§

glyph_to_text
Resolves a glyph name to the text it represents, per the Adobe Glyph List algorithm: everything from the first period on is dropped (eight.oldstyle8), underscore-joined components each resolve and concatenate (f_ifi, T_hTh), and a uni prefix may carry several 4-digit hex groups. None unless every component resolves — a partially-resolved ligature would silently drop letters, where the caller’s U+FFFD at least stays visible.
glyph_to_unicode
Resolves a glyph name (as used in /Differences) to a Unicode scalar: uniXXXX and uXXXXuXXXXXX hex forms, single ASCII letters, the Adobe Glyph List, and the TeX math names the list never adopted. None for an unknown name, and for a listed name whose text is more than one scalar; glyph_to_text resolves those.
is_standard_14
Whether base_font (after subset-prefix stripping and alias normalization) names one of the standard 14 fonts.
mac_roman
Unicode value of code in MacRomanEncoding.
standard
Unicode value of code in StandardEncoding.
standard_14_width
The advance width (1000-unit glyph space) of glyph_name in the standard-14 font whose PDF /BaseFont (or a recognized alias, or a subsetted variant) is base_font, or None if base_font isn’t one of the standard 14 (including Symbol/ZapfDingbats, which this module doesn’t tabulate) or glyph_name is unknown to that font. Courier’s four variants are monospaced (every glyph is 600 units wide per the Adobe Core-14 AFM metrics) and so always return Some(600.0). Oblique variants share their upright counterpart’s widths (Helvetica and Helvetica-Oblique are metrically identical, likewise the bold pair), so only upright/bold tables are stored.
standard_encoding_name
Adobe StandardEncoding glyph name for code (ISO 32000-1 Annex D.2 “StandardEncoding” column; equivalently Adobe Type 1 Font Format Appendix C). None for exactly the codes standard leaves unassigned (see the self-verifying standard_encoding_name_matches_standard_table test below, which ties this table to that one so an authoring mistake here fails a test rather than silently mis-encoding a glyph).
type1_builtin_encoding
The built-in encoding of an embedded Type 1 font program: code to glyph name, read from the program’s clear-text portion, which is where ISO 32000-1 9.6.6 sends a simple font that states no usable /Encoding of its own. A bare StandardEncoding token expands to that table, and any dup <code> /<name> put entries override it code by code. None when the program states no /Encoding at all.
win_ansi
Unicode value of code in WinAnsiEncoding.
win_ansi_glyph_name
WinAnsiEncoding glyph name for code (ISO 32000-1 Annex D.2 “WinAnsiEncoding” column). None for exactly the codes win_ansi leaves unassigned. Two ASCII codes diverge from StandardEncoding’s names: 0x27 is quotesingle and 0x60 is grave (the straight marks, matching win_ansi’s identity mapping there). Two codes render an existing glyph rather than owning one: 0xA0 carries space (the nonbreaking space draws as the space glyph) and 0xAD carries hyphen (likewise the soft hyphen) — see the self-verifying win_ansi_glyph_name_matches_win_ansi_table test below.