As example we use example.ttf as the truetype font we want to install on our system. And use in an RML report within OpenERP.
Installing the font on your system
First you need to install your font on the server. If you use Ubuntu you can use the following commands to do this:
make a directory in the /usr/share/fonts/truetype folder for your custom fonts
cd /usr/share/fonts/truetype/ mkdir example
Change to the new folder and copy your file to this location
cd example cp example.ttf ./
update the font cache of your system
Enable the custom fonts
Open the customfonts.py file of your OpenERP Server (if you followed my installation of openerp from launchpad the location will be: /opt/openerp/server/openerp/report/render/rml2pdf/customfonts.py.
Add a new line to the CustomTTFonts list:
The ‘all’ part of the tuple has different options. You may also use ‘normal’ , ‘bold’, ‘italic’, ‘bolditalic’.
Using the font in a RML based report
You can now use the custom font in your RML reports. Just use the name you have chosen. The paraStyle will show someting like:
<paraStyle name="default_8" fontName="example" fontSize="8.0" leading="10" alignment="LEFT" spaceBefore="0.0" spaceAfter="0.0"/>
[…] How to add custom fonts in RML: http://www.schenkels.nl/2013/02/using-your-own-font-with-openerp-v7-rml-reportlab-ubuntu-12-04/ 2. OpenOffice Report Designer: An extension to the RML Reportlab option. Use OpenOffice / […]
Sorry to bother again.
Any idea why the main part of the f.ex. offer when printed still comes with the old font (Helvetica)?
can I also use *.otf files with the rml2pdf renderer?
I used your instructions with SourceSansPro-Regular.otf files but it’s unfortunately not working…
Never tried a otf file but I casn try for you. Please give some time. I’ll test it. Could you provide me with the files?
that would be awesome.
got the files from here:
With *.ttf file from here it’s working like a charm:
So I assume you also won’thave any luck with *.otf file format… 🙁
Don’tbother if you don’twish to invesitgate ;).
I really like to use my time for v8 so I’ll stop investigating otf files..
Thnx for the information.
Als je het weet is het makkelijk 😉