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

STY: Remove variable check_crlf_space #3096

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 5 additions & 8 deletions pypdf/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -1907,8 +1907,8 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
nonlocal char_scale, space_scale, _space_width, TL, font_size, cmap
nonlocal orientations, rtl_dir, visitor_text, output, text, _actual_str_size

check_crlf_space: bool = False
str_widths: float = 0.0

# Table 5.4 page 405
if operator == b"BT":
tm_matrix = [1.0, 0.0, 0.0, 1.0, 0.0, 0.0]
Expand All @@ -1918,14 +1918,14 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
text = ""
memo_cm = cm_matrix.copy()
memo_tm = tm_matrix.copy()
return None
if operator == b"ET":
elif operator == b"ET":
output += text
if visitor_text is not None:
visitor_text(text, memo_cm, memo_tm, cmap[3], font_size)
text = ""
memo_cm = cm_matrix.copy()
memo_tm = tm_matrix.copy()

# Table 4.7 "Graphics state operators", page 219
# cm_matrix calculation is reserved for later
elif operator == b"q":
Expand Down Expand Up @@ -1964,6 +1964,7 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
)
memo_cm = cm_matrix.copy()
memo_tm = tm_matrix.copy()

# Table 5.2 page 398
elif operator == b"Tz":
char_scale = float(operands[0]) / 100 if operands else 1.0
Expand Down Expand Up @@ -2012,7 +2013,6 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
pass # keep previous size
# Table 5.5 page 406
elif operator == b"Td":
check_crlf_space = True
# A special case is a translating only tm:
# tm = [1, 0, 0, 1, e, f]
# i.e. tm[4] += tx, tm[5] += ty.
Expand All @@ -2023,15 +2023,12 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
str_widths = compute_str_widths(_actual_str_size["str_widths"])
_actual_str_size["str_widths"] = 0.0
elif operator == b"Tm":
check_crlf_space = True
tm_matrix = [float(operand) for operand in operands[:6]]
str_widths = compute_str_widths(_actual_str_size["str_widths"])
_actual_str_size["str_widths"] = 0.0
elif operator == b"T*":
check_crlf_space = True
tm_matrix[5] -= TL
elif operator == b"Tj":
check_crlf_space = True
text, rtl_dir, _actual_str_size = self._handle_tj(
text,
operands,
Expand All @@ -2048,7 +2045,7 @@ def process_operation(operator: bytes, operands: List[Any]) -> None:
else:
return None

if check_crlf_space:
if operator in ( b"Td", b"Tm", b"T*", b"Tj"):
try:
text, output, cm_prev, tm_prev = crlf_space_check(
text,
Expand Down
Loading