This question has been flagged
2 Replies
5123 Views

Hi, i want to use New font for the Qweb report,am tried many ways but nothing working out..How to use new fonts  ?is it possible ?

Avatar
Discard
Best Answer

It's possible. If you want to use some special fonts you should have the font file included in a odoo module directory. On the desired report you should add css style inside the <div class="page"> element.

<style type="text/css">
            /* Declare fonts */
            @font-face {
                font-family: tetria;
                src: url(/odoo_module_name/static/font/TetriaLTComBlack.ttf);
            }
</style>
...
<p style="font-family: tetria;">Hello, World!</p>
Avatar
Discard

In the CSS, you have to replace odoo_module_name/static/font/TetriaLTComBlack.ttf

by the actual folder in which you place your font file and give the name of your font file instead of TetriaLTComBlack.ttf. It's a relative path that must match an existing file otherwise it won't work.

Are you viewing the report in PDF or HTML? Still not working?

Author

css

/* Declare fonts */

@font-face {

font-family: corsiva;

src: url(/hotel_reservation/static/src/font/monotype-corsiva-5947e2c660f1f.TTF);

}

report.xml

<p style="font-family: corsiva;">Hello, World!</p>

any other place need to declared ?

Try to put the style in a separate template inheriting from report.layout :

<!-- Override general report layout to add custom css -->

<template id="layout" inherit_id="report.layout">

<!-- Add report style -->

<xpath expr="//head" position="inside">

<style type="text/css">

/* Declare fonts */

@font-face {

font-family: tetria;

src: url(/hotel_reservation/static/src/font/monotype-corsiva-5947e2c660f1f.TTF);

}

</style>

</xpath>

</template>

Author

error while upgrading module

File "src/lxml/lxml.etree.pyx", line 3501, in lxml.etree._Validator.assert_ (src/lxml/lxml.etree.c:194922)

AssertionError: Document does not comply with schema