Skip to content

set_font/add_font: treat a repeated style letter as the same style - #2062

Merged
andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:font-style-repeated-letters
Oct 27, 2026
Merged

andersonhc merged 1 commit into
py-pdf:masterfrom
RavSinghChandan:font-style-repeated-letters

Conversation

@RavSinghChandan

Copy link
Copy Markdown

set_font() and add_font() normalize the style by sorting its letters, but kept duplicates, so set_font("helvetica", style="BB") looked for a font named helveticaBB and raised FPDFException: Undefined font: helveticaBB - Use built-in fonts or FPDF.add_font() beforehand, which does not point at the real cause. A style string built in code (for example by appending "B" for a bold context to a style that is already bold) easily repeats a letter.

A repeated letter now means the same style: "BB" is bold and "ibIu" is bold italic underlined. Unknown letters still raise as before (test_set_unknown_style is unchanged). Added tests for set_font() and add_font().

@andersonhc
andersonhc merged commit f90c615 into py-pdf:master Oct 27, 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