This is an Openerp patch to fix issues occured when dealing with Arabic and other RTL languages (Arabic, Hebrew, Ordo, Farsi, etc).
- copy file arabic_reshaper.py into:
<INSTALL_DIR>\Openerp Server 6.1\Server\server
, where<INSTALL_DIR>
is the location where you installed Openerp Server (e.g. C:\Program Files). - copy folder bidi into the same Location you put arabic_reshaper.py to it:
<INSTALL_DIR>\Openerp Server 6.1\Server\server
- copy file textobject.py into:
<INSTALL_DIR>\Openerp Server 6.1\Server\server\reportlab\pdfgen
, you may want to backup the old textobject.py before replace it with this version.
-
create a new directory name "fonts" inside:
<INSTALL_DIR>\Openerp Server 6.1\Server\server\
-
open a file called openerp-server.conf with your preferred text editor (e.g. notepad), the openerp-server.conf live in:
<INSTALL_DIR>\Openerp Server 6.1\Server\server\openerp-server.conf
-
at the end of the file, add the following line:
fonts_search_path = <INSTALL_DIR>\Openerp Server 6.1\Server\server\fonts
NOTE: Dont forget to replace <INSTALL_DIR> with the absolute path of OpenERP server installation (e.g. C:\Program Files).
-
go to DjaVu Fonts Site http://dejavu-fonts.org/wiki/Download and download a file called dejavu-fonts-ttf-2.33.tar.bz2, here is another mirror for it.
-
extract dejavu-fonts-ttf-2.33.tar.bz2 and copy the contents of "ttf" folder into your fonts directory:
<INSTALL_DIR>\Openerp Server 6.1\Server\server\fonts
-
Now, restart openerp server:
- Control Panel => Administrative Tools => Services - find a service called openerp server - restart it.
-
try to print some reports that contains arabic characters. enjoy :)
more information can be found on our blog: http://goure-it.blogspot.com.
Because There are several ways to install OpenERP on Linux, Files Locations are not unique. so, this instructions assume that you install OpenERP using the popular method, Through `apt-get` on ubuntu platform.
Copy the file "textobject.py" into:
/usr/lib/python2.6/dist-packages/reportlab/pdfgen/textobject.py
make sure you backup old"textobject.py"
before you replace it.Check to ensure if the link file:
/usr/share/pyshared/reportlab/pdfgen/textobject.py
pointing correctly to the new"textobject.py"
file.Copy
"arabic_reshaper.py"
file, and"bidi"
directory into:/usr/lib/python2.6/dist-packages/
Create a folder called
"fonts"
in a location that is accessable by openerp server. (e.g./usr/share/pyshared/fonts
).go to DejaVu Fonts Site and download a file called dejavu-fonts-ttf-2.33.tar.bz2 [here] [id] is another mirror for it: [id]: http://ie.archive.ubuntu.com/ftp.frugalware.org/pub/frugalware/frugalware-current/source/x11/dejavu-ttf/dejavu-fonts-ttf-2.33.tar.bz2 "Ubuntu Mirror"
extract dejavu-fonts-ttf-2.33.tar.bz2 copy the contents of a folder called ttf and paste them into "fonts" directory you created on step 4.
use linux searching tool, search for a file called openerp-server.conf, open it with a text editor (e.g. gedit), at the end of it, paste the following line:
**fonts_search_path = /usr/share/pyshared/fonts**
where
/usr/share/pyshared/fonts
is your new fonts directory you created on step 4.
- restart openerp server,
sudo service openerp restart
go and try printing some reports with arabic characters.as you might noticed, using dejavu fonts are so uguly on arabic characters. there is a set of awesome arabic fonts (open source) created by arabeyes: Khotot go and download them.
Keep in mind that openerp report engine depends on 4 standard PDF fonts:
- Helvetica
- Times
- Times-Roman
- Courier
all 4 fonts unable to render most languages correctly. as a result, openerp report enginge will automagically pickup DjaVu Fonts Set, when you point to them.
That's why you set
fonts_search_path = /your/custom/fonts
option in openerp-server.conf file before. here is the mapping that openerp report engine does:
Font Name Font Type DjaVu Equivelant Helvetica normal DejaVuSans.ttf Helvetica bold DejaVuSans-Bold.ttf Helvetica italic DejaVuSans-Oblique.ttf Helvetica bolditalic DejaVuSans-BoldOblique.ttf ---- ---- ---- Times normal LiberationSerif-Regular.ttf Times bold LiberationSerif-Bold.ttf Times italic LiberationSerif-Italic.ttf Times bolditalic LiberationSerif-BoldItalic.ttf ---- ---- ---- Times-Roman normal LiberationSerif-Regular.ttf Times-Roman bold LiberationSerif-Bold.ttf Times-Roman italic LiberationSerif-Italic.ttf Times-Roman bolditalic LiberationSerif-BoldItalic.ttf ---- ---- ---- Courier normal FreeMono.ttf Courier bold FreeMonoBold.ttf Courier italic FreeMonoOblique.ttf Courier bolditalic FreeMonoBoldOblique.ttf ---- ---- ---- So, for example. if you want to replace
Helvetica
with something else, (e.g.ae_AlMohanad.ttf
from arab eyes package), you can do it by renaming your font DejaVuSans.ttf and put it into your custom fonts directory.For More Information, go to our blog
Copyrights © Mohammed Barsi (dantario AT gmail DOT com).
Many Thanks go to Meir Kriheli and Abd Allah Diab for their unicode bidirection packages:
- python-bidi package created by Meir Kriheli http://github.com/mksoft/python-bidi "GNU Library or Lesser General Public License (LGPL)"
- arabic_reshaper.py created by Abd Allah Diab https://github.com/mpcabd/python-arabic-reshaper "GNU General Public License v3."