diff --git a/test/break_or_add_page_draw_fill.pdf b/test/break_or_add_page_draw_fill.pdf new file mode 100644 index 000000000..aaa3c2dea Binary files /dev/null and b/test/break_or_add_page_draw_fill.pdf differ diff --git a/test/errors/test_FPDF_errors.py b/test/errors/test_FPDF_errors.py index 0e68f4589..872f7453a 100644 --- a/test/errors/test_FPDF_errors.py +++ b/test/errors/test_FPDF_errors.py @@ -105,3 +105,11 @@ def test_repeated_calls_to_output(tmp_path): pdf = fpdf.FPDF() assert_pdf_equal(pdf, HERE / "repeated_calls_to_output.pdf", tmp_path) assert_pdf_equal(pdf, HERE / "repeated_calls_to_output.pdf", tmp_path) + + +def test_incorrent_number_of_pages_toc(): + pdf = fpdf.FPDF() + pdf.add_page() + pdf.insert_toc_placeholder(lambda a, b: None, 10) + with pytest.raises(FPDFException): + pdf.close() diff --git a/test/fonts/Quicksand-Regular.otf b/test/fonts/Quicksand-Regular.otf new file mode 100644 index 000000000..c0ffc32c2 Binary files /dev/null and b/test/fonts/Quicksand-Regular.otf differ diff --git a/test/fonts/test_add_font.py b/test/fonts/test_add_font.py index fbb4e322f..87d4fc2d4 100644 --- a/test/fonts/test_add_font.py +++ b/test/fonts/test_add_font.py @@ -88,3 +88,11 @@ def test_render_en_dash(tmp_path): # issue-166 pdf.add_page() pdf.cell(w=pdf.epw, txt="–") # U+2013 assert_pdf_equal(pdf, HERE / "render_en_dash.pdf", tmp_path) + + +def test_add_font_otf(): + pdf = FPDF() + font_file_path = HERE / "Quicksand-Regular.otf" + with pytest.raises(RuntimeError) as error: + pdf.add_font("Quicksand", fname=font_file_path) + assert str(error.value) == "Postscript outlines are not supported" diff --git a/test/test_add_page.py b/test/test_add_page.py index e746da0e9..88fa3ba7a 100644 --- a/test/test_add_page.py +++ b/test/test_add_page.py @@ -2,6 +2,7 @@ import fpdf from test.conftest import assert_pdf_equal +from fpdf.drawing import DeviceGray HERE = Path(__file__).resolve().parent @@ -45,3 +46,27 @@ def test_break_or_add_page(tmp_path): pdf.set_x(100) pdf.multi_cell(50, 10, f"Text {i} - Page {pdf.page}", 1, "C") assert_pdf_equal(pdf, HERE / "break_or_add_page.pdf", tmp_path) + + +def test_break_or_add_page_with_different_draw_and_fill_color(tmp_path): + class CustomHeader(fpdf.FPDF): + def header(self): + self.line_width = 0 + self.draw_color = DeviceGray(0.2) + self.fill_color = DeviceGray(0.2) + + pdf = CustomHeader() + pdf.set_auto_page_break(auto=True, margin=0) + pdf.draw_color = DeviceGray(0.5) + pdf.set_stretching(101) + pdf.add_page() + pdf.set_font("Helvetica", "", 16) + for i in range(1, 51): + pdf.set_x(10) + pdf.multi_cell(50, 10, f"Text {i} - Page {pdf.page}", 1, "C") + pdf.page = 1 + pdf.set_xy(100, 10) + for i in range(51, 101): + pdf.set_x(100) + pdf.multi_cell(50, 10, f"Text {i} - Page {pdf.page}", 1, "C") + assert_pdf_equal(pdf, HERE / "break_or_add_page_draw_fill.pdf", tmp_path)