Local Google Fonts — Self-Hosted GDPR Fonts (dffontmanager)
Installation, local Google Fonts import, subsetting, preloading, replacement rules without touching the theme, and GDPR verification.
DF Font Manager hosts your Google Fonts directly on your PrestaShop server: your visitors never contact Google’s servers again (GDPR compliance), and you change your store’s typography through simple CSS rules, without modifying a single theme file. The module handles importing from the Google Fonts catalog, automatic per-alphabet subsetting, critical file preloading, the font-display strategy and custom font uploads.
This documentation covers version 1.0.0 of the module, compatible with PrestaShop 8.0.0 to 9.x. No class overrides, no Composer dependency, vanilla JS without jQuery.
Installation
- In your PrestaShop back office, open Modules > Module Manager.
- Click Upload a module and drop the
dffontmanager.zipfile. - A Font Manager tab appears under the Design menu: everything happens there (the module’s Configure button redirects there too).
The module registers three hooks (displayHeader, actionFrontControllerSetMedia, actionOutputHTMLBefore) and creates two tables: installed fonts and replacement rules. Font files are stored in modules/dffontmanager/views/fonts/ and the generated stylesheet in modules/dffontmanager/views/css/generated/ — make sure these folders are writable.
General settings
- Enable self-hosted fonts — master switch: loads the generated stylesheet and preload tags on the front office.
- Remove external Google Fonts calls (GDPR) — cleans the rendered HTML of the store: every link tag pointing to
fonts.googleapis.comorfonts.gstatic.com(stylesheets, preconnects, preloads) as well as matching inline@importstatements are stripped before the page is sent. This is the option that guarantees no request ever reaches Google, even if your theme or another module injects one. - font-display strategy — applied to every generated
@font-facedeclaration.swap(default) keeps text visible while fonts load;block,fallback,optionalandautoare available for specific needs.
Recommendation: keep swap. It is the best Core Web Vitals trade-off — no invisible text (FOIT), no LCP penalty.
Importing a Google Font
- In the Import a Google Font panel, type at least two characters: autocomplete browses the full Google Fonts catalog, cached on your server for 7 days (refresh button next to the field).
- Select a family: the available variants (weights 100 to 900, normal and italic) and alphabets appear. By default, weights 400 and 700 plus the latin and latin-ext subsets are pre-checked.
- Click Import locally.
The module then queries Google’s CSS API, downloads the official woff2 files matching your selection (one file per alphabet per variant), verifies their binary signature, stores them in views/fonts/family-name/ and regenerates the stylesheet. The page reloads with the family visible in the installed fonts table, including its total disk footprint.
The download happens once, server to server, at import time. Your visitors are never part of this request: on the front end, everything is served from your own domain.
Automatic subsetting
Google splits each font into per-alphabet files (latin, latin-ext, cyrillic, greek, vietnamese, etc.). The module only downloads the checked alphabets and keeps each file’s original unicode-range in the @font-face declaration. Browsers therefore only request the character ranges actually displayed on the page: a typical Western European store serves 20 to 90 KB of fonts instead of several hundred.
Only check the alphabets of your actual audience. You can always re-import the family later with additional subsets: the import cleanly replaces existing files while preserving your settings (preload, active state) and your rules.
Re-importing or modifying a family
To add a weight or an alphabet to an already installed family, simply run the import again with the new selection: the family’s old files are replaced, and the replacement rules using it remain intact.
Uploading a custom font
The Custom font upload panel accepts woff2 (recommended), woff, ttf and otf formats. Provide the family name, weight and style, then send the file — one file per weight/style combination, automatically merged under the same family. Each file is validated by its binary signature (not its extension), then included in the generated stylesheet and available in the rules exactly like a Google font.
Make sure your license allows self-hosted web usage, especially for commercial fonts purchased from foundries.
Managing installed fonts
The installed fonts table shows, for each family: the source (google or custom), the variants, the subsets, the file count and disk footprint, plus two toggles:
- Active — includes or excludes the family from the generated stylesheet (files remain on disk).
- Preload — see the dedicated section below.
The delete button removes the family, its files on disk and every rule that uses it, then rebuilds the stylesheet.
Replacement rules
This is where you apply your fonts without touching the theme. Each rule maps a CSS selector to an installed font, with four options:
- Weight — forces a
font-weight(leave empty to inherit from the theme); - Style — normal or italic (empty to inherit);
- Fallback stack — generic families displayed until the font is loaded:
sans-serif,serif,monospaceorsystem-ui, sans-serif; - !important — checked by default, guarantees the rule wins over theme styles regardless of their specificity.
Common selector examples:
body— the whole store;h1, h2, h3, h4, h5, h6— all headings;.btn, button— buttons;.product-title, .h3.product-title— product titles in listings (adapt to your theme).
Typical two-rule setup: body to your font at 400 with a sans-serif stack, then h1, h2, h3, h4 to the same family at 700. Inspect your theme with the browser developer tools to identify finer-grained selectors.
Every rule addition or deletion rebuilds the stylesheet immediately. The stylesheet loads after the theme CSS: even without !important, your rules win the cascade at equal specificity.
Preloading — best practices
A family’s Preload toggle emits, at the top of the page, a link rel=preload as=font crossorigin tag for its critical file, picked automatically: woff2, normal style, latin alphabet, weight closest to 400. The browser downloads the font in parallel with the CSS, before even discovering its usage — the final text renders sooner.
Only preload one or two families actually used above the fold. Each preload consumes high-priority bandwidth: overusing it degrades LCP instead of improving it.
Technical operation
- The generated stylesheet
fonts-v{timestamp}.csscontains every@font-facedeclaration (withfont-displayandunicode-range) followed by the replacement rules. Each rebuild produces a new filename (automatic cache-busting) and purges older versions. - It is registered through
actionFrontControllerSetMediawith a priority that places it after the theme CSS. - Preload tags are emitted by
displayHeader; the critical file list is cached in configuration — no extra SQL query per front-office page. - External call removal runs in
actionOutputHTMLBefore, on the final HTML, after the Smarty cache. - The Rebuild CSS button forces a full regeneration — useful after a manual intervention on the files or a backup restore.
Verifying GDPR compliance
- Open your store in a private browsing window.
- Open the developer tools (F12), Network tab, and filter on
fonts.g. - Reload the page: the list must stay empty. If a request to
fonts.googleapis.comorfonts.gstatic.comappears, enable the external call removal option and clear the PrestaShop cache.
Test the homepage, a product page and the checkout: some payment modules or third-party widgets load their own fonts inside iframes, out of reach of the HTML cleaning (their own consent banners then apply).
Multistore
Imported fonts and replacement rules are shared across all stores of the same installation. The activation toggles and the external call removal option follow the standard PrestaShop configuration context.
Troubleshooting
- The font does not show on the front end — check in order: the master switch is on, the family is active, a replacement rule exists for the right selector, and the PrestaShop cache is cleared (Advanced Parameters > Performance). Then inspect the element in the browser: if the rule appears struck through, a more specific theme style overrides it — check
!importanton the rule. - Import fails with a network error — your server must be able to reach
fonts.googleapis.comandfonts.gstatic.comoutbound (cURL or allow_url_fopen). On a server behind a strict firewall, ask your host to open these two domains. - Autocomplete suggests nothing — the catalog could not be downloaded (network). Click the catalog refresh button, or type the exact family name and press Enter: direct import works without the catalog.
- Write error on import or rebuild — grant the web server write permissions on
modules/dffontmanager/views/fonts/andmodules/dffontmanager/views/css/generated/. - Google calls persist despite the removal option — identify the source in the Network tab (initiator column). If it comes from a third-party iframe (payment, reviews, maps), the HTML cleaning cannot reach it: that third-party service’s own consent governs.
Updating the module
Font files and the generated stylesheet live inside the module folder. An update performed by overwriting the folder modules/dffontmanager/ deletes the imported fonts. After such an update, open the manager and re-import your families (two clicks per family: your settings and rules, stored in the database, are preserved). An update through the standard Module Manager triggers the same behavior: plan the re-import right after.
Uninstallation
Uninstalling removes both tables, the configuration keys, the downloaded font files and the generated stylesheet. Your store instantly returns to its theme’s original fonts — no leftovers.