Using Unicode fonts


I need to use some unicode text in my plots (Devanagari - Marathi). Locally the font manager finds the font. How do I do that in the streamlit app? Do I include the ttf file? Or add something to the requirements file? How? I am not using anything non-standard here otherwise. Below is the code snippet that uses the ‘Sanskrit 2003’ font, and the deployed version is here:

for tick in ax.get_yticklabels():
tick.set_fontname(“Sanskrit 2003”)

Thank you for the help.


Hello @AshishMahabal, welcome to the community!

If you’re using a custom font into Matplotlib, my guess would be to include a folder with the .ttf file to your Github project, then set up a custom font for matplotlib from inside your app.

I haven’t tested it but I hope it puts you on the right track :slight_smile: I’d be happy to hear back from you when you got it working.


1 Like

Thank you, @andfanilo. That worked.

I used tick.set_fontname(“Kalam”) for it to work in a specific location rather than setting it explicitly for the entire script using rcParams.

It is devanagari font, and it does not render the glyphs correctly right now, but that is a completely separate question.

Thanks, again!


1 Like

Hi, I am facing kind of the same issue. I like to use a specific font (chewy) in my streamlit web app (suvat_calculator/ at main · rafisics/suvat_calculator · GitHub). I have done the following:

st.markdown("<div><h1 style='text-align: center; color: #ff7903; font-family: Chewy'> SUVAT Calculator </h1></div>", unsafe_allow_html=True)

I can see the font because it’s installed on my computer. But I want it to appear to the users of the app who might not have it installed. How can I do that?