Skip to content

set_font/set_stretching: also reject NaN and infinity - #2104

Merged
andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:font-size-finite
Nov 3, 2026
Merged

andersonhc merged 3 commits into
py-pdf:masterfrom
RavSinghChandan:font-size-finite

Conversation

@RavSinghChandan

Copy link
Copy Markdown

set_font_size(float("inf")) wrote BT /F1 inf Tf ET and then -inf Td nan Ts for the next cell; set_stretching(float("nan")) wrote nan Tz. They now raise their existing ValueError, with a math.isfinite() check like set_display_mode() uses. write_html() ignores an infinite <font size="inf"> like a negative one, instead of failing with "Not enough horizontal space to render a single character".

  • A unit test is covering the code added / modified by this PR
  • A mention of the change is present in CHANGELOG.md
  • This PR is ready to be merged

@andersonhc
andersonhc merged commit d163b5b into py-pdf:master Nov 3, 2026
23 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