Skip to main content

extended_glyph_name

Function extended_glyph_name 

pub fn extended_glyph_name(ch: char) -> Option<&'static str>
Expand description

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:

  • most of Latin Extended-A (Ł, ł, Ě, ě, Ő, ő, …, excluding those that already live in WinAnsi like š/Š/ž/Ž);
  • the Latin Extended-B comma-below set Ș/ș/Ț/ț;
  • the spacing diacritics ˘ˇ˙˝˛˚;
  • the math operators −≤≥≠√∂∑∆◊;
  • the fraction slash and the fi/fl ligatures.

Returns None for two distinct cases that callers must distinguish:

  1. WinAnsi natives: š (U+0161), ž (U+017E), Š, Ž, the accented Latin-1 alphabet, , , … These do have PostScript glyph names in the AFM, but this function returns None for them because they’re reachable through winansi_byte instead and don’t need a /Differences slot. Callers querying “what’s the AFM glyph name for é?” should use Base14Font::glyph_width_by_name on the result of [winansi_glyph_name](winansi_byte(ch)?), or just measure widths through Base14Font::winansi_width.
  2. Unmappable codepoints with no glyph in any Core 14 font (Cyrillic, CJK, emoji, most non-European scripts). The PDF backend silently substitutes these to ? for Base14 runs; real coverage requires the bundled embedded family that mos-fonts provides.

The name extended_glyph_name is deliberately chosen over the shorter glyph_name to avoid surprising readers who reach for the function expecting “AFM name for any char.” For any-tier AFM lookup the two-step (winansi_glyph_namewinansi_byte) then-fallback-to-extended_glyph_name composition is the way.

Used by the PDF backend’s /Differences-based encoding planner to allocate slots for the extended tier.

§Examples

use pdf_base14_metrics::extended_glyph_name;

assert_eq!(extended_glyph_name('Ł'), Some("Lslash"));
assert_eq!(extended_glyph_name('A'), None);