Skip to content

feat: TrueType font support (ISO 32000-2 §9.6.3, §9.7) (Block B) #11

@ralflang

Description

@ralflang

PDF TrueType font handling

TrueType font parser and subsetting

Read ttf files with a TrueTypeFontParser: head, hhea, maxp, cmap, hmtx,
loca, glyf, name, OS/2, post tables.

Extract metrics and glyph outlines.

Create TrueTypeFontSubsetter that produces a minimal .ttf containing only the
glyphs referenced by a given set of Unicode codepoints.

Output: FontDescriptor with embedded font program stream, widths array.

Tests: parse known .ttf fixture, subset and verify table structure, metrics match.

TODO: Should we maybe put all TTF handling into a separate namespace with potential ejection to a standalone library?

CIDFont + Type0Font for Unicode text

Implement the Font interface with CidFont and Type0Font classes.

Type0Font wraps a CIDFont descendant with Identity-H CMap encoding.

Generate ToUnicodeCMap for text extraction / copy-paste from PDF viewers.

Update PdfSerializer to emit CIDFont dictionaries, CIDSystemInfo, DescendantFonts.

Tests: CJK text renders, ToUnicode map produces correct extraction, multi-byte.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions