GitHub user mistercrunch edited a comment on the discussion: Recommended approach to add custom fonts with the new theming system and frontend structure
I asked Claude Code to analyze this, here's what it came up with (after going nuts on SUPER complex solutions...) --- # Simple Runtime Font Loading for Superset You're exactly right! The solution is quite straightforward: ## Implementation 1. **Add font config to `superset_config.py`**: ```python CUSTOM_FONT_URLS = [ "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap", "https://fonts.googleapis.com/css2?family=Roboto+Mono&display=swap" ] # Update CSP to allow these domains TALISMAN_CONFIG = { "content_security_policy": { "font-src": ["'self'", "https://fonts.googleapis.com", "https://fonts.gstatic.com"], "style-src": ["'self'", "'unsafe-inline'", "https://fonts.googleapis.com"], } } ``` 2. **Modify the Jinja base template** (`superset/templates/superset/spa.html`): ```html {% if config.CUSTOM_FONT_URLS %} {% for font_url in config.CUSTOM_FONT_URLS %} <link rel="stylesheet" href="{{ font_url }}"> {% endfor %} {% endif %} ``` 3. **Use the fonts normally** in theme config or CSS: ```json { "token": { "fontFamily": "Inter, -apple-system, BlinkMacSystemFont, sans-serif" } } ``` ## How It Works - Config defines font URLs - Jinja template injects `<link>` tags at runtime - Browser loads fonts from CDN - React/Ant Design components can reference them by name - No build required! This gives Docker users custom fonts through simple configuration, while build users can still bundle fonts the traditional way. GitHub link: https://github.com/apache/superset/discussions/34397#discussioncomment-13939653 ---- This is an automatically sent email for notifications@superset.apache.org. To unsubscribe, please send an email to: notifications-unsubscr...@superset.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org