Python3如何安装.ttf字体文件?

标签 python python-3.x truetype

我想用 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/

相关文章:

python - 成功在Azure部署Flask应用程序,但应用程序在打开网站时无法运行

python - lxml cssselect 解析

python 子进程不写入标准输出

fonts - 通过 fontforge 脚本获取字形宽度

c - stb_truetype.h 和 SDL2 更改字体颜色

fonts - Web 浏览器如何实现字体回退?

python - 优化Python中的广度优先搜索

python - 计数向量化器中是否可以有无序二元组

python - 无法使用 python 过滤器返回预期输出

linux - 键盘快捷键在 tkinter 中给我错误