Skip to content

theme.json: custom_fonts: [] should remove default Inter Google Font #2804

@kaaloo

Description

@kaaloo

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:

  1. Wastes bandwidth
  2. Breaks in air-gapped / government network environments where Google domains may be blocked
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendPertains to the Python backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions