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

Text shaping does not work with text() #1265

Closed
bmiklautz opened this issue Sep 20, 2024 · 2 comments · Fixed by #1266
Closed

Text shaping does not work with text() #1265

bmiklautz opened this issue Sep 20, 2024 · 2 comments · Fixed by #1266
Labels

Comments

@bmiklautz
Copy link

When using text() with shaping enabled like documented in
https://py-pdf.github.io/fpdf2/Text.html and https://py-pdf.github.io/fpdf2/TextShaping.html the created text isn't shaped.

Minimal code

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.add_font('khmer', '', 'NotoSansKhmer-Regular.ttf')
pdf.set_font('khmer', size=32)
pdf.set_text_shaping(True)
pdf.text(20,100, text="ភាសាខ្មែរ")

pdf.set_xy(20,110)
pdf.cell(text="ភាសាខ្មែរ")

pdf.set_xy(20,130)
pdf.write(None, text="ភាសាខ្មែរ")

pdf.output("hello_world.pdf")

In the example Noto Sans Khmer was used (can be downloaded from https://fonts.google.com/noto/specimen/Noto+Sans+Khmer) but the problem occurs with other fonts as well.

The following screenshot shows the output of the example. Text placed with write() and cell() is represented correctly but text() (first line) isn't.
Screenshot 2024-09-20 at 12 19 23

Environment
Please provide the following information:

  • Operating System: MacOS, Linux (Debian/Ubuntu)
  • Python version: Python 3.10.14, Python 3.11.9, Python 3.12.4
  • fpdf2 version used: master 90c7d7f

Thank you for your efforts and work on fpdf2.

@bmiklautz bmiklautz added the bug label Sep 20, 2024
@andersonhc
Copy link
Collaborator

Hi @bmiklautz,

The text() method is kept on the codebase for backwards compatibility, but it lacks many of the features available in write(), cell(), and multicell() like markdown and text shaping.

We could definitely add this information on our documentation to avoid confusion. Let me know if you're interested in submitting a PR.

bmiklautz added a commit to bmiklautz/fpdf2 that referenced this issue Sep 30, 2024
* adept comparison table in Text.md (add text shaping)
* add a note in the functions doc string
bmiklautz added a commit to bmiklautz/fpdf2 that referenced this issue Sep 30, 2024
* adept comparison table in Text.md (add text shaping)
* add a note in the functions doc string
bmiklautz added a commit to bmiklautz/fpdf2 that referenced this issue Sep 30, 2024
* adept comparison table in Text.md (add text shaping)
* add a note in the functions doc string
bmiklautz added a commit to bmiklautz/fpdf2 that referenced this issue Sep 30, 2024
* adept comparison table in Text.md (add text shaping)
* add a note in the functions doc string
@bmiklautz
Copy link
Author

bmiklautz commented Sep 30, 2024

@andersonhc thank you for your answer. I've created #1266.

bmiklautz added a commit to bmiklautz/fpdf2 that referenced this issue Oct 1, 2024
* adept comparison table in Text.md (add text shaping)
* add a note in the functions doc string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants