From 0f69d69efee234f8cf86e4f6ad7cce7be54bcabe Mon Sep 17 00:00:00 2001 From: Br1an67 <932039080@qq.com> Date: Sun, 1 Mar 2026 14:19:13 +0800 Subject: [PATCH] fix: treat empty custom_fonts array as intent to remove default fonts When custom_fonts is set to [] in theme.json, the user intends to manage fonts themselves (e.g., via custom_css). Previously, empty array was falsy in Python so the default Inter Google Font link was always preserved. Now check for key presence instead of truthiness, and use 'is not None' for the replacement check so an empty string properly clears the default font tags. Fixes #2804 --- backend/chainlit/server.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/chainlit/server.py b/backend/chainlit/server.py index f9393e5e3b..b6ff5ce814 100644 --- a/backend/chainlit/server.py +++ b/backend/chainlit/server.py @@ -410,10 +410,10 @@ def get_html_template(root_path): js += f"""""" font = None - if custom_theme and custom_theme.get("custom_fonts"): + if custom_theme and "custom_fonts" in custom_theme: font = "\n".join( - f"""""" - for font in custom_theme.get("custom_fonts") + f"""""" + for f in custom_theme["custom_fonts"] ) index_html_file_path = os.path.join(build_dir, "index.html") @@ -425,7 +425,7 @@ def get_html_template(root_path): content = content.replace(JS_PLACEHOLDER, js) if css: content = content.replace(CSS_PLACEHOLDER, css) - if font: + if font is not None: content = replace_between_tags( content, "", "", font )