From c3e2d3729950475b1c972fb49633f37476cf6723 Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Wed, 9 Mar 2016 17:15:17 +0100 Subject: [PATCH] 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 --- Snippets/apply-feature-file.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 Snippets/apply-feature-file.py diff --git a/Snippets/apply-feature-file.py b/Snippets/apply-feature-file.py new file mode 100755 index 000000000..1fcb45dfe --- /dev/null +++ b/Snippets/apply-feature-file.py @@ -0,0 +1,19 @@ +#!/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)