Skip to content

feat(extractor): expose the raw font resource tag on TextItem - #449

Merged
abimaelmartell merged 1 commit into
mainfrom
feat/font-tag
Aug 21, 2026
Merged

feat(extractor): expose the raw font resource tag on TextItem#449
abimaelmartell merged 1 commit into
mainfrom
feat/font-tag

Conversation

@abimaelmartell

@abimaelmartell abimaelmartell commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

1.16.0 replaced TextItem::font's resource tag with the /BaseFont family name (#415). That is the right default, but it erased the only signal distinguishing two font programs that share a family name — consumers that partition items by font program (style grouping, feature parity with pre-1.16.0 extractions) lost their key when same-family subsets merged.

This adds a font_tag field carrying exactly what font carried before 1.16.0:

  • the raw per-page resource tag (F2, T22), stamped by both content-stream parsers from the same resource name
  • first run's tag on merged items; propagated through derived items (numeric splits, heuristic-table splits)
  • the tag active at EMC for ActualText spans, matching the sibling font/is_bold/is_italic/font_size fields, which all sample the same state at the same point — legacy parity is the contract, so any change to that sampling must move all five fields together
  • empty for items not born from a content-stream show operator (images, links, form fields, OCR)

Exposed through --items-json, the Node binding (fontTag), and the Python binding (font_tag + .pyi stub). The wasm binding doesn't surface positioned items, so no change there.

Compatibility

  • npm and PyPI surfaces are strictly additive; markdown output is byte-identical.
  • For the Rust crate, the new pub field is source-breaking for consumers that construct TextItem literally or destructure it exhaustively (field readers are unaffected). TextItem is an output type, so literal construction outside tests is expected to be rare, but the release that ships this should be versioned with that caveat in mind.

Notes

  • Tests: stamping parity pinned in both parsers (items_carry_family_name_and_resource_tag, form_items_carry_family_name_and_resource_tag).

1.16.0 replaced TextItem::font's resource tag with the /BaseFont family
name (#415). That is the right default, but it erased the only signal
that distinguishes two font programs sharing a family: consumers that
partition items by font program (style grouping, training-time feature
parity) lost their key when same-family subsets merged.

Add font_tag, carrying exactly what font carried before 1.16.0: the raw
per-page resource tag, first-run's tag on merged items, empty for items
that don't come from a content-stream show operator (images, links,
form fields, OCR). Both content-stream parsers stamp it from the same
resource name, derived items (numeric splits, merges) propagate it, and
it is exposed through --items-json and the Node/Python bindings.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 31 files

Shadow auto-approve: would not auto-approve because issues were found.

Fix all with cubic | Re-trigger cubic

Comment thread src/types.rs
Comment thread src/extractor/content_stream.rs
@abimaelmartell

Copy link
Copy Markdown
Member Author

@cubic-dev-ai

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown

@cubic-dev-ai

@abimaelmartell I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 31 files

Shadow auto-approve: would require human review. This PR adds a font_tag field to TextItem to restore data parity. It is a source-breaking change for Rust crate consumers and modifies the public API contract across multiple bindings.

Re-trigger cubic

@abimaelmartell
abimaelmartell merged commit 2ae4e29 into main Aug 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant