我想用 python3(更精确的 Python 3.6)代码在 Windows 10 上安装 .ttf 字体文件,我用谷歌搜索,但我唯一找到的是这个 Install TTF fonts on windows with python ,我测试了它,但它没有做任何事情。有没有办法用 python3 代码安装 .ttf?
提前致谢。
最佳答案
This图书馆似乎很有前途(我自己还没有尝试过)。
正在安装
pip install --user fonttools
或
pip3 install --user fonttools
代码
from fontTools.ttLib import TTFont
font = TTFont('/path/to/font.ttf')
然后使用font.save
方法:
Definition: font.save(self, file, reorderTables=True)
Docstring: Save the font to disk. Similarly to the constructor, the 'file' argument can be either a pathname or a writable file object.
关于Python3如何安装.ttf字体文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51177475/