Comments (4)
I can't seem to reproduce it, maybe the font file you're using is not properly configured, have you tried using a TrueType® (.ttf) file?
import arabic_reshaper
import os
from PIL import Image, ImageDraw, ImageFont
from bidi.algorithm import get_display
directory = os.path.abspath(os.path.dirname(__file__))
def f(p): return os.path.join(directory, p)
text_to_be_reshaped = 'امتحان الرياضيات النهائي'
reshaper = arabic_reshaper.ArabicReshaper({
'use_unshaped_instead_of_isolated': True
})
reshaped_text = reshaper.reshape(text_to_be_reshaped)
bidi_text = get_display(reshaped_text)
font = ImageFont.truetype(f('arabic-typesetting.ttf'), 120)
image = Image.new('RGBA', (800, 600), (255, 255, 255, 255))
image_draw = ImageDraw.Draw(image)
image_draw.text((10, 10), bidi_text, fill=(0, 0, 0, 255), font=font)
image.save(f('text-manual-config.png'))
config_from_font = arabic_reshaper.config_for_true_type_font(
f('arabic-typesetting.ttf'))
reshaper = arabic_reshaper.ArabicReshaper(config_from_font)
reshaped_text = reshaper.reshape(text_to_be_reshaped)
bidi_text = get_display(reshaped_text)
image_draw.rectangle([0, 0, 800, 600], fill=(255, 255, 255, 255))
image_draw.text((10, 10), bidi_text, fill=(0, 0, 0, 255), font=font)
image.save(f('text-auto-config.png'))
The code is using my latest release 2.1.0
which has a new method to read a .ttf
file and configure the reshaper accordingly. See this new section in the README for more info.
from python-arabic-reshaper.
Can you show me how you're using the config mentioned? I suspect it's not being used or utilised correctly.
This image show the text you provided while enabling use_unshaped_instead_of_isolated
from python-arabic-reshaper.
here is a snippet of how i used the "use_unshaped_instead_of_isolated" option and i wish i'm wrong at using it.
and this is the result of me code :
from python-arabic-reshaper.
@mpcabd i did upgrade the library and tried your code and amazingly solved my problems and worked smoothly, i'm very grateful, thanks.
from python-arabic-reshaper.
Related Issues (20)
- Letter ڵ is not reshaped HOT 1
- dropping diacritics? HOT 1
- Arabic text reversed with connected letters not reshaped correctly HOT 2
- ironpython error
- Gaps between some characters HOT 1
- why the tashkeel is shifted like that? the tashkeel have width between charachters. is that reshaper problem or rendering problem and how to treat that issue? HOT 2
- Unreshape (reshaping back to original text) HOT 2
- AttributeError: 'ImageFont' object has no attribute 'getmask2' HOT 1
- Unnecessary setuptools requirement HOT 2
- a variation of some letters is not added HOT 1
- Yank 2.1.3 because of invalid fonttools version constraint HOT 1
- Problem with non-overlapping matches of ligature pattern in string when ligature is skipped due to its form mismatch
- Security vulnerability on the "future" dependency HOT 3
- Font support
- Arabic text is revering lines in reportlab HOT 1
- Reshape Arabic letter located inside table
- pip install arabic-teshaper[with-fonttools] HOT 1
- TypeError: '>' not supported between instances of 'str' and 'int' HOT 2
- font reem kufi HOT 1
- Issue with Diacritics/Harakat positions and placement and tested on 6 fonts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-arabic-reshaper.