Skip to content

Commit

Permalink
FIX : cope with cmap from py-pdf#1322
Browse files Browse the repository at this point in the history
fixes py-pdf#1322
cope with cmap where the range contains first and last   code are on variable length.
Also fix cases where the code is on 3 characters only (not standard)
no test data available
  • Loading branch information
pubpub-zz committed Sep 27, 2022
1 parent d9aa64c commit c216b97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions PyPDF2/_cmap.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import warnings
from binascii import unhexlify
from math import ceil
from typing import Any, Dict, List, Tuple, Union, cast

from ._codecs import adobe_glyphs, charset_encoding
Expand Down Expand Up @@ -267,9 +268,9 @@ def parse_bfrange(
) -> Union[None, Tuple[int, int]]:
lst = [x for x in l.split(b" ") if x]
closure_found = False
nbi = len(lst[0])
map_dict[-1] = nbi // 2
fmt = b"%%0%dX" % nbi
nbi = max(len(lst[0]), len(lst[1]))
map_dict[-1] = ceil(nbi / 2)
fmt = b"%%0%dX" % (map_dict[-1] * 2)
if multiline_rg is not None:
a = multiline_rg[0] # a, b not in the current line
b = multiline_rg[1]
Expand Down

0 comments on commit c216b97

Please sign in to comment.