Skip to content

ROB: Do not crash on a composite font without descendant fonts - #4119

Merged
stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:type0-without-descendant-fonts
Sep 22, 2026
Merged

stefan6419846 merged 1 commit into
py-pdf:mainfrom
RavSinghChandan:type0-without-descendant-fonts

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

from_font_resource reads /DescendantFonts directly on the composite-font branch,
with a comment stating the entry does not need to be tested for "because all
other fonts have already been dealt with".

That holds for the subtype, not for the entry. A /Type0 font which omits
/DescendantFonts raises a bare KeyError out of extract_text(), and one storing a
dictionary or a string there is cast to an ArrayObject and enumerated.

The entry is now read with a default and checked, matching how the same function
already reads /FontDescriptor. The half of the comment that is no longer true
was removed; the half describing the /W array was kept.

Offline suite passes, 1390 tests.

Used Claude (Opus) to help locate and patch this; I reviewed and tested the change.

from_font_resource reads /DescendantFonts directly on the composite-font
branch, with a comment stating the entry does not need to be tested for because
every other font subtype has already been handled. That holds for the subtype,
not for the entry: a /Type0 font which omits /DescendantFonts raised a bare
KeyError out of extract_text(), and one storing a dictionary or a string there
was cast to an ArrayObject and enumerated.

The entry is now read with a default and checked, matching how the same
function already reads /FontDescriptor. A composite font whose descendants
cannot be read still yields a font, with its widths left empty, rather than
failing the page.
@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.10%. Comparing base (2c536fc) to head (aaf16dc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4119   +/-   ##
=======================================
  Coverage   98.10%   98.10%           
=======================================
  Files          59       59           
  Lines       11547    11553    +6     
  Branches     2158     2159    +1     
=======================================
+ Hits        11328    11334    +6     
  Misses        124      124           
  Partials       95       95           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@RavSinghChandan RavSinghChandan changed the title Title: ROB: Do not crash on a composite font without descendant fonts ROB: Do not crash on a composite font without descendant fonts Sep 22, 2026
@stefan6419846
stefan6419846 merged commit 359f70d into py-pdf:main Sep 22, 2026
20 of 21 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.

2 participants