Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
4 Antworten
22022 Ansichten

I want to add my custom font to website theme editor > options > font family.

That custom font isn't related to "Google Web Fonts" and it has its own folder and files.

I'm using Odoo 14 with default theme.

tnx.

Avatar
Verwerfen

@Misaghmi

Have you found any solution?

Beste Antwort

you need to follow these steps:

  1. Prepare your custom font files: Make sure you have the necessary font files in the proper formats (e.g., .woff, .woff2, .ttf, etc.) for your custom font. Place these font files in a directory within your Odoo module.

  2. Define the font in your Odoo module's assets: In your module, create a static assets directory (e.g., static/src/fonts) and place your custom font files in this directory. Also, create a CSS file (e.g., static/src/css/custom_fonts.css) to define the font face rules.

  3. Define the font face rules: In the custom_fonts.css file, define the @font-face rules for your custom font. For example:

@font-face {
font-family: 'YourCustomFontName';
src: url('/your_module_name/static/src/fonts/YourCustomFont-Regular.woff2') format('woff2'),
url('/your_module_name/static/src/fonts/YourCustomFont-Regular.woff') format('woff');
font-weight: normal;
font-style: normal;
}


Replace 'YourCustomFontName' with the actual name you want to use for your font, and adjust the paths in the url() statements to match the location of your font files within your module.

  1. include the font CSS file in the assets section:

"web.assets_frontend": [ "your_module_name/static/src/fonts/YourCustomFont-Regular.woff", "your_module_name/static/src/fonts/YourCustomFont-Regular.woff2", "your_module_name/static/src/css/custom_fonts.css" ], "web.assets_qweb": [ "your_module_name/static/src/fonts/YourCustomFont-Regular.woff", "your_module_name/static/src/fonts/YourCustomFont-Regular.woff2", "your_module_name/static/src/css/custom_fonts.css" ]

  1. Restart your Odoo server and update the module: After restarting the server, update your module to load the new assets.

  2. Customize the website theme: Go to the Odoo backend and navigate to Website > Configuration > Website Settings. In the "Options" tab, you should now see your custom font in the font family options. Select your custom font to apply it to the website theme.


Avatar
Verwerfen
Beste Antwort

Hello Mishaghmi,

You can give a path of your font folder in css.

.test {

        @font-face {

        font-family: 'myfont';

        src: url('/theme_test/static/src/fonts/230163575-DINNextLTArabic-Regular.eot');

        src: url('/theme_test/static/src/fonts/230163575-DINNextLTArabic-Regular.eot?#iefix') format('embedded-opentype'),

        url('/theme_test/static/src/fonts/230163575-DINNextLTArabic-Regular.woff') format('woff'),

        url('/theme_test/static/src/fonts/230163575-DINNextLTArabic-Regular.ttf') format('truetype'),

        url('/theme_test/static/src/fontss/230163575-DINNextLTArabic-Regular.svg#DIN Next LT Arabic') format('svg');

        font-weight: normal;

        font-style: normal;

        }

            li {

                font-family: 'myfont';

                }

}

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Verwerfen
Beste Antwort

Thanks für your solution Jainesh! Stupid Question, how do I access the odoo file system? I do not use odoo on premise, I use the cloud installation. Could you please briefly describe how I can access the files - i.e. how I can access the font folder in css? Thanks and br Horst

Avatar
Verwerfen
Beste Antwort

Hi,Please refer to this blog to understand how to add custom fonts to the theme.
https://www.cybrosys.com/blog/how-to-add-new-fonts-to-the-odoo-15-website

Even though it says about how to add custom fonts in version 15, 14 also follows the same steps.

Hope it helps

Avatar
Verwerfen

How about fopr odoo 16? The same?

Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Mai 24
3144
1
Apr. 24
26742
1
Nov. 22
2600
2
Juli 22
3296
2
Juli 22
3117