Commit 96aea33
committed
fix(render): Type0/CIDFontType2 font CID→GID mapping (issue #215)
Root cause: open-pdf-render/src/fonts.rs treated a MISSING /CIDToGIDMap entry
as false. Per ISO 32000-1 §9.7.4.2 the spec default for CIDFontType2 is
Identity — absence must mean true. Combined with a system-font fallback
heuristic that triggered when GIDs 1–10 of an embedded subset had empty
outlines (common — those slots are placeholder/control glyphs), CIDs were
ultimately looked up as Unicode codepoints in the system Arial cmap. CID 46
('K' in the embedded ArialMT) → Unicode 46 = '.', producing the observed
-29 shift "Kelder" → ".HOGHU".
Fix:
- check_cid_to_gid_identity: missing /CIDToGIDMap → true (spec Identity);
explicit Stream → false.
- build_font_entry: never apply system-font fallback to Type0/CID fonts.
CID→GID mapping is embed-specific; no system Arial substitute is ever
correct.
- cid_to_glyph_id: identity → ToUnicode→cmap → CID-as-Unicode fallback
(last resort only, preserves any previously-working PDFs).
Verified on the user's test PDF (Vloerverwarming Woning Bert van Dorp): all
4 pages now render text correctly — "Kelder", "Begane Grond", "groep 01.01",
"Regelunit 01", "Kunststof 8", etc.
Note: text *extraction* (selection layer) still returns U+FFFD for these PDFs
because the embedded /ToUnicode streams are empty. Selectable-text support
for such PDFs is tracked separately.1 parent 076557d commit 96aea33
4 files changed
Lines changed: 57 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
144 | 160 | | |
145 | 161 | | |
146 | 162 | | |
147 | 163 | | |
148 | 164 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
| |||
314 | 325 | | |
315 | 326 | | |
316 | 327 | | |
317 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
318 | 333 | | |
319 | 334 | | |
320 | 335 | | |
321 | 336 | | |
322 | | - | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
323 | 341 | | |
324 | 342 | | |
325 | | - | |
| 343 | + | |
| 344 | + | |
326 | 345 | | |
327 | 346 | | |
328 | 347 | | |
| |||
484 | 503 | | |
485 | 504 | | |
486 | 505 | | |
487 | | - | |
488 | | - | |
489 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
490 | 514 | | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | 515 | | |
| 516 | + | |
| 517 | + | |
495 | 518 | | |
496 | 519 | | |
497 | 520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
0 commit comments