Skip to content

Commit

Permalink
Fix: non-bold TitleStyle is now rendered as non-bold even when the cu…
Browse files Browse the repository at this point in the history
…rrent font is bold - fix #1072 (#1078)
  • Loading branch information
Lucas-C authored Dec 30, 2023
1 parent 52205c0 commit f00f472
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
* support for `<path>` elements in SVG `<clipPath>` 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
Expand Down
4 changes: 1 addition & 3 deletions fpdf/fpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/outline/test_outline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Binary file not shown.

0 comments on commit f00f472

Please sign in to comment.