mpcabd / python-arabic-reshaper

Reconstruct Arabic sentences to be used in applications that don't support Arabic
MIT License
398 stars 80 forks source link

Missing Font #20

Closed Ashraf-Ali-aa closed 6 years ago

Ashraf-Ali-aa commented 6 years ago

@mpcabd Assalam Alaikum, thanks for a great tool, I was planning on converting this tool to Ruby but I have noticed that when I use KFGQPC Uthmanic Script HAFS font the letters are not get displayed, is there a way to fix this?

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import sys
from arabic_reshaper import ArabicReshaper
from bidi.algorithm import get_display
from PIL import Image, ImageFont, ImageDraw, ImageEnhance

# text_to_be_reshaped = 'اللغة العربية رائعة'
text_to_be_reshaped = "مَٰلِكِ يَوۡمِ ٱلدِّينِ"

configuration = {
    'delete_harakat': False,
    'delete_tatweel': False,
    'support_ligatures': True,
    'support_zwj': False,
    'shift_harakat_position': False,
    'use_unshaped_instead_of_isolated': False
}
reshaper = ArabicReshaper(configuration=configuration)

reshaped_text = reshaper.reshape(text_to_be_reshaped)

bidi_text = get_display(reshaped_text)

image = Image.new('RGBA', (500,500), "black")
image_draw = ImageDraw.Draw(image)
image_draw.text((10,10), bidi_text, fill=(255,255,255,128), font=ImageFont.truetype("/Users/user/Github/Personal/gq-tool/UthmanicHafs1 Ver09.otf", 50))
image.save("ImageDraw.png")

output:

imagedraw

Font: http://fonts.qurancomplex.gov.sa/?page_id=42

mpcabd commented 6 years ago

I tested the font on http://torinak.com/font/lsfont.html and it showed only the isolated characters, compared with Tajwal for example which shows all the forms. Either the font file on the site is broken, or they intended for the font to only replace the isolated characters, while relying on another font, a fallback one, to render the rest. There seems to be nothing to be done here in the reshaper itself, try a different font.