Local google fonts
by Miguel Martinez Lopez https://github.com/holasoftware/odoo_local_google_fontsAvailability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 286 |
Technical Name |
local_google_fonts |
License | See License tab |
Website | https://github.com/holasoftware/odoo_local_google_fonts |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 286 |
Technical Name |
local_google_fonts |
License | See License tab |
Website | https://github.com/holasoftware/odoo_local_google_fonts |
Local google fonts
Host google fonts and serve them from your own odoo instance.
Rationale
Serving cached google fonts improves privacy. For European citizens, hosting the google fonts locally doesn't require user consent for being GDPR compliant.
It also allows local development without internet connection. Some odoo modules like the website module requires to load some google fonts by default to function properly, otherwise it shows an error popup because it couldn't load the imported stylesheets containing the google fonts declarations.
At the same time, not having the computer connected to the Internet has some advantages such as being less exposed to cybersecurity risks and also saving internet data.
How does it work?
After installation, the application starts downloading the default google fonts used in odoo and defined here: addons/website/static/src/scss/primary_variables.scss
It also deletes some attachments in the database like stylesheet bundles containing URL's to stylesheet with declarations for google fonts. The next time the bundle is regenerated, the content's bundle will have the links to google fonts pointing to local resources. The font files referenced in the google font stylesheet are also extracted and downloaded and the links to external resources are replaced to links pointing to the cached ones. The download process is executed in a python thread.
The module also adds a button in a new section called Local Google Fonts
in the General settings only available for the admin. Clicking the button, the module runs the same process as when it was installed. It helps to download again google fonts not yet cached (because there was no internet connection during installation and it was not possible to download the fonts for example) or deleted manually and to regenerate the attachments containing google fonts with all the replacement links.
Environment variables
These are the environment variables that can be used for configuration:
ODOO_LOCAL_GOOGLE_FONTS_CACHE_DIR_PATH:
Path to directory used for storing locally the data for this module (google font stylesheets and font files). By default, it's the directorygoogle_fonts
in odoo data directory. (data_dir
config parameter).ODOO_GOOGLE_FONT_STYLESHEETS_PATH:
Path to the directory for storing the google font stylesheets. By default, it's the same value thanLOCAL_GOOGLE_FONTS_CACHE_DIR_PATH
.ODOO_GOOGLE_FONTS_PATH:
Path to the directory for storing the font files. By default, it's the subdirectorygstatic
inODOO_LOCAL_GOOGLE_FONTS_CACHE_DIR_PATH
.ODOO_DONT_DOWNLOAD_GOOGLE_FONTS_ON_MODULE_INSTALL:
If the value of this environment variable is1
, the module doesn't host the google fonts when installed. It will be required to install manually in the settings section.
Copyright (c) 2025 Miguel Martinez Lopez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module