Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
503 views
in Technique[技术] by (71.8m points)

python - pyfribidi for windows or any other bidi algorithm

I'm trying to generate a report using reportlab, and the report language is Arabic. but the problem is reportlab doesn't support BIDI (Bidirection) Display because of the lack BIDI Algorithm support in Python. after alot of googling I found that there is a wrapper around Gnome Fribidi called PyFribidi. but it compiled and runs only on Linux, I tried to build it on windows using mingwin but the compilation fails because a lot of linux libs not found.

My question is, is there any Unicode bi-direction algorithm implementation in python, that runs on windows?

thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Python BiDi is a great BiDi algorithm implementation, but it just support bi-direction (As Is) without fixing the contextual form of arabic script, to solve contextual form problem, you should use python-bidi module with an arabic reshaper library called python-arabic-reshaper.

example : (from => http://mpcabd.igeex.biz/python-arabic-text-reshaper/)

import arabic_reshaper
from bidi.algorithm import get_display

#...
reshaped_text = arabic_reshaper.reshape(u'????? ??????? ?????')
bidi_text = get_display(reshaped_text)
pass_arabic_text_to_render(bidi_text)
#...

it fixes my problem perfectly, and both packages are pure python implementation.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...