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

Figure out what ligatures to use and in what order in certain fonts #52

Open
ahmed4end opened this issue Aug 21, 2020 · 3 comments
Open

Comments

@ahmed4end
Copy link

ahmed4end commented Aug 21, 2020

the image will explain what i mean:
example
highlighted:
image
the issue continues with some other certain letters connect to each other this way.

the snippet code i used:


from PIL import Image , ImageDraw , ImageFont  
from bidi.algorithm import get_display
import arabic_reshaper
import os


txt = "سيمبا"
fnt_path = os.path.join(os.getcwd()+ "/ar.ttf") #Arabic typesetting font.
fnt = ImageFont.truetype(fnt_path , 200)

reshaper = arabic_reshaper.ArabicReshaper(
    arabic_reshaper.config_for_true_type_font(
        fnt_path,
        arabic_reshaper.ENABLE_ALL_LIGATURES
    )
)

reshaped_text = reshaper.reshape(txt)
bidi_text = get_display(reshaped_text)
image = Image.new(mode = "RGBA" , size = (300, 200) , color="white")
draw = ImageDraw.Draw(image)
draw.text( (0, 0), text=bidi_text, fill="black", font = fnt)
image.save("example.png")
os.startfile("example.png")

@mpcabd
Copy link
Owner

mpcabd commented Sep 3, 2020

I believe this has to do with the font having multiple ligatures that should be used in proper order otherwise you get this result.

The proper way of rendering "سيمبا" should be like this
image

I think I have to learn more about ligatures ordering in font files, and adapt the reshaper to respect that.

Thanks for reporting, I'll look into it as the time allows.

@mpcabd mpcabd changed the title some letters aren't connect properly in Arabic typesetting font. Figure out what ligatures to use and in what order in certain fonts Sep 3, 2020
@ahmed4end
Copy link
Author

is there any updates ?
wojak mis

@mpcabd
Copy link
Owner

mpcabd commented Jul 13, 2021

Sorry Ahmed, no update, I haven't had any time to look into it, and honestly, the issue slipped through my mind. If you have any pointers do let me know, my personal time is so tight now with WFH and the kids.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants