要在 WSL (Windows Subsystem for Linux) 中使用 PyCharm + matplotlib
正确显示 宋体 + Times New Roman + 五号字号(10.5pt) 的图内文字,需要完成以下几个步骤:
✅ 一、字体安装(在 WSL 中)
1. ✔️ 确认你需要的字体文件
你想用的字体包括:
中文字体 | 英文字体 | 五号字号 |
---|---|---|
宋体(SimSun) | Times New Roman | 10.5 pt |
这些字体Windows 原生自带,你只需复制到 WSL 下 /usr/share/fonts
目录即可。
2. ✔️ 复制字体文件到 WSL
在 WSL 中执行以下命令:
mkdir -p ~/.fonts/simsun_tnr
cd ~/.fonts/simsun_tnr
然后,从 Windows 复制字体文件到 WSL:
cp /mnt/c/Windows/Fonts/simsun.ttc simsun.ttc
cp /mnt/c/Windows/Fonts/times.ttf times.ttf
cp /mnt/c/Windows/Fonts/timesbd.ttf timesbd.ttf
cp /mnt/c/Windows/Fonts/timesi.ttf timesi.ttf
cp /mnt/c/Windows/Fonts/timesbi.ttf timesbi.ttf
3. ✔️ 更新字体缓存
fc-cache -fv
验证字体安装是否成功:
fc-list | grep -i "simsun"
fc-list | grep -i "times new roman"