Font family 'Computer Modern' not found

Defining “Computer Modern” as default font familly is very convenient when using Plots.jl default gr() backend, as per this other post.

However, using the pyplot or pythonplot backends issues the warning message:

findfont: Font family ['Computer Modern'] not found.

Is it possible to fix this font problem?

Since no one else is answering, here’s some input, maybe useful: Computer Modern is Knuth’s font for TeX. In the post you reference it’s however being used by MathJax so it’s not clear to me what’s happening here. The suggestion of using “Computer Modern” may be specific to that setup with specific backends. In any case, I’m not sure that Computer Modern is a good font choice, Knuth last updated it in 1992. I’m sure there are better, TTF or OTF, font available now.

Thanks for your response.

There is a “cm” font for pythonplot() backend :

using Plots; pythonplot(dpi=100)
plot(sin, fontfamily="cm", tickfontsize=20)

which issues the same error:
findfont: Font family 'cm' not found.

however, what is plotted does look like “Computer Modern”.

Could someone enlighten if pythonplot’s “cm” and gr’s “Computer Modern” could be matched, so that when we change backend we can keep the same font family.

I’m sorry if this might be a pointless and thankless question, but even if it is, I’d like to know that too.

Not a solution, just two cents worth of observations.

matplotlib finds the following Computer Modern related fonts on my system. They ship with mpl.

In [45]: font_list = sorted(matplotlib.font_manager.get_font_names())

[...]
 'cmb10',
 'cmex10',
 'cmmi10',
 'cmr10',
 'cmss10',
 'cmsy10',
 'cmtt10',
[...]

So Plots.plot(..., xlabel="x", fontfamily="cmr10") (“Computer Modern Roman”) works for setting the non-math font, but it sadly won’t select cm as the math font. Plots just doesn’t know how to translate cmr10 into the appropriate math font. I had thought this could be achieved by setting Plots.PythonPlot.matplotlib.rcParams["mathtext.fontset"] = "cm", but alas Plots has other plans and keeps falling back to dejavu for math.

1 Like