python - 如何在 Python 中使用 fonttools 将 woff2 字体转换为 ttf?
问题描述
我有 woff2 文件,我想使用 Python 和 fonttools 库将其转换为 ttf。我已经看到了一些关于如何将 ttf 字体转换为 woff2 的方法,但我不能用它们来做相反的事情。
提前致谢
解决方案
from fontTools.ttLib import woff2
# you also need brotli
import os
def convert(infilename, outfilename):
with open(infilename , mode='rb') as infile:
with open(outfilename, mode='wb') as outfile:
woff2.decompress(infile, outfile)
这是我编写的 CLI 友好脚本 https://github.com/basisvectors/woff2otf
python woff2otf.py (filename.woff or filename.woff2 or directory for batch conversion) [target file or dir name]
推荐阅读
- json - 如何进入我的帖子颤动/REST的详细信息页面?
- javascript - 将 UTC 时间 (HH:MM) 转换为本地时间
- javascript - jquery 是从哪里来的??(导轨)
- vb.net - 使用 StreamReader vb.net 的行文本文件索引
- c# - 有没有更好的方法来概括具有相同属性的 dbSet - 实体框架
- mysql - 如何在不丢失数据的情况下将 varchar 日期列更改为日期类型列
- java - 带有多个 if 语句的意图
- django - 从 ModelSerializer 中删除嵌套
- amazon-web-services - 使用 selenium AWS lambda 进行 Web 抓取
- amazon-web-services - s3,需要从浏览器下载,10GB限制