Repository navigation
ROB: Do not crash when the font widths are not an array - #4118
Merged
Merged
Conversation
_collect_tt_t1_character_widths casts the /Widths entry of a TrueType or Type1 font to an ArrayObject and enumerates it, so a file storing a string there raised 'ValueError: invalid literal for int() with base 10' out of extract_text() when the characters were passed to int(). The entry is now checked and a font whose widths cannot be read is reported and skipped, which is how the surrounding code already handles a non-numeric width entry.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4118 +/- ##
=======================================
Coverage 98.10% 98.10%
=======================================
Files 59 59
Lines 11559 11562 +3
Branches 2161 2162 +1
=======================================
+ Hits 11340 11343 +3
Misses 124 124
Partials 95 95 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
approved these changes
Sep 22, 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.
_collect_tt_t1_character_widths casts the /Widths entry of a TrueType or Type1
font to an ArrayObject and enumerates it:
The cast has no effect at runtime, so a file storing a string there is iterated
character by character and raises 'ValueError: invalid literal for int() with
base 10' out of extract_text().
The entry is now checked and a font whose widths cannot be read is reported and
skipped, which is how the loop below already handles a non-numeric width entry.
Offline suite passes, 1390 tests.
Used Claude (Opus) to help locate and patch this; I reviewed and tested the change.