Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL Direction issue #4496

Closed
CovertError opened this issue Mar 29, 2020 · 14 comments
Closed

RTL Direction issue #4496

CovertError opened this issue Mar 29, 2020 · 14 comments
Labels
Installation Usually a problem with … Question

Comments

@CovertError
Copy link

CovertError commented Mar 29, 2020

What did you do?

I'm trying to put an RTL(Right to left direction) text(Arabic) on an image

What did you expect to happen?

being able to set the direction of the text

What actually happened?

I got an error saying setting text direction, language or font features is not supported without libraqm

What are your OS, Python and Pillow versions?

  • OS: Windows (Running pycharm virtual python)
  • Python: 3.6
  • Pillow: PIL 7.0.0
import PIL
import arabic_reshaper
from PIL import Image, ImageDraw, ImageFont
from bidi.algorithm import get_display

    image = Image.open('main.jpeg')

    draw = ImageDraw.Draw(image)

    font = ImageFont.truetype('din-next-lt-w23-medium.ttf', size=60)

    text_to_be_reshaped = 'محمد'
    reshaped_text = arabic_reshaper.reshape(text_to_be_reshaped)
    bidi_text = get_display(reshaped_text)
    print(bidi_text.__sizeof__() + font.size)
    print(type(bidi_text))
    (x, y) = (1050, 463)
    color = 'rgb(255, 255, 255)'  # white color
    draw.text((x, y), bidi_text, fill=color, font=font, direction="rtl")

    # draw the message on the background

    image.save('result.png')
@CovertError
Copy link
Author

same issue on Linux Ubuntu 16.04

@hugovk
Copy link
Member

hugovk commented Mar 30, 2020

setting text direction or font features is not supported without libraqm.

https://pillow.readthedocs.io/en/stable/installation.html

@hugovk hugovk added Installation Usually a problem with … Question labels Mar 30, 2020
@CovertError
Copy link
Author

setting text direction or font features is not supported without libraqm.

https://pillow.readthedocs.io/en/stable/installation.html

okay I have installed the libraqm and ran the test on there it worked well now the problem I'm still getting this error
KeyError: 'setting text direction, language or font features is not supported without libraqm'
I have even ran this code I found in the docs

pip3.6 install --upgrade Pillow

Requirement already up-to-date: Pillow in /usr/local/lib/python3.6/dist-packages (7.0.0)

@CovertError
Copy link
Author

I have installed libraqm in /usr/bin/lib/libraqm

@CovertError CovertError reopened this Mar 30, 2020
@radarhere
Copy link
Member

After installing libraqm, did you uninstall and then re-install Pillow?

@CovertError
Copy link
Author

After installing libraqm, did you uninstall and then re-install Pillow?

yea I have tried that too

@radarhere
Copy link
Member

When you say that you 'ran the test on there', are you referring to a specific test, or do you just mean this code that you're trying to execute?

I presume that the following code won't print True.

from PIL import features
print(features.check_feature('raqm'))

@CovertError
Copy link
Author

No that comes back with False I have ran the test on libraqm run/usr/lib/libraqm/tests/runtest.py

@radarhere
Copy link
Member

If you're saying that raqm.h is at /usr/bin/lib/raqm.h, then would you mind uninstalling Pillow, and then running this command, so that Pillow is looking there when it installs?

pip3.6 install --upgrade Pillow --global-option="build_ext" --global-option="-I/usr/bin/lib"

@CovertError
Copy link
Author

so I did search for that file and I only found it in those locations is okay does that mean i should be changing this --global-option="-I/usr/bin/lib" to --global-option="-I/usr/local/include/" or --global-option="-I/usr/lib/libraqm/src/"
/usr/lib/libraqm/src/raqm.h
/usr/local/include/raqm.h

@radarhere
Copy link
Member

I would try pip3.6 install --upgrade Pillow --global-option="build_ext" --global-option="-I/usr/local/include/", but if that doesn't resolve the problem, you're welcome to try the other. It's just telling Pillow to look for headers in that directory.

@CovertError
Copy link
Author

I have tried all three and ran the script again but still doesn't work I just keep getting this

/usr/local/lib/python3.6/dist-packages/pip/_internal/commands/install.py:244: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
  cmdoptions.check_install_build_global(options)
Requirement already up-to-date: Pillow in /usr/local/lib/python3.6/dist-packages (7.0.0)

@CovertError
Copy link
Author

is it possible that I have installed libraqm in the wrong location? I have installed it in /usr/lib/libraqm/

@CovertError
Copy link
Author

okay so I took a different approach by first scrapping ubuntu 16 and getting 18 then installing pip and all the other dependencies I needed including pillow then I cloned the Pilow repo and I first install all the packages needed I have noted it below ran the install raqm bash script in the depends folder

apt-get -y \
    install sudo xvfb \
    git wget python3-numpy python3-scipy netpbm \
    ghostscript libffi-dev libjpeg-turbo-progs \
    python3-setuptools \
    python3-dev cmake  \
    libtiff5-dev libjpeg8-dev libopenjp2-7-dev zlib1g-dev \
    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev \
    python3-tk \
    libharfbuzz-dev libfribidi-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Installation Usually a problem with … Question
Projects
None yet
Development

No branches or pull requests

3 participants