Skip to main content

Module embedded

Module embedded 

Source
Expand description

Type 0 CID-keyed font emission for bundled embedded faces.

Each embedded face used in a document is emitted as five indirect objects:

  1. Font dict (Type 0, Identity-H, descendant + ToUnicode refs)
  2. CIDFont dict (CIDFontType2, /CIDSystemInfo, /W, /CIDToGIDMap /Identity, descriptor ref)
  3. FontDescriptor dict (bbox, ascent, descent, italic angle, stem widths, /FontFile2 ref)
  4. /FontFile2 stream (the subsetted TTF, with /Length1 = uncompressed size)
  5. /ToUnicode CMap (maps each subset CID back to the source cluster’s UTF-8 codepoints)

The subset is built per-document over the union of glyph IDs seen across every run that uses the face. With /CIDToGIDMap /Identity the CID in the content stream equals the GID inside the subset font file. subsetter::GlyphRemapper provides the original-GID β†’ subset-GID mapping.

StructsΒ§

EmbeddedFontPlan πŸ”’
Per-face plan: which glyph IDs were used, the subset bytes, the GlyphRemapper that maps original β†’ subset GIDs, and the gid-to-source-text map used to build /ToUnicode.
EmbeddedRefs πŸ”’
PDF objects emitted for one embedded face. The 5 refs are allocated up front so the cross-references resolve.

EnumsΒ§

ContentOp πŸ”’

FunctionsΒ§

accumulate_glyphs πŸ”’
cids_to_bytes πŸ”’
emit_embedded πŸ”’
Emit the 5 PDF objects for one embedded face. Caller allocates the refs and ensures they’re cross-referenced from each page’s /Font resource dict.
encode_glyph_run πŸ”’
Encode shaped glyphs into PDF text-content operations. Each ShapedGlyph::gid is remapped through plan.remapper to its subset CID. GPOS advances become TJ adjustments; glyphs with GPOS offsets get their own absolute Tm so marks draw at the shaped position and the next glyph resumes from the un-offset pen.
flush_cids πŸ”’
plan_embedded πŸ”’
Plan every embedded face touched by runs. Returns one EmbeddedFontPlan per face actually referenced, in stable (EmbeddedFontId-sorted) order.
subset_tag πŸ”’
Six-letter uppercase subset tag derived deterministically from the subset bytes. Required by PDF 1.7 Β§9.6.4 for embedded subsets: the /BaseFont and FontDescriptor /FontName must start with <6 uppercase letters>+.
units_to_f32 πŸ”’
units_to_pt πŸ”’
units_to_text_adjust πŸ”’
write_font_descriptor πŸ”’