python下载ttf字体文件
时间: 2023-08-13 18:08:54 浏览: 1025
你可以按照以下步骤下载ttf字体文件:
1. 打开终端或命令提示符,并导航到Matplotlib的ttf目录。可以使用以下命令:
```
cd ~/.local/lib/python3.5/site-packages/matplotlib/mpl-data/fonts/ttf
```
2. 复制你想要下载的ttf字体文件到ttf目录下。可以使用以下命令:
```
cp /mnt/hgfs/DirShare/SimHei.ttf .
```
3. 清除Matplotlib的缓存文件。可以使用以下命令:
```
rm ~/.cache/matplotlib/fontlist-v300.json
```
这样,你就成功下载了ttf字体文件,并可以在Matplotlib中使用它了。如果你想在Python中使用ttf字体文件,你可以使用以下代码:
```
import matplotlib.pyplot as plt
plt.rcParams\['font.sans-serif'\] = \['SimHei'\]
```
这样,你就可以在Matplotlib中使用SimHei字体了。希望对你有帮助!\[1\]
#### 引用[.reference_title]
- *1* [Python3 | UserWarning: findfont: Font family [‘SimHei‘] not found. Falling back to DejaVu Sans.](https://blog.csdn.net/Neutionwei/article/details/108311811)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [python游戏开发——字体文件下载](https://blog.csdn.net/weixin_63373973/article/details/130910522)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [python如何获取免费的可以商用的字体](https://blog.csdn.net/zhongkeyuanchongqing/article/details/120319566)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文