Graphics drawing = Graphics.FromImage(img) first, create a dummy bitmap just to get a graphics object Var font= new Font(modernFont.Families, 12) //The second argument is the font size ModernFont.AddFontFile("NafeesNaskh.ttf") //Load font from the font file Var modernFont = new PrivateFontCollection() For someone who might face similar problem may use following to generate Urdu text images (all of the fonts supported): //Create the font using your font file However, I was able to find a work around for this using the good old. On further R&D found out that this is still an issue specifically for Urdu and no solution has been worked out for it yet:
![urdu fonts graphics urdu fonts graphics](https://www.softlay.com/wp-content/uploads/2015/11/Urdu-Fonts-Ms-Office-2003-2007-2010-2016-e1518461787441.png)
Text_string = get_display(reshape(text_string)) Text_string = u'نیدرلینڈز کی ملکہ پاکستان آ رہی ہیں'įont = uetype('./UrduFontsDirectory' + data.iloc, 25)ĭraw.text((25,40), text_string, fill='white', font=font)Īlso I tried using Arabic Reshaper which resolved the alignment on rendering issue but yet some characters never get rendered: from PIL import Image, ImageFont, ImageDraw
URDU FONTS GRAPHICS CODE
Text_string = u'Hello how are you doing?'ĭraw.text((25,40), text_string, fill='white')įollowing is the code and result when done with Urdu: from PIL import Image, ImageFont, ImageDraw
![urdu fonts graphics urdu fonts graphics](https://www.mtctutorials.com/wp-content/uploads/kumail-urdu-font-mtc.jpg)
Using the same code to generate normal English works like a charm but when I do the same with Urdu text things just does not go as smooth.įollowing is the code and result when done with English: from PIL import Image, ImageFont, ImageDraw
![urdu fonts graphics urdu fonts graphics](https://cdn.dribbble.com/users/2180538/screenshots/12165828/media/bcea7434af63c869de4a99bd2a5416c4.jpg)
I am trying to generate image for some Urdu text using Pillow.