SciencePlots icon indicating copy to clipboard operation
SciencePlots copied to clipboard

findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.

Open iDTer opened this issue 2 years ago • 3 comments

os: win10 SciencePlots v1.0.9 matplotlib 3.3.0 python 3.8

I have put the NotoSerifSC fonts into "..\site-packages\matplotlib\mpl-data\fonts\ttf" and also try the following command: import matplotlib.font_manager as fm fm._rebuild()

but still report "findfont: Font family ['serif'] not found. Falling back to DejaVu Sans.".

iDTer avatar Apr 28 '22 08:04 iDTer

Or how can I set the ['serif'] to ['sans serif']?

Thank you for any help!!!

iDTer avatar Apr 28 '22 08:04 iDTer

This may be because you don't install the corresponding font.

I use matplotlib-3.5.2, and then meet similar problem with you:

findfont: Font family ['serif'] not found. Falling back to DejaVu Sans. 
findfont: Generic family 'serif' not found because none of the following families were found: Times

I solve the problem by install the needed font 'Times'. I download the .ttf file from https://www.dafontfree.net/times-regular/f145546.htm and copy it to 'my_python_path/site-packages/matplotlib/mpl-data/fonts/ttf/'. After that, I delete the cache of matplotlib, which could be found by

import matplotlib
matplotlib.get_cachedir()

I hope it would be helpful for you : )

G0K0URURI avatar May 17 '22 14:05 G0K0URURI

You can use the following code to avoid warning in win10 without calling latex.

plt.style.use(['science', 'ieee', 'no-latex'])
matplotlib.rc('font', family='times new roman')

hh-wu avatar Aug 20 '22 09:08 hh-wu

Thank you everyone for the contribution. Closing as resolved, since no more reports of the problem were made, I assume it did work.

echedey-ls avatar Jan 20 '23 18:01 echedey-ls