Compare commits

..
Author SHA1 Message Date
Abimael Martell ef0596bdc3 review: resolve indirect numeric elements in Type3 FontMatrix/FontBBox
PDF syntax allows array elements to be indirect references; the scale
computation silently read them as zero. Resolve through the document
before computing scale_y/bbox_h, with a regression test.
2026-08-03 11:18:05 -07:00
Abimael Martell e66cfec5aa review: resolve Symbol/ZapfDingbats codes through built-in encodings for widths
The width fallback decoded every code without a Differences entry as
cp1252, but Symbol and ZapfDingbats glyphs live at byte positions
unrelated to Latin text (Symbol 0x61 renders alpha, Zapf 0x21 renders
U+2701) — those codes missed their AFM entries and got the generic
default. Codes now resolve Differences -> built-in Symbol/Zapf encoding
-> cp1252 fallback, so advances match what the renderer draws.
Encoding tables generated from the Adobe standard encodings alongside
the width tables.
2026-08-03 11:03:55 -07:00
Abimael Martell 6689430534 review: address cubic round 2 + local review findings
- base14: alias U+00A0/U+00AD to space/hyphen widths (cp1252 fallback
  can produce them; they previously got the generic default); drop the
  redundant 'mono' conjunct in Courier matching
- Embedded drop cap: normalize whitespace at the join — mid-word caps
  concatenate directly, standalone-word caps keep exactly one space;
  target must also read as a paragraph first line (starts alphabetic,
  >=8 letters) so labels/headings in the geometric window are never
  rewritten
- Script exclusion in the body-font pass now requires a heading-sized
  anchor (>=1.15x base): sub/superscripts attached to headings stay
  excluded, while a body-size table cell beside a slightly larger
  label with baseline jitter is never filtered
2026-08-03 10:48:26 -07:00
Abimael Martell c36493319f review: address cubic feedback
- Gate ALL heading paths (font-tier + rarity + sequence) behind the
  display-equation check, not just the rarity fallback; require >=2
  operator chars in is_symbol_dominated and stop counting grouping
  chars so short legit headings like "A + B" or "(R-12)" survive
- Require a genuine baseline offset for script attachment so a small
  cell beside a larger same-baseline label is never filtered; index
  attachment targets by Y (sorted, window scan) instead of scanning
  the whole page per candidate
- Restrict the tiny-all-numeric table veto to the small-font pass
- Strengthen the phantom-table regression test with the real
  entropy.pdf page-1 geometry: asserts the layout forms a table
  without anchors and is suppressed with them
- Embedded drop cap: char-count instead of byte-length, target only
  the immediately preceding line with column/indent continuity, and
  require a substantive body run before rewriting
- compute_heading_tiers: use the dominant (alphanumeric-weighted)
  size consistently with detection; symmetric +/-20% uniformity bound;
  char-boundary-safe debug preview (no more potential UTF-8 panic)
- merge_heading_lines: dominant size for the merge gap threshold
- base14: real ZapfDingbats metrics (via the ZapfDingbats encoding
  vector), exact-name matching for Symbol/ZapfDingbats so custom
  fonts mentioning 'Symbol' never get base-14 metrics; width decode
  now matches the extractor's cp1252-style single-byte fallback
- Apply Type3 visual scaling in the Form XObject text path too
- Redact document text from table-region debug logs (coords/metrics
  only)
2026-08-03 10:18:16 -07:00
Abimael Martell 39be831f8f fix(extractor): handle legacy dvips/Distiller PDFs (base-14 metrics, Type3 sizing, TeX layout heuristics)
Shannon's entropy.pdf (1998 dvips 5.58 -> Distiller 3) exposed a failure
class affecting pre-2000 TeX PDFs:

- Base-14 fallback widths (new src/extractor/base14.rs): PDFs may omit
  /Widths for non-embedded standard fonts; the spec requires the reader
  to supply the metrics. Without them every item had width 0, breaking
  space synthesis, sub/superscript detection, and table columns.
  Tables generated from the Adobe Core 14 AFM data, resolved per code
  through the font's Differences encoding.
- Type3 visual sizing: PK bitmap fonts use FontMatrix [1 0 0 -1 0 0]
  with nominal sizes like 0.12pt; scale by FontBBox height x |matrix_y|
  so drop caps and math glyphs get realistic sizes.
- Table detection: exclude script-attached small items (equation
  sub/superscripts) from small-font candidates; reject tiny all-numeric
  2-row grids (exponent clusters aligning as phantom tables).
- First-line-indent paragraph breaks for justified documents that
  separate paragraphs only by indentation.
- Embedded drop-cap merge (two-line caps land as the second line's
  first item, previously emitted mid-sentence).
- Heading robustness: classify by dominant alphanumeric font size,
  ignore glyph-run lines when computing tiers, and stop rarity-promoting
  display equations to headings.

On entropy.pdf: phantom-table pages 28 -> 8, glued sentences 95 -> 5,
correct sub/superscripts, drop cap restored, title/PART hierarchy fixed.
pdf-evals: 202/203 byte-identical, semantic score flat. Adds the paper's
first two pages as a snapshot fixture.
2026-08-03 09:52:47 -07:00

Diff Content Not Available