fix(pdf): export TrueType text as embedded subset fonts, not triangles

PDF export filled every TrueType glyph's tessellated outline, one triangle
per triple. A stroke-heavy CJK face such as DFKai-SB tessellates into
hundreds of triangles per character, so a 28-layout schematic set
exported at 320.9 MB and viewers crawled through it. The atlas export
table was also rebuilt for every text wire, which made the same export
take 566 s.

- ttf_glyph: GlyphSource records the face, glyph id and font-unit scale a
  filled outline came from; glyph_source / fallback_source resolve the
  same face as glyph / fallback_glyph (fallback picks both in one search).
- Face::glyph_source mirrors Face::glyph; stroke glyphs (LFF, SHX, big
  font) return None and keep their polyline export.
- GlyphExport carries the char and the source (filled glyphs only, so
  TEXTFILL 0 still exports hollow outlines).
- pdf_export draws a sourced glyph as text (Tf 1 + a Tm that maps its em
  onto the SDF quad), subsets each face with allsorts after all pages
  (keeping cvt/fpgm/prep for tricky fonts), renumbers glyph ids, and
  snapshots the glyph table once per export.

Same set: 566 s / 320.9 MB -> 27 s / 1.42 MB; text is searchable and
lands on the same pixels as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris YehandClaude Opus 5.5 committed 2026-10-01 23:07:15 +08:00
1 parent 6cc53c1001
commit a8dc6534f9
6 files changed
+539 -22

No files matched your search

Generated
+1
View File
@@ -6,6 +6,7 @@ version = 4
name = "OpenCADStudio"
version = "2026.39.0"
dependencies = [
"allsorts",
"ashpd",
"base64",
"bincode",