Skip to content

Commit

Permalink
Fixing issue py-pdf#1223: pdf.font_style now behaves like pdf.set_font
Browse files Browse the repository at this point in the history
  • Loading branch information
smilerightnow committed Sep 1, 2024
1 parent e54583c commit ab64006
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
* In [text_columns()](https://py-pdf.github.io/fpdf2/extColumns.html), paragraph top/bottom margins didn't correctly trigger column breaks; [issue #1214](https://github.com/py-pdf/fpdf2/issues/1214)
* [`fpdf.drawing.color_from_hex_string`](https://py-pdf.github.io/fpdf2/fpdf/drawing.html#fpdf.drawing.color_from_hex_string) did not test or mention accepting lowercase hex values.
* handling of bidirectional text on `FPDF.get_string_width()` [issue #1231]
* pdf.font_style now behaves like pdf.set_font() `FPDF.font_style` [issue #1223]
* new translation of the tutorial in [Indonesian](https://py-pdf.github.io/fpdf2/Tutorial-id.html) - thanks to @odhyp
### Removed
* an obscure and undocumented [feature](https://github.com/py-pdf/fpdf2/issues/1198) of [`FPDF.write_html()`](https://py-pdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.write_html), which used to magically pass instance attributes as arguments.
Expand Down
Binary file added test/fonts/fonts_issue_1223.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions test/fonts/test_set_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ def test_set_builtin_font(tmp_path):
pdf.text(0, 10 + 40 * i + 10 * j, "Hello World!")
assert_pdf_equal(pdf, HERE / "fonts_set_builtin_font.pdf", tmp_path)

def test_issue_1223(tmp_path):
pdf = FPDF()
pdf.add_page()
pdf.set_font("Helvetica", size=32)
with pdf.text_columns() as cols:
with cols.paragraph() as par:
par.write(text="Un.")
pdf.font_style = "B"
with cols.paragraph() as par:
par.write(text="Deux.")
pdf.font_style = "I"
par.write(text="Trois.")
assert_pdf_equal(pdf, HERE / "fonts_issue_1223.pdf", tmp_path)

def test_issue_66(tmp_path):
pdf = FPDF()
Expand Down

0 comments on commit ab64006

Please sign in to comment.