有时候apt/yum库无法自动安装字体, 需要手动安装

首先下载.ttf结尾的字体, 或者从windows上找到, 拷贝到Linux中
这里我是从google font下载的字体

1
scp NotoSerifSC-VariableFont_wght.ttf root@your-host:/usr/share/fonts/NotoSerifSC-VariableFont_wght/ # 记得提前mkdir

然后加载ttf字体

1
2
fc-cache -fv
fc-list :lang=zh # 验证生效

然后就可以使用了, 比如py里. 可能识别不到, 需要先清除plt缓存rm -rf ~/.cache/matplotlib

1
2
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = ['Noto Serif SC']