7

I'm trying to change the direction of text on an image using pil on python3, but I am unable to do so, because the dependency libraqm isn't installed. I can't find a way to install libraqm.


I tried to install it through pip, but it didnt work.

I also tried to find it, and I did but there are no instructions on how to install it on Windows 10; only on Mac OS and Linux. The link is: https://github.com/HOST-Oman/libraqm/


from PIL import Image, ImageDraw, ImageFont, ImageTk, features


Coords = [0,0]
Text = 'Hello World'
colour = '#225643'
Font = ImageFont.truetype("Font/GentiumBasic-Regular.ttf", 40, 
                                 encoding="unic"))

direction = 'rtl' #Right to Left
Alignment= 'right'

til = Image.new("RGBA", (800, 500))
draw = ImageDraw.Draw(til)
draw.text(Coords, Text, colour, font=Fonts, 
                  align=Alignment, direction=direction)
til.show()

Raises:

File "C:\Users\Yousef\AppData\Roaming\Python\Python37\site-packages\PIL\ImageFont.py", line 185, in getmask2

size, offset = self.font.getsize(text, direction, features, language)

KeyError: 'setting text direction, language or font features is not supported without libraqm'.


from PIL import Image, ImageDraw, ImageFont, ImageTk, features
print (features.check('raqm'))
print (Image.PILLOW_VERSION)

Returns:

False

6.0.0

I'm just wondering on how I should install it? Any help would be much appreciated, thank you :)

1

2 Answers 2

5

The easiest way to not actually install libraqm, but to get it working in python / PIL is:

  • Download the unofficial build dlls from here (search for "libraqm")
  • Copy them to the same directory as your python.exe

Restart you kernel and it should work.

1
  • 1
    Link to dlls is dead, rather frustratingly Commented Jun 9 at 15:51
3

Libraqm also has its own dependencies that need to be installed. The easiest way to install Libraqm and its dependencies is to use vcpkg link

Here's a video that explains to to use vcpkg video

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.