Repository navigation
BUG: Collect the fonts declared in the AcroForm /DR dictionary - #3983
Merged
stefan6419846 merged 1 commit intoAug 20, 2026
Merged
Conversation
`_get_fonts_walk` iterates the /DR font dictionary directly:
for f in cast(DictionaryObject, cast(DictionaryObject, obj["/DR"])["/Font"]):
process_font(f)
Iterating a DictionaryObject yields its keys, so `process_font` receives
the font *names* rather than the font dictionaries. `/BaseFont` is never
found on a name, so every font that a form declares only in its default
resources is silently dropped from `_get_fonts()`. The /Resources branch
a few lines below already uses `.values()`.
Also widened the `process_font` annotation from DictionaryObject to
PdfObject. The entries can be indirect references, which is why the
function starts by resolving its argument with `get_object()`, and a
runtime protocol check rejects them as declared.
Added an offline test that builds an AcroForm carrying one /DR font; it
fails on main because the collected set comes back empty.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3983 +/- ##
=======================================
Coverage 97.95% 97.95%
=======================================
Files 57 57
Lines 11043 11043
Branches 2068 2068
=======================================
Hits 10817 10817
Misses 126 126
Partials 100 100 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
approved these changes
Aug 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_get_fonts_walkiterates the /DR font dictionary directly:Iterating a DictionaryObject yields its keys, so
process_fontreceives thefont names rather than the font dictionaries.
/BaseFontis never found on aname, so every font that a form declares only in its default resources is
silently dropped from
_get_fonts(). The /Resources branch a few lines belowalready uses
.values(), which is what made me look.Also widened the
process_fontannotation from DictionaryObject to PdfObject.The entries can be indirect references - that is why the function starts by
resolving its argument with
get_object()- and a runtime protocol checkrejects them as declared. That accounts for 7 failures in test_page under
make testtype; they go to 0.Added an offline test that builds an AcroForm carrying one /DR font. It fails
on main because the collected set comes back empty.
mypy reports the same 11 pre-existing errors before and after, none in this
file, and ruff check passes.