feat(detect): flag pages with gid-encoded fonts for OCR

Fonts using raw glyph ID names (gidNNNNN) in their Differences
encoding cannot be decoded to Unicode without the original font's
cmap table. Detect this pattern during font parsing and add
affected pages to pages_needing_ocr so downstream consumers
know to use OCR instead.

Fixes text extraction on PDFs like Tezukuri_Food-Menu.pdf where
the main body font (AcuminVariableConcept) uses gid-encoded
glyphs — even PyMuPDF and ODL fail on these.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Abimael Martell
2026-03-19 08:36:16 -07:00
co-authored by Claude Opus 4.6
parent da8c27f3c4
commit 74d416e8ce
6 changed files with 96 additions and 30 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ use std::collections::HashMap;
use crate::text_utils::should_join_items;
/// Result tuple returned by page-level text extraction: text items, rectangles, and line segments.
/// Result tuple returned by page-level text extraction: text items, rectangles, line segments,
/// and whether fonts with unresolvable gid-encoded glyphs were encountered.
pub(crate) type PageExtraction = (Vec<TextItem>, Vec<PdfRect>, Vec<PdfLine>);
// ── Font types (crate-internal) ──────────────────────────────────────