Description
When using theme.json with self-hosted fonts loaded via @font-face in custom_css, the default Inter font from Google Fonts is still loaded — there is no way to disable it.
The built index.html contains:
<!-- FONT START -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap" />
<!-- FONT END -->
In server.py, the replacement logic only triggers when custom_fonts is truthy:
if custom_theme and custom_theme.get("custom_fonts"):
font = "\n".join(...)
Setting custom_fonts: [] in theme.json is falsy in Python, so the default Inter <link> tags are never removed.
Use case
We are adopting the French Government Design System (DSFR) which requires the Marianne typeface, self-hosted from /public/dsfr/fonts/. We load it via @font-face in our custom_css and set --font-sans to 'Marianne', ... in theme.json variables.
The font works, but the browser still makes an unnecessary request to fonts.googleapis.com for Inter, which:
- Wastes bandwidth
- Breaks in air-gapped / government network environments where Google domains may be blocked
- Creates a privacy concern (sends user IPs to Google)
Expected behavior
When custom_fonts is present in theme.json — even as an empty array [] — the default Inter <link> tags between <!-- FONT START --> and <!-- FONT END --> should be removed, since the developer is signaling they manage fonts themselves.
Suggested fix
In server.py get_html_template(), change the condition from:
if custom_theme and custom_theme.get("custom_fonts"):
to:
if custom_theme and "custom_fonts" in custom_theme:
Then when custom_fonts is [], the font variable would be "", and replace_between_tags would effectively clear the Inter tags. When custom_fonts has URLs, they'd replace Inter as before. When custom_fonts is absent, the default Inter is preserved (backward-compatible).
Environment
- Chainlit version: 2.9.6
- OS: macOS
- Python: 3.13
👾 Generated with Letta Code
Description
When using
theme.jsonwith self-hosted fonts loaded via@font-faceincustom_css, the default Inter font from Google Fonts is still loaded — there is no way to disable it.The built
index.htmlcontains:In
server.py, the replacement logic only triggers whencustom_fontsis truthy:Setting
custom_fonts: []intheme.jsonis falsy in Python, so the default Inter<link>tags are never removed.Use case
We are adopting the French Government Design System (DSFR) which requires the Marianne typeface, self-hosted from
/public/dsfr/fonts/. We load it via@font-facein ourcustom_cssand set--font-sansto'Marianne', ...intheme.jsonvariables.The font works, but the browser still makes an unnecessary request to
fonts.googleapis.comfor Inter, which:Expected behavior
When
custom_fontsis present intheme.json— even as an empty array[]— the default Inter<link>tags between<!-- FONT START -->and<!-- FONT END -->should be removed, since the developer is signaling they manage fonts themselves.Suggested fix
In
server.pyget_html_template(), change the condition from:to:
Then when
custom_fontsis[], thefontvariable would be"", andreplace_between_tagswould effectively clear the Inter tags. Whencustom_fontshas URLs, they'd replace Inter as before. Whencustom_fontsis absent, the default Inter is preserved (backward-compatible).Environment
👾 Generated with Letta Code