How to use multiple fonts in multi_cell if it contains english and arabic letters #583
Replies: 2 comments 3 replies
-
Hi @papunmohanty-homer and welcome! Interesting question. from fpdf import FPDF
pdf = FPDF()
pdf.add_font("NotoSansArabic", fname="NotoSansArabic.ttf")
pdf.add_page()
pdf.set_font("NotoSansArabic", size=24)
text = "تمانتمانتمانتمانتم"
text_width = pdf.get_string_width(text)
pdf.multi_cell(w=text_width + 2, h=5, txt=text)
pdf.set_font("Helvetica", size=24)
pdf.multi_cell(w=0, h=5, txt="English Letters")
pdf.output("discuss_583.pdf") Does that solve your issue @papunmohanty-homer? |
Beta Was this translation helpful? Give feedback.
-
Apparently, the Noto Sans Arabic font does not include any latin character glyphs. If you absolutely need to use this specific font, then the suggestion by @Lucas-C above is the way to go (or a variation using the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If I need to print mixed fonts how can I achieve it
pdf.multi_cell(w=150, h=5, txt="تمانتمانتمانتمانتم English Letters")
I have posted my question in Stackoverflow as well
https://stackoverflow.com/questions/74059846/how-to-print-arabic-and-english-text-together-using-pythons-fpdf-library
Beta Was this translation helpful? Give feedback.
All reactions