Drawing Hebrew text and image using image module (python)

This is a problem that I already asked about, and several received answers, but the problem remained. when I try to write Hebrew on an image using the Image module, instead of the Hebrew lettring, I get the inscription (ascii ??). if I convert to unicode or ascii, I get an error message that it does not support. I got a link to a code that does what I want in Chinese:

import sys

import Imag

import ImageDraw

import ImageFont

import _imaging

txt = '你好,世界!'

font = ImageFont.truetype('c:/test/simsun.ttc',24)

im = Image.new("RGBA",(300,200),(0,0,0))

draw = ImageDraw.Draw(im)

#draw.text( (0,50), u'你好,世界!', font=font)

draw.text( (0,50), unicode(txt,'UTF-8'), font=font)

but then I get an error: ImportError:

The _imagingft C module is not installed.

The same thing happens when I try to use the standard Hebrew font "arial.ttf" (with a Hebrew string). As you can see, I imported _imaging succsefuly, so the problem does not lie there, as suggested by effbot.org.

, Imagefont.truetype(...).

+2
2

, PIL FreeType. Dev FreeType PIL.

+3

, PIL 1.1.7 Windows XP. Linux XP, PIL 1.1.6

+1

Source: https://habr.com/ru/post/1731016/


All Articles