2018-11-07 11:05:48 +03:00
|
|
|
### Based on a script by Stephen Nixon
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import fontTools
|
|
|
|
from fontTools.ttLib import TTFont
|
|
|
|
from fontTools.varLib.featureVars import addFeatureVariations
|
|
|
|
|
2018-11-08 13:36:47 +03:00
|
|
|
inputTTF = sys.argv[1]
|
|
|
|
style = sys.argv[2]
|
2018-11-07 11:05:48 +03:00
|
|
|
|
2018-11-08 02:25:24 +03:00
|
|
|
f = TTFont(inputTTF)
|
2018-11-08 13:36:47 +03:00
|
|
|
if style == "Upright":
|
2018-11-09 14:27:09 +03:00
|
|
|
condSubst = [
|
|
|
|
# A list of (Region, Substitution) tuples.
|
|
|
|
([{"wght": (0.158, 0.564)}], {"uniF8FF": "uniF8FF.001"}),
|
|
|
|
([{"wght": (0.868, 1)}], {"uni20B5": "uni20B5.201_230",
|
|
|
|
"cent": "cent.201_230",
|
|
|
|
"dollar": "dollar.201_230",
|
|
|
|
"uni20B2": "uni20B2.201_230",
|
|
|
|
"dollar.tf": "dollar.tf.201_230",
|
|
|
|
"cent.tf": "cent.tf.201_230"}),
|
|
|
|
([{"wght": (0.71, 1)}], {"uni20A6": "uni20A6.169_230",
|
|
|
|
"peseta": "peseta.169_230",
|
|
|
|
"uni20A9": "uni20A9.169_230"}),
|
|
|
|
([{"wght": (0.564, 1)}], {"uni20B1": "uni20B1.136_230",
|
2018-11-12 17:11:18 +03:00
|
|
|
"Adieresis": "Adieresis.136_230",
|
|
|
|
"Udieresis": "Udieresis.136_230",
|
2018-11-09 14:47:05 +03:00
|
|
|
"Adieresis.titl": "Adieresis.titl.136_230",
|
2018-11-12 17:11:18 +03:00
|
|
|
"Udieresis.titl": "Udieresis.titl.136_230",
|
|
|
|
"colonmonetary": "colonmonetary.136_230"}),
|
2018-11-09 14:27:09 +03:00
|
|
|
([{"wght": (0.424, 1)}], {"uni2761": "uni2761.79_230",
|
|
|
|
"paragraph": "paragraph.79_230",
|
2018-11-12 17:11:18 +03:00
|
|
|
"Odieresis.titl": "Odieresis.titl.106_230",
|
|
|
|
"Odieresis": "Odieresis.106_230"}),
|
2018-11-09 14:27:09 +03:00
|
|
|
]
|
|
|
|
elif style == "Italic":
|
|
|
|
condSubst = [
|
|
|
|
# A list of (Region, Substitution) tuples.
|
|
|
|
([{"wght": (0.868, 1)}], {"uni20B5": "uni20B5.201_230",
|
|
|
|
"cent": "cent.201_230",
|
|
|
|
"colonmonetary": "colonmonetary.201_230",
|
|
|
|
"dollar": "dollar.201_230",
|
|
|
|
"uni20B2": "uni20B2.201_230",
|
|
|
|
"dollar.tf": "dollar.tf.201_230",
|
|
|
|
"cent.tf": "cent.tf.201_230"}),
|
|
|
|
([{"wght": (0.71, 1)}], {"uni20A6": "uni20A6.169_230",
|
|
|
|
"peseta": "peseta.169_230",
|
|
|
|
"uni20A9": "uni20A9.169_230"}),
|
2018-11-12 17:11:18 +03:00
|
|
|
([{"wght": (0.564, 1)}], {"uni20B1": "uni20B1.136_230",
|
|
|
|
"colonmonetary": "colonmonetary.136_230"}),
|
2018-11-09 14:27:09 +03:00
|
|
|
([{"wght": (0.424, 1)}], {"uni2761": "uni2761.79_230",
|
|
|
|
"paragraph": "paragraph.79_230"}),
|
|
|
|
]
|
|
|
|
|
2018-11-07 11:05:48 +03:00
|
|
|
|
|
|
|
addFeatureVariations(f, condSubst)
|
|
|
|
|
2018-11-08 02:25:24 +03:00
|
|
|
outputTTF = inputTTF.replace('.ttf', '-swap.ttf')
|
2018-11-09 14:27:09 +03:00
|
|
|
f.save(outputTTF)
|