-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
The weight property in theme.fontFaces passes to the font-weight CSS @font-face descriptor. This is parsed correctly if the weight is an integer or an int-like string. However, if a range of weights is passed (like "400 600") the font is not correctly interpreted and it doesn't load to the front end.
Reproducible Code Example
import streamlit as st
st.sidebar.header("fg **fg** _fg_ ***fg*** `fg`")
st.sidebar.subheader("fg **fg** _fg_ ***fg*** `fg`")
st.sidebar.write("fg **fg** _fg_ ***fg*** `fg`")
st.sidebar.code("fg **fg** _fg_ ***fg*** `fg` #And a code comment")
st.header("fg **fg** _fg_ ***fg*** `fg`")
st.subheader("fg **fg** _fg_ ***fg*** `fg`")
st.write("fg **fg** _fg_ ***fg*** `fg`")
st.code("fg **fg** _fg_ ***fg*** `fg` #And a code comment")Steps To Reproduce
Get Noto font files form Google:
https://fonts.google.com/specimen/Noto+Sans
https://fonts.google.com/specimen/Noto+Sans+Mono
Consider the following configuration (with the appropriate font files saved in the static hosting directory.
[server]
enableStaticServing = true
[[theme.fontFaces]]
family="noto-sans"
url="app/static/NotoSans-Italic-VariableFont_wdth,wght.ttf"
style="italic"
[[theme.fontFaces]]
family="noto-sans"
url="app/static/NotoSans-VariableFont_wdth,wght.ttf"
style="normal"
weight=800
[[theme.fontFaces]]
family="noto-mono"
url="app/static/NotoSansMono-VariableFont_wdth,wght.ttf"
style="normal"
[theme]
font="noto-sans"
codeFont="noto-mono"
The makes the non-italic font all have weight 800.
If the weight line is changed to:
weight="400"
...then all non-italic font has normal weight.
However, if the weight line is changed to:
weight="400 800"
...the non-italic font doesn't load and everything uses the italic font instead (as the closest available font).
Expected Behavior
No response
Current Behavior
No response
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: v1.44.2.dev20250421
- Python version: 3.11
- Operating System:
- Browser:
Additional Information
No response