forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed FPDF.local_context() style leak during page breaks - Fix #1204
- Loading branch information
Showing
8 changed files
with
125 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from pathlib import Path | ||
|
||
from fpdf import FPDF, FontFace | ||
|
||
from test.conftest import assert_pdf_equal | ||
|
||
HERE = Path(__file__).resolve().parent | ||
|
||
|
||
def test_header_footer_and_use_font_face(tmp_path): # issue 1204 | ||
class PDF(FPDF): | ||
def header(self): | ||
with self.use_font_face(FontFace(color="#00ff00", size_pt=12)): # LABEL A | ||
self.cell(text=f"Header {self.page_no()}") | ||
self.ln() | ||
|
||
def footer(self): | ||
self.set_y(-15) | ||
with self.use_font_face(FontFace(color="#0000ff", size_pt=12)): # LABEL B | ||
self.cell(text=f"Footer {self.page_no()}") | ||
|
||
pdf = PDF() | ||
pdf.set_font(family="helvetica", size=12) | ||
pdf.add_page() | ||
with pdf.use_font_face(FontFace(size_pt=36)): # LABEL C | ||
pdf.multi_cell(w=0, text="\n".join(f"Line {i + 1}" for i in range(21))) | ||
assert pdf.font_size_pt == 12 | ||
assert_pdf_equal(pdf, HERE / "header_footer_and_use_font_face.pdf", tmp_path) |