Sections must have a style
Closed this issue · 2 comments
dmail00 commented
Describe the bug
Sections must have a style otherwise style is take from the previous(current) font style.
Minimal code
from fpdf import FPDF, TitleStyle
def test_headings():
# fonts.py line:55 will set emphasis to None
# fpdf.py line: 4870 will use the previous style as emphasis is None
pdf = FPDF()
pdf.add_page()
pdf.set_font("Helvetica", "B") # this is the font style that will be used
level0 = TitleStyle("Helvetica", "", 20, (0, 0, 0)) # empty string or None does not matter
pdf.set_section_title_styles(level0)
pdf.start_section("foo")
pdf.output("test_headings.pdf")
if __name__ == "__main__":
test_headings()
Environment
Please provide the following information:
- Operating System: Windows
- Python version: 3.11.3
fpdf2
version used: 2.7.7
Lucas-C commented
The fix has been merged into the master
branch of this repo, but not released yet.
You can install this unreleased latest version this way, if you want to test that this fix solves your initial problem:
pip install git+https://github.com/py-pdf/fpdf2.git@master