From a9138612fa1aed43f05dea56abc1aceabaafc741 Mon Sep 17 00:00:00 2001 From: weiweihuanghuang Date: Thu, 8 Nov 2018 21:36:47 +1100 Subject: [PATCH] Update build --- sources/Test/tools/swapBracketTrick.py | 46 --------------------- sources/build.sh | 23 ++++++----- sources/tools/gftools-fix-vf-meta.py | 3 +- sources/tools/swapBracketTrick-NiceNames.py | 46 --------------------- sources/tools/swapBracketTrick.py | 41 +++++++++--------- 5 files changed, 34 insertions(+), 125 deletions(-) delete mode 100755 sources/Test/tools/swapBracketTrick.py delete mode 100644 sources/tools/swapBracketTrick-NiceNames.py diff --git a/sources/Test/tools/swapBracketTrick.py b/sources/Test/tools/swapBracketTrick.py deleted file mode 100755 index 40129a0..0000000 --- a/sources/Test/tools/swapBracketTrick.py +++ /dev/null @@ -1,46 +0,0 @@ -### Based on a script by Stephen Nixon - -import os -import sys -import fontTools -from fontTools.ttLib import TTFont -from fontTools.varLib.featureVars import addFeatureVariations -from fontTools.ttx import makeOutputFileName - -inputTTF = sys.argv[1] -# style = sys.argv[2] - -# f = TTFont(fontPath) -f = TTFont(inputTTF) - -condSubst = [ - # A list of (Region, Substitution) tuples. - ([{"wght": (0.158, 0.564)}], {"uniF8FF": "uniF8FF.001"}), - # ([{"wght": (0.868, 1)}], {"uni20B5": "uni20B5.201_230"}), - # ([{"wght": (0.868, 1)}], {"cent": "cent.201_230"}), - # ([{"wght": (0.868, 1)}], {"colonmonetary": "colonmonetary.201_230"}), - # ([{"wght": (0.868, 1)}], {"dollar": "dollar.201_230"}), - # ([{"wght": (0.868, 1)}], {"uni20B2": "uni20B2.201_230"}), - # ([{"wght": (0.868, 1)}], {"dollar.tf": "dollar.tf.201_230"}), - # ([{"wght": (0.868, 1)}], {"cent.tf": "cent.tf.201_230"}), - # ([{"wght": (0.71, 1)}], {"uni20A6": "uni20A6.169_230"}), - # ([{"wght": (0.71, 1)}], {"peseta": "peseta.169_230"}), - # ([{"wght": (0.71, 1)}], {"uni20A9": "uni20A9.169_230"}), - # ([{"wght": (0.564, 1)}], {"uni20B1": "uni20B1.136_230"}), - # ([{"wght": (0.424, 1)}], {"uni2761": "uni2761.79_230"}), - # ([{"wght": (0.424, 1)}], {"paragraph": "paragraph.79_230"}), -] - -# if style == "Upright": -# condSubst += [ -# ([{"wght": (0.564, 1)}], {"Adieresis.titl": "Adieresis.titl.136_230"}), -# ([{"wght": (0.564, 1)}], {"Odieresis.titl": "Odieresis.titl.136_230"}), -# ] - -addFeatureVariations(f, condSubst) - -# newFontPath = fontPath.split(".")[0] + "-italic.ttf" -# f.save(fontPath) -extension = os.path.splitext(inputTTF)[1] -outputTTF = makeOutputFileName(inputTTF, '', extension) -f.save(outputTTF) \ No newline at end of file diff --git a/sources/build.sh b/sources/build.sh index 4cf3dce..c736ca8 100755 --- a/sources/build.sh +++ b/sources/build.sh @@ -22,26 +22,24 @@ rm -rf master_ufo rm -rf instance_ufo rm -rf variable_ttf -# Add featureVariation for bracket trick glyphs -# python tools/swapBracketTrick.py ${VFname}.ttf "$1" -# mv ${VFname}-swap.ttf ${VFname}.ttf +Add featureVariation for bracket trick glyphs +python tools/swapBracketTrick.py ${VFname}.ttf "$1" +mv ${VFname}-swap.ttf ${VFname}.ttf # Fix non-hinting, DSIG and GASP table gftools fix-nonhinting ${VFname}.ttf ${VFname}.ttf -gftools fix-dsig --autofix ${VFname}.ttf gftools fix-gasp ${VFname}.ttf echo "nonhinting, dsig, gasp fixed" # Clean up backup file rm -rf ${VFname}-backup-fonttools-prep-gasp.ttf -# Fix VF Metadata -python tools/gftools-fix-vf-meta.py ${VFname}.ttf -echo "vf-meta fixed" - -# Clean up and rename VF -rm ${VFname}.ttf -mv ${VFname}.ttf.fix ${VFname}.ttf +# # Fix VF Metadata +# python tools/gftools-fix-vf-meta.py ${VFname}.ttf +# echo "vf-meta fixed" +# # Clean up and rename VF +# rm ${VFname}.ttf +# mv ${VFname}.ttf.fix ${VFname}.ttf # Correct nameID 6 (remove space) python tools/NAMEpatch.py ${VFname}.ttf @@ -49,6 +47,9 @@ rm ${VFname}.ttf mv ${VFname}#1.ttf ${VFname}.ttf echo "nameID 6 fixed" +# Fix DSIG +gftools fix-dsig --autofix ${VFname}.ttf + if [ "$1" = "Italic" ]; then # Rename *-ItalicItalic to -Italic for i in *.ttf; do diff --git a/sources/tools/gftools-fix-vf-meta.py b/sources/tools/gftools-fix-vf-meta.py index 5c9530a..9fbbfb9 100755 --- a/sources/tools/gftools-fix-vf-meta.py +++ b/sources/tools/gftools-fix-vf-meta.py @@ -19,7 +19,8 @@ axis (covers 95% of GF cases). """ from argparse import ArgumentParser from fontTools.ttLib import TTFont, newTable -from fontTools.ttLib.tables import otTables +from fontTools.ttLib.tables import otTablesos +import os OS_2_WEIGHT_CLASS = { diff --git a/sources/tools/swapBracketTrick-NiceNames.py b/sources/tools/swapBracketTrick-NiceNames.py deleted file mode 100644 index ed17ce6..0000000 --- a/sources/tools/swapBracketTrick-NiceNames.py +++ /dev/null @@ -1,46 +0,0 @@ -### Based on a script by Stephen Nixon - -import os -import sys -import fontTools -from fontTools.ttLib import TTFont -from fontTools.varLib.featureVars import addFeatureVariations -from fontTools.ttx import makeOutputFileName - -inputTTF = sys.argv[1] -style = sys.argv[2] - -# f = TTFont(fontPath) -f = TTFont(inputTTF) - -condSubst = [ - # A list of (Region, Substitution) tuples. - ([{"wght": (0.158, 0.564)}], {"apple": "apple.001"}), - ([{"wght": (0.868, 1)}], {"cedi": "cedi.201_230"}), - ([{"wght": (0.868, 1)}], {"cent": "cent.201_230"}), - ([{"wght": (0.868, 1)}], {"colonsign": "colonsign.201_230"}), - ([{"wght": (0.868, 1)}], {"dollar": "dollar.201_230"}), - ([{"wght": (0.868, 1)}], {"guarani": "guarani.201_230"}), - ([{"wght": (0.868, 1)}], {"dollar.tf": "dollar.tf.201_230"}), - ([{"wght": (0.868, 1)}], {"cent.tf": "cent.tf.201_230"}), - ([{"wght": (0.71, 1)}], {"naira": "naira.169_230"}), - ([{"wght": (0.71, 1)}], {"peseta": "peseta.169_230"}), - ([{"wght": (0.71, 1)}], {"won": "won.169_230"}), - ([{"wght": (0.564, 1)}], {"peso": "peso.136_230"}), - ([{"wght": (0.424, 1)}], {"curvedStemParagraphSignOrnament": "curvedStemParagraphSignOrnament.79_230"}), - ([{"wght": (0.424, 1)}], {"paragraph": "paragraph.79_230"}), -] - -if style == "Upright": - condSubst += [ - ([{"wght": (0.564, 1)}], {"Adieresis.titl": "Adieresis.titl.136_230"}), - ([{"wght": (0.564, 1)}], {"Odieresis.titl": "Odieresis.titl.136_230"}), - ] - -addFeatureVariations(f, condSubst) - -# newFontPath = fontPath.split(".")[0] + "-italic.ttf" -# f.save(fontPath) -extension = os.path.splitext(inputTTF)[1] -outputTTF = makeOutputFileName(inputTTF, '', extension) -f.save(outputTTF) \ No newline at end of file diff --git a/sources/tools/swapBracketTrick.py b/sources/tools/swapBracketTrick.py index 4b6c817..121e9ec 100755 --- a/sources/tools/swapBracketTrick.py +++ b/sources/tools/swapBracketTrick.py @@ -6,34 +6,33 @@ import fontTools from fontTools.ttLib import TTFont from fontTools.varLib.featureVars import addFeatureVariations -inputTTF = sys.argv[-1] -print(inputTTF) - +inputTTF = sys.argv[1] +style = sys.argv[2] f = TTFont(inputTTF) condSubst = [ # A list of (Region, Substitution) tuples. ([{"wght": (0.158, 0.564)}], {"uniF8FF": "uniF8FF.001"}), - # ([{"wght": (0.868, 1)}], {"uni20B5": "uni20B5.201_230"}), - # ([{"wght": (0.868, 1)}], {"cent": "cent.201_230"}), - # ([{"wght": (0.868, 1)}], {"colonmonetary": "colonmonetary.201_230"}), - # ([{"wght": (0.868, 1)}], {"dollar": "dollar.201_230"}), - # ([{"wght": (0.868, 1)}], {"uni20B2": "uni20B2.201_230"}), - # ([{"wght": (0.868, 1)}], {"dollar.tf": "dollar.tf.201_230"}), - # ([{"wght": (0.868, 1)}], {"cent.tf": "cent.tf.201_230"}), - # ([{"wght": (0.71, 1)}], {"uni20A6": "uni20A6.169_230"}), - # ([{"wght": (0.71, 1)}], {"peseta": "peseta.169_230"}), - # ([{"wght": (0.71, 1)}], {"uni20A9": "uni20A9.169_230"}), - # ([{"wght": (0.564, 1)}], {"uni20B1": "uni20B1.136_230"}), - # ([{"wght": (0.424, 1)}], {"uni2761": "uni2761.79_230"}), - # ([{"wght": (0.424, 1)}], {"paragraph": "paragraph.79_230"}), + ([{"wght": (0.868, 1)}], {"uni20B5": "uni20B5.201_230"}), + ([{"wght": (0.868, 1)}], {"cent": "cent.201_230"}), + ([{"wght": (0.868, 1)}], {"colonmonetary": "colonmonetary.201_230"}), + ([{"wght": (0.868, 1)}], {"dollar": "dollar.201_230"}), + ([{"wght": (0.868, 1)}], {"uni20B2": "uni20B2.201_230"}), + ([{"wght": (0.868, 1)}], {"dollar.tf": "dollar.tf.201_230"}), + ([{"wght": (0.868, 1)}], {"cent.tf": "cent.tf.201_230"}), + ([{"wght": (0.71, 1)}], {"uni20A6": "uni20A6.169_230"}), + ([{"wght": (0.71, 1)}], {"peseta": "peseta.169_230"}), + ([{"wght": (0.71, 1)}], {"uni20A9": "uni20A9.169_230"}), + ([{"wght": (0.564, 1)}], {"uni20B1": "uni20B1.136_230"}), + ([{"wght": (0.424, 1)}], {"uni2761": "uni2761.79_230"}), + ([{"wght": (0.424, 1)}], {"paragraph": "paragraph.79_230"}), ] -# if style == "Upright": -# condSubst += [ -# ([{"wght": (0.564, 1)}], {"Adieresis.titl": "Adieresis.titl.136_230"}), -# ([{"wght": (0.564, 1)}], {"Odieresis.titl": "Odieresis.titl.136_230"}), -# ] +if style == "Upright": + condSubst += [ + ([{"wght": (0.564, 1)}], {"Adieresis.titl": "Adieresis.titl.136_230"}), + ([{"wght": (0.564, 1)}], {"Odieresis.titl": "Odieresis.titl.136_230"}), + ] addFeatureVariations(f, condSubst)