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

Not displaying Russian text in the table of contents #320

Closed
lcomrade opened this issue Jan 18, 2022 · 5 comments · Fixed by #324
Closed

Not displaying Russian text in the table of contents #320

lcomrade opened this issue Jan 18, 2022 · 5 comments · Fixed by #324

Comments

@lcomrade
Copy link

Russian characters are not displayed in the table of contents.
But English text, numbers and special characters are displayed normally.

Error details
I don't get any exceptions.

Minimal code

from fpdf import FPDF
from fpdf import TitleStyle

if __name__ == "__main__":
    # Setup
    pdf = FPDF("P", "mm", "A4")
    pdf.add_page()

    pdf.add_font("FreeMono", fname="FreeMono.ttf", uni=True)
    pdf.add_font("FreeMonoBold", fname="FreeMonoBold.ttf", uni=True)
    pdf.set_font("FreeMono", style="", size=18)

    pdf.set_section_title_styles(TitleStyle(
        font_family="FreeMonoBold",
        font_style="",
        font_size_pt=24,
        color=None,
        underline=False,
        t_margin=10,
        l_margin=10,
        b_margin=0,
    ))

    # Write text
    pdf.start_section("Русский, English, 1 2 3...")

    pdf.write(8, "Русский текст в параграфе.")
    pdf.ln(15)

    # Save result
    pdf.output("test.pdf")

Environment

  • GNU/Linux
  • Python 3.9.2
  • fpdf2 2.4.6
@lcomrade lcomrade added the bug label Jan 18, 2022
@lcomrade
Copy link
Author

The table of contents should be Русский, English, 1 2 3..., but it displays , English, 1 2 3....

image

@Lucas-C
Copy link
Member

Lucas-C commented Jan 18, 2022

Thank you for reporting this @lcomrade

This is strange as we should have a test covering this already:

I'll try to have a closer look at it this evening

@Lucas-C
Copy link
Member

Lucas-C commented Jan 18, 2022

@all-contributors please add @lcomrade for bug

@allcontributors
Copy link

@Lucas-C

I've put up a pull request to add @lcomrade! 🎉

@Lucas-C
Copy link
Member

Lucas-C commented Jan 18, 2022

OK so in fact the existing test shares the same issue:
the hebrew text is not rendered in the outline.

cf. cfe92904

I guess we need to find the correct encoding to use when embedding unicode text in the document outline.

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