Alternative for google fonts

Summary

There is new regulation in Germany that bans the use of Google Fonts (even though they are open source). I need to find an alternative ASAP!

Link to news article

Steps to reproduce

CSS file
@import url(‘https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap’); ← I need a different link here that is not from Google!

html, body, [class*=“css”] {
font-family: ‘Roboto’, sans-serif;
font-size: 18px;
font-weight: 500;
color: #091747;
}

Is there a place where I can quickly find a font to use on my app that is not from Google? I cannot seem to find any at all.

Thanks in advance!

People already have fonts installed in their computers, you don’t need to find fonts for them.

What I am trying to do is get rid of my page getting notified as a page that uses Google fonts. Here is the website where the check can be performed. I have not used any font settings in my page at all, but apparently my page gets flagged, therefore I am now looking into those CSS files. For clarity, my page does not use such a style.css file yet, I am just investigating it to get rid of this issue.

We have the same problem. We use streamlit share to deploy our apps. Unfortunately streamlits css uses the google fonts api to serve fonts, which is not gdpr compliant, without asking the user for consent first.

.
We changed all fonts in the app by uploading a substitute font file to the github repo and switching all google fonts with this font by creating our own css and loading it in the code (using streamlit own css ) but at the start of the app all google fonts api calls are executed nonetheless. Does anybody have an idea how to solve this?
The situation makes it impossible for us (and at least any company based in Europe) to legally use streamlit share. To my understanding this could be easily solved from streamlits side by serving the font files from their servers or implementing a consent banner before the first google fonts api calls are executed.

Where or when exactly is that google api call occurring? As @Goyo mentioned and afaik, fonts files are served directly from streamlit installation, at least in v. 1.15.2: streamlit/frontend/src/assets/fonts at 1.15.2 · streamlit/streamlit · GitHub.

As you can see in the css snippet I posted above, which I got from our app deployed with streamlit share, atleast the streamlit version running on the streamlit share servers makes googlefonts api calls through the css. I cannot exactly say when these calls occur ( I am by no way an expert), but they are definitely in the css. Here is a longer version of the css (Unfortunately I cannot upload the file itself as this is not allowed on this forum). I highlighted the calls in red.

Just did a short test, when I run the App locally the css loads all fonts from local sources:

1 Like

I can confirm the google API call for that couple of fonts; interestingly, it only happens sometimes (not sure what’s the trigger).

My guess is that those calls are triggered by something in Streamlit Cloud (and not Streamlit), but since source code and implementation details for that are closed/proprietary :skull_and_crossbones:, it’s very hard to diagnose/fix from the community.

1 Like

Thank you for checking. Does anybody know the proper channel to contact streamlit staff regarding this issue?

Not really, Streamlit Cloud is a bit obscure about that. You can try opening a new post here on discuss describing the problem again, and put a link to this thread. In the meantime, the best option is to use a different hosting service imo.

I will try that, thank you for your answer

Sorry it took awhile to respond but that’s because we were figuring this out and good news, as of the Cloud release tonight, Google fonts are now self-hosted on Community Cloud! And they’ve always been self-hosted on Streamlit open source.

3 Likes

Hello, I just found this topic. I tried adding a custom font and hosting the app on Streamlit Community Cloud, but without making the call to googleapi, the text is not displayed with the proper font. Is there any Streamlit Community Cloud documentation about the self hosted fonts so I can check what I may be doing wrong? Thanks!