From f00f47205e051ac11fdfb020d1294c18d273af81 Mon Sep 17 00:00:00 2001 From: Lucas Cimon <925560+Lucas-C@users.noreply.github.com> Date: Sat, 30 Dec 2023 20:16:08 +0100 Subject: [PATCH] Fix: non-bold TitleStyle is now rendered as non-bold even when the current font is bold - fix #1072 (#1078) --- CHANGELOG.md | 1 + fpdf/fpdf.py | 4 +--- test/outline/test_outline.py | 9 +++++++++ .../toc_with_font_style_override_bold.pdf | Bin 0 -> 1857 bytes 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 test/outline/toc_with_font_style_override_bold.pdf diff --git a/CHANGELOG.md b/CHANGELOG.md index 5340bc815..5b87383ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default', * support for `` elements in SVG `` elements ### Fixed * When adding a link on a table cell, an extra link was added erroneously on the left. Moreover, now `FPDF._disable_writing()` properly disable link writing. +* non-bold `TitleStyle` is now rendered as non-bold even when the current font is bold ## [2.7.7] - 2023-12-10 ### Added diff --git a/fpdf/fpdf.py b/fpdf/fpdf.py index 489921a41..c2c4bbda6 100644 --- a/fpdf/fpdf.py +++ b/fpdf/fpdf.py @@ -4871,9 +4871,7 @@ def use_font_face(self, font_face: FontFace): prev_font = (self.font_family, self.font_style, self.font_size_pt) self.set_font( font_face.family or self.font_family, - font_face.emphasis.style - if font_face.emphasis is not None - else self.font_style, + font_face.emphasis.style if font_face.emphasis is not None else "", font_face.size_pt or self.font_size_pt, ) prev_text_color = self.text_color diff --git a/test/outline/test_outline.py b/test/outline/test_outline.py index c8e4249fd..e3b358ea0 100644 --- a/test/outline/test_outline.py +++ b/test/outline/test_outline.py @@ -231,3 +231,12 @@ def test_toc_without_font_style(tmp_path): # issue-676 pdf.start_section("Title") pdf.start_section("Subtitle", level=1) assert_pdf_equal(pdf, HERE / "toc_without_font_style.pdf", tmp_path) + + +def test_toc_with_font_style_override_bold(tmp_path): # issue-1072 + pdf = FPDF() + pdf.add_page() + pdf.set_font("Helvetica", "B") + pdf.set_section_title_styles(TitleStyle("Helvetica", "", 20, (0, 0, 0))) + pdf.start_section("foo") + assert_pdf_equal(pdf, HERE / "toc_with_font_style_override_bold.pdf", tmp_path) diff --git a/test/outline/toc_with_font_style_override_bold.pdf b/test/outline/toc_with_font_style_override_bold.pdf new file mode 100644 index 0000000000000000000000000000000000000000..a32fbc162a175e88f32f6eb54c630e65df39ec8d GIT binary patch literal 1857 zcmbtV&yU+w5Jo+rCn3(Im$|H(B6XjiebYU;cf?B{lu zbH(2P6~`j=Sj69f)b`E+B&Y-zF2I#}esB#Rv84!)Y)A@n9+BvD_Uz}!NM7kIn255CKG{Q%$2PS+ghI9l?Y z?ClXQ78=fOz}}3q`y+8Iq1&bUJ70jx3Xab7aLq+8R*4i^sp1)OlSYaUc`O&4&;u@(>K+8X4$4)=qZK*%)|veIi~Zd3 zZns`#V=t=9|lV4xm|M1bG_uY#hi@%EBF1!=`^nuU=u98)w_8Nuuqnw8l zd#BfV`hcq>j;{7)x*&94VAY9O0==Dxp2(BhK?QGM;h;bBarZV&Es(?`VY^(62rR)#vC=qXR9(I>8N? z2O17FZgimK3QX@8CNl(_*Kq?#M>c?1sWXjKYhCM6#>EOncphv&<*NoznXg9rq*&q3 zTQINinx&Vf+7WBF%4}r^n05)}rNBYz?OhfbigO07V=1q^Ieqg;yuLkQlI6HN734wG z_+fadk3zGN^INR17_QZjW30JiKtKKL2x;?~v+KF_d8zlbIxdEA%@G(5u=+%$ylMqU zUn!n7cXNP?rw`Z=R})&pk66$SnC&nYSoj>V;Id_1zS1c6B;&`#0_G9zU><0Dp5wtW zoY|0F{eU>L1t`G{o83l%ZrEIgQrob3KI(hJ*7mn^bo}iczK`^7#0K7$AG7Q&JZ5!J z)8}Iu`;S=L+4gf>RCXP!vM5P;R{l>-lP_^uJVMI@Urn$4hbbq68#Efiyld@u{JL#Jhxy*#|9g~6kgF(D<&N|1c!~0ww+b