tuxnani
tuxnani

Reputation: 3864

Telugu (Unicode) font not rendering correctly in pyfpdf

I am trying to render Telugu text into pdf using pyfpdf. The problem is with font rendition in fpdf. What might be the problem? The code I used is :

#!/usr/bin/python
# -*- coding: utf8 -*-
from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.add_font('lakkireddy', '', 'LakkiReddy.ttf', uni=True)
pdf.set_font('lakkireddy','', 16)
pdf.cell(40,10,u'హలో ప్రపంచమా!')
pdf.output('testfpdf.pdf','F')`

The expected output is : enter image description here

But the actual output is broken text : enter image description here

What could be the issue, Is it the font, Is it encoding or Is it font rendering engine? Can I define which font rendering engine to use?

Upvotes: 2

Views: 863

Answers (1)

Mihai Iancu
Mihai Iancu

Reputation: 1828

I am not familiar with fpdf but it seems that fpdf does not support proper text shaping for complex scripts. Glyph shapes change based on glyph position in the string and based on its neighbor glyphs but fpdf does not seem to do this kind of processing by default.

You have to check if there are options in fpdf for specifying this kind of processing for complex scripts.

Upvotes: 1

Related Questions