批量更改字体属性
Bulk changing font properties
我有一个这样的字体目录:
├── Trenda Black It.ttf
├── Trenda Black.ttf
├── Trenda Bold It.ttf
├── Trenda Bold.ttf
├── Trenda ExtraLight It.ttf
├── Trenda ExtraLight.ttf
├── Trenda Heavy It.ttf
├── Trenda Heavy.ttf
├── Trenda Light It.ttf
├── Trenda Light.ttf
├── Trenda RegularIt.ttf
├── Trenda Regular.ttf
├── Trenda Semibold It.ttf
├── Trenda Semibold.ttf
├── Trenda Thin It.ttf
└── Trenda Thin.ttf
不幸的是,字体系列并不都是Trenda
,它们是Trenda Black
、Trenda Bold
等等。
有没有办法自动将所有字体系列更改为 Trenda
?
以前我使用 Font Forge 在每个字体上手动完成,但这需要很长时间。
如果我也能根据名称设置权重 Class 就好了。
对于任何正在寻找的人,您可以在 python.
中与 font forge 交互
Python 不是我通常编写的程序,因此对糟糕的代码表示歉意
#!/usr/bin/env python
import fontforge as ff
import sys
args = sys.argv[1:]
if args[0] == '--help':
print("changeFontFamily <font> <family> <newFont>")
else:
font = args[0]
family = args[1]
newfont = args[2]
f = ff.open( font )
f.familyname = family
f.generate(newfont)
然后我就在 bash 循环中使用它
for file in *.ttf; do changeFontFamily "$file" "Trenda" "new/$file" 2> /dev/null; done
我有一个这样的字体目录:
├── Trenda Black It.ttf
├── Trenda Black.ttf
├── Trenda Bold It.ttf
├── Trenda Bold.ttf
├── Trenda ExtraLight It.ttf
├── Trenda ExtraLight.ttf
├── Trenda Heavy It.ttf
├── Trenda Heavy.ttf
├── Trenda Light It.ttf
├── Trenda Light.ttf
├── Trenda RegularIt.ttf
├── Trenda Regular.ttf
├── Trenda Semibold It.ttf
├── Trenda Semibold.ttf
├── Trenda Thin It.ttf
└── Trenda Thin.ttf
不幸的是,字体系列并不都是Trenda
,它们是Trenda Black
、Trenda Bold
等等。
有没有办法自动将所有字体系列更改为 Trenda
?
以前我使用 Font Forge 在每个字体上手动完成,但这需要很长时间。
如果我也能根据名称设置权重 Class 就好了。
对于任何正在寻找的人,您可以在 python.
中与 font forge 交互Python 不是我通常编写的程序,因此对糟糕的代码表示歉意
#!/usr/bin/env python
import fontforge as ff
import sys
args = sys.argv[1:]
if args[0] == '--help':
print("changeFontFamily <font> <family> <newFont>")
else:
font = args[0]
family = args[1]
newfont = args[2]
f = ff.open( font )
f.familyname = family
f.generate(newfont)
然后我就在 bash 循环中使用它
for file in *.ttf; do changeFontFamily "$file" "Trenda" "new/$file" 2> /dev/null; done