font-subset only.Expand description
Embedding a caller-supplied Unicode font, so a replacement can contain
scripts the document itself never had. See
text_edit::FontFallback::EmbedUnicode.
Embedding a caller-supplied Unicode font, so a replacement can contain
characters the document’s own fonts have no glyph for.
Embedding a caller-supplied Unicode font as a Type0 composite
font, so a replacement can contain characters the original font has no
glyph for.
§Why this exists
The Phase 1B replacement path re-encodes through the original font’s
reverse map, and its fallback ([FontFallback::InjectStandard]) injects
Helvetica/WinAnsi. Both are bounded by what the document already had:
WinAnsi tops out at U+00FF. That is fine for replacing a word in an
English document and useless for writing Polish, Greek, Cyrillic, CJK or
any other script the source never contained.
A Type0 font with Identity-H encoding removes that ceiling: character
codes are 2-byte glyph indices into an embedded font program, so the
reachable set is whatever the supplied font covers.
§Why the caller supplies the font
Embedding glyphs redistributes the font. Rather than bundle one and inherit its licence terms (and its size — a full CJK face is tens of megabytes), the caller passes the bytes of a font they are licensed to embed. That also lets them pick a face per language, which a bundled default could not do. A bundled default can be layered on later without changing this API.
§What is written
Type0 (/Encoding /Identity-H)
└── DescendantFonts[0] → CIDFontType2
├── /CIDToGIDMap /Identity CID == GID, no extra indirection
├── /W per-glyph advances
└── /FontDescriptor → /FontFile2 (subsetted font program)
└── /ToUnicode CMap so the text stays extractableThe /ToUnicode map is not optional here. Without it a translated
document renders correctly and yields nothing on copy, search or
screen-reader — which for a translation workflow is a silent, total loss
of the actual product.
§Subsetting and glyph identity
Glyphs are remapped to a compact range via subsetter::GlyphRemapper,
so the embedded program carries only what is used. Because Identity-H
ties the character code to the glyph index, the codes written into the
content stream are the new (post-remap) indices, never the original
ones. Getting that pairing wrong produces a file that opens cleanly and
renders the wrong glyphs, so the two always travel together in
UnicodeEncoder.
Structs§
- Unicode
Encoder - Accumulates glyph usage for one page, then writes the font.
- Unicode
Font - A caller-supplied font, validated as embeddable.
Enums§
- Outlines
- Which outline format the font program carries.