I have a file named \"hindi.txt\". It has contents as follows. I\'m using Python3.5.
कामकाजी महिलाओं के लिए देश में दिल्ली असुरक्षित, सिक्किम सबसे बेहतर: रिपोर्ट
Pillow 7.0.0 provides support for rendering complex font with raqm library
To check for support:
>>> from PIL import features
>>> print(features.check("raqm"))
True
If it returns False check if library is installed:
/sbin/ldconfig -p | grep raqm
libraqm.so.0 (libc6,x86-64) => /usr/lib/libraqm.so.0
libraqm.so (libc6,x86-64) => /usr/lib/libraqm.so
To Install raqm in debian based distros:
sudo apt-get install libraqm-dev
To use raqm as layout engine add layout_engine option while initializing font:
font = ImageFont.truetype("foo.ttf", size=90, layout_engine=ImageFont.LAYOUT_RAQM)
The above code is tested for: Hindi, Marathi, Gujrati and Telugu fonts.