Add Font Type to Replit for Image Creation (Python)

Hi there,

Using Plotly, a charting python package, I am trying to locally create a .png of various different charts. Plotly allows for users to set a custom font, but Replit isn’t recognizing the font when it goes to create and store the image locally.

How can I add a font to my Replit such that the chart displays my desired font? Sample code below:

import plotly.graph_objects as go

headerColor = 'grey'
rowEvenColor = 'lightgrey'
rowOddColor = 'white'

fig = go.Figure(data=[go.Table(
    font=dict(color='white', size=12, family='montserrat')
      ['Salaries', 'Office', 'Merchandise', 'Legal', '<b>TOTAL</b>'],
      [1200000, 20000, 80000, 2000, 12120000],
      [1300000, 20000, 70000, 2000, 130902000],
      [1300000, 20000, 120000, 2000, 131222000],
      [1400000, 20000, 90000, 2000, 14102000]],
    # 2-D list of colors for alternating rows
    fill_color = [[rowOddColor,rowEvenColor,rowOddColor, rowEvenColor,rowOddColor]*5],
    align = ['left', 'center'],
    font = dict(color = 'darkslategray', size = 11, family='montserrat')


Hey, @phum126 welcome to the forums.

Since I never worked with that package I don’t know but I did find this answer on Stack Overflow about changing the font. Thought it is 5 years old so it may be outdated.

Thanks Ethan.

I’ve already made the changes in my code above for a different font, family='montserrat'. The issue is that Replit itself doesn’t generate a chart locally with said font. I’m not sure if I need to install the font via CLI or something?