Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROB: MissingWidth is IndirectObject #2288

Merged
merged 3 commits into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pypdf/_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from ._codecs import adobe_glyphs, charset_encoding
from ._utils import b_, logger_warning
from .errors import PdfReadWarning
from .generic import DecodedStreamObject, DictionaryObject, StreamObject
from .generic import DecodedStreamObject, DictionaryObject, IndirectObject, NullObject, StreamObject


# code freely inspired from @twiggy ; see #711
Expand Down Expand Up @@ -457,6 +457,17 @@
m += x
cpt += 1
sp_width = m / max(1, cpt) / 2

if isinstance(sp_width, IndirectObject):
# According to
# 'Table 122 - Entries common to all font descriptors (continued)'
# the MissingWidth should be a number, but according to #2286 it can
# be an indirect object
obj = sp_width.get_object()

Check warning on line 466 in pypdf/_cmap.py

View check run for this annotation

Codecov / codecov/patch

pypdf/_cmap.py#L466

Added line #L466 was not covered by tests
if obj is None or isinstance(obj, NullObject):
return 0.0
return obj # type: ignore

Check warning on line 469 in pypdf/_cmap.py

View check run for this annotation

Codecov / codecov/patch

pypdf/_cmap.py#L468-L469

Added lines #L468 - L469 were not covered by tests

return sp_width


Expand Down
Loading