Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sections must have a style #1072

Closed
dmail00 opened this issue Dec 24, 2023 · 2 comments
Closed

Sections must have a style #1072

dmail00 opened this issue Dec 24, 2023 · 2 comments

Comments

@dmail00
Copy link

dmail00 commented Dec 24, 2023

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
Copy link
Member

Lucas-C commented Dec 30, 2023

Thank you for the report @dmail00

I opened #1078 to fix this.

@Lucas-C Lucas-C closed this as completed Dec 30, 2023
Lucas-C added a commit that referenced this issue Dec 30, 2023
Lucas-C added a commit that referenced this issue Dec 30, 2023
@Lucas-C
Copy link
Member

Lucas-C commented Jan 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants