Changing to a custom font config.toml [[theme.fontFaces]] v1.45

version 1.45
The theme.fontsFaces documentation in the config.toml seems to be out of sync with the v1.45 code.

An array of fonts to use in your app. Each font in the array is a table

(dictionary) with the following three attributes: font, url, weight,

and style. To host a font with your app, enable static file serving

with server.enableStaticServing=true. You can define multiple

[[theme.fontFaces]] tables.

For example, each font is defined in a [[theme.fontFaces]] table as

follows:

[[theme.fontFaces]]

font = “font_name”

url = “app/static/font_file.woff”

weight = 400

style = “normal”

fontFaces =

"font = " should be "family = "

so declarations should look like this

[[theme.fontFaces]]
family = “Roboto”
url = “https://fonts.gstatic.com/s/roboto/v47/KFOMCnqEu92Fr1ME7kSn66aGLdTylUAMQXC89YmC2DPNWubEbVmUiAo.woff2
weight = 400
style = “normal”
[[theme.fontFaces]]
family = “Roboto Condensed”
url = “https://fonts.gstatic.com/s/robotocondensed/v27/ieVj2ZhZI2eCN5jzbjEETS9weq8-19eLDwM9.woff2
weight = 900
style = “italic”
[[theme.fontFaces]]
family = “Roboto Condensed”
url = “https://fonts.gstatic.com/s/robotocondensed/v27/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7DQ.woff2
weight = 900
style = “normal”

you can specify the font you want to use for the whole app in the config.toml
[theme]
font = “Roboto”

the sidebar has its own config override in [theme.sidebar],
but doesn’t change the font on st.navigation
works for st.sidebar.caption (didn’t test other st.sidebar elements)
The work around for this is to create custom CSS for the class assigned to to either
the div surrounding the unordered list that surrounds navigation or the unordered list that is navigation. But this might break in future updates if the class changes.
Or it could be fixed later to not require the custom CSS.

Alternatively you can set an environment variable to change all streamlit apps on a system
STREAMLIT_THEME_FONT=“Roboto”
but this seemed to be a nuclear approach to the problem.
theme.fontFaces settings have to be in the config.toml with this option

other notes for those new to streamlit (like me) and haven’t had a reason or time to
review all the documentation
I had trouble self hosting the fonts from my directory static/fonts/
to fix this, I had to literally prepend “app/” to the path
so the url for self hosted files for my fonts is “app/static/fonts/”
check the documentation for other limitations on files hosted in static/