fix: treat empty custom_fonts array as intent to remove default fonts#2808
Open
Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Open
fix: treat empty custom_fonts array as intent to remove default fonts#2808Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Br1an67 wants to merge 1 commit intoChainlit:mainfrom
Conversation
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 Chainlit#2804
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When
custom_fontsis set to[]intheme.json, the user intends to manage fonts themselves (e.g., via@font-faceincustom_css). However, the default Inter Google Font<link>tags are still injected because[]is falsy in Python, so the conditioncustom_theme.get("custom_fonts")evaluates toFalse.This causes:
fonts.googleapis.comFix
"custom_fonts" in custom_theme) instead of truthinessif font is not Noneinstead ofif fontso an empty string properly clears the default font tags viareplace_between_tagsWhen
custom_fontsis:[]→ default Inter removed (user manages fonts)[{...}]→ custom fonts replace Inter (existing behavior)Fixes #2804
Summary by cubic
Stop injecting the default Inter font when theme.json sets custom_fonts to []. An empty array now removes the Inter links, reducing unwanted Google requests and supporting air-gapped environments. Fixes #2804.
Written for commit 0f69d69. Summary will update on new commits.