Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Some languages (e.g. Chinese) needs different charset not supported by classic fonts (or you just want Comic Sans MS in your reports). Good news, you can use custom TTF fonts. For Chinese, we make it easier for Sun-ExtA but you can use any TTF font,
The list of available fonts is hardcoded in CustomTTFontsvariable in openerp/report/render/rml2pdf/customfonts.py. If you want to add another font than DejaVu Sans, Liberation Serif, FreeMono or Sun-ExtA, you will need to modify the source file to add the font in the format:('family name', 'font name', 'ttf file name', 'mode')
- family name: the name of font interpreted by reportlab (e.g. check with FontForge Element > Font Info)
- font name: what should be put in your rml file. Family name can common between several fonts while font name should be unique (e.g. "DejaVu Sans" vs "DejaVu Sans Bold")
- file name: just the name of your ttf file, not the full patch
- mode: one between normal, italic, oblique, bold, bolditalic, bold italic, boldoblique, bold oblique or all
Careful: the font and file names are case sensitive !!!
To be discovered by odoo, your font should be in one of these folders
'/usr/share/fonts/truetype', '/usr/share/fonts/dejavu', '/usr/share/fonts/liberation', '/usr/share/fonts/truetype/*', '/usr/share/fonts/TTF/*', '/usr/share/fonts/TTF', 'c:/winnt/fonts', 'c:/windows/fonts', '~/Library/Fonts', '/Library/Fonts', '/Network/Library/Fonts', '/System/Library/Fonts',
- the search folders defined in reportlab library, variable TTFSearchPath (e.g.~/.fonts on linux, check /usr/lib/python2.7/site-packages/reportlab/rl_settings.py for full list)
When rendering a report, check your logs (debug mode helps) for warning or info message about fonts not found. Restarting your odoo server after installing a font may help.
To use your font on every report modify the RML Header of your company (Settings > Companies > Header/Footer) and change and locate the fontName="DejaVu Sans" or setFont name="DejaVu Sans" to replace by the font name you wish to use.
This will only modify global settings, if you have font specified inside the rml reports, you will also need to modify these one !
No more needed to modify python files ! Well actually no more need to do RML reports in v8 but still possible.
You still need to install the custom font in one of the searched folder (see above).
Go to Settings > Companies > Report Configuration and hit the reload fonts button to populate the many2one (by default empty). odoo will scan all the fonts installed on your system. Selecting one will modify the company headers to use it globally.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 12/19/14, 5:03 AM|
|Seen: 5049 times|
|Last updated: 3/10/16, 3:54 PM|