pyfribidi for windows 或任何其他比迪算法 [英] pyfribidi for windows or any other bidi algorithm

查看:35
本文介绍了pyfribidi for windows 或任何其他比迪算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 reportlab 生成报告,报告语言为阿拉伯语.但问题是 reportlab 不支持 BIDI(双向)显示,因为缺少 BIDI Algorithm 支持Python.经过大量的谷歌搜索后,我发现 Gnome Fribidi 有一个名为 PyFribidi.但它仅在 Linux 上编译和运行,我尝试使用 mingwin 在 Windows 上构建它,但编译失败,因为找不到很多 linux 库.

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.

我的问题是,python 中是否有任何 Unicode 双向算法实现,可以在 Windows 上运行?

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

谢谢.

推荐答案

Python BiDi 是一个很棒的 BiDi 算法实现,但它只支持双向(按原样)而不修复 contextual阿拉伯语脚本的形式,要解决上下文形式问题,您应该将 python-bidi 模块与名为 python-arabic-reshaper.

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.

示例:(来自 => http://mpcabd.igeex.biz/python-arabic-text-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)
#...

它完美地解决了我的问题,两个包都是纯 python 实现.

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

这篇关于pyfribidi for windows 或任何其他比迪算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆