Skip to content

fix(pdf-codec, documents.js): decimal points, Distiller glyph ids and tables open at a page break - #1810

Merged
Mearman merged 3 commits into
mainfrom
fix/pdf-chain-decimal-glyph-table
Nov 14, 2026
Merged

Mearman merged 3 commits into
mainfrom
fix/pdf-chain-decimal-glyph-table

Conversation

@Mearman

@Mearman Mearman commented Nov 14, 2026

Copy link
Copy Markdown
Member

Three PDF reading defects, each found on a real document and fixed at its cause.

A verified symbol subset whose font dictionary names no encoding (pdf-codec). A typesetter's math italic subset draws a full stop at the glyph it names /colon and a comma at /semicolon, and its /ToUnicode reads each by its name, so 0.212 reads as 0:212. The checked tables in verified-glyph-tables.ts select a glyph by the name /Differences or the named base encoding gives its code; a dictionary with no /Encoding at all reaches the glyph through the program's built-in encoding, which the lookup never asked. It now does (ISO 32000-1 9.6.6.1), opening the program only for a font whose subset has a table, and the second AdvP4C4E51 program written this way is added with its rendered sheet.

A Century Schoolbook subset Distiller numbers g<id> (pdf-codec). Distiller converts the TrueType face to a CFF subset naming each glyph g plus its glyph id in the face, the lower-case form of the optimiser's G<id>. With no /ToUnicode every code read as U+FFFD. The numbered-name pattern takes either case and the generated glyph orders carry the four Century Schoolbook faces; regenerating left the twelve faces already carried byte-identical, and the width agreement check still decides whether a subset is the face.

A ruled table whose row is left open at a page break (documents.js). A table breaking across pages leaves its last row open at the foot of the page, the rule under it drawn under some columns or none and the side borders running down to it. Since a border drawn in pieces is joined into one boundary, that open row became the grid's bottom edge, the rectangle did not close, and the whole table was read as prose with tab-separated rows. A grid that does not close now loses a top or bottom row boundary that does not span it and is tested again; no column boundary is ever taken off, so a gap in a side border still leaves the grid unclosed.

Measured on the real documents, re-extracted with these builds:

  • the math book: 165 colon-as-decimal-point figures to 0, and digit-colon-digit sequences in its text from 1,188 to 57 (the rest are real colons);
  • the distilled standard: a hidden 70-glyph heading that read as 70 U+FFFD now reads as its letters (0 replacement characters);
  • the 633-page standard: tables lost against an earlier extraction from 3 to 1. Across all its pages every grid the earlier documents.js found is still found and 14 pages gain one; no page loses one. The one still counted lost is written as an HTML table because of its spanned cells, which the downstream comparison does not read.

Tests use made-up fixtures of the same shapes: a synthetic CFF program with a built-in encoding and no dictionary /Encoding, a made-up line in Century Schoolbook Bold's glyph ids and widths (refused under the italic face's name), and a grid with an open last row, an open first row, a gap in a side border and a short side border. Each new assertion fails on main.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant