fonttools/Snippets/apply-feature-file.py
Sascha Brawer c3e2d37299 Snippet for applying a feature file to a font
It would be nice to also handle MTI feature files, and to process
TTX in addition to binary fonts, and and and... but it's a start.
https://github.com/behdad/fonttools/issues/527
2016-03-09 17:19:10 +01:00

20 lines
530 B
Python
Executable File

#!/usr/bin/env python
from __future__ import print_function, division, absolute_import
from fontTools.misc.py23 import *
import fontTools.feaLib.builder as feaLibBuilder
from fontTools.ttLib import TTFont
import sys
if len(sys.argv) != 4:
print("usage: apply-feature-file.py features.fea in.ttf out.ttf")
sys.exit(1)
inputFeaturePath = sys.argv[1]
inputFontPath = sys.argv[2]
outputFontPath = sys.argv[3]
font = TTFont(inputFontPath)
feaLibBuilder.addOpenTypeFeatures(inputFeaturePath, font)
font.save(outputFontPath)