Browse Source

Split webfonts and output to fonts/web/split

Marc Foley 4 years ago
parent
commit
a77726b86f
3 changed files with 22 additions and 22 deletions
  1. 4 4
      Scripts/split_slnt_vf.py
  2. 0 7
      Scripts/subset_for_web.py
  3. 18 11
      sources/build-min.sh

+ 4 - 4
Scripts/split_slnt_vf.py

@@ -11,7 +11,7 @@ from fontTools.varLib.instancer import (
 )
 
 
-def split_slnt(ttfont):
+def split_slnt(ttfont, out_dir):
     """Use varlib instance to split a variable font if it contains a
     slnt or ital axis."""
     sanityCheckVariableTables(ttfont)
@@ -25,12 +25,12 @@ def split_slnt(ttfont):
     _update_nametable(italic)
 
     roman_filename = os.path.join(
-        os.path.dirname(roman.reader.file.name),
+        out_dir,
         vf_filename(roman)
     )
     roman.save(roman_filename)
     italic_filename = os.path.join(
-        os.path.dirname(italic.reader.file.name),
+        out_dir,
         vf_filename(italic)
     )
     italic.save(italic_filename)
@@ -89,7 +89,7 @@ def _update_nametable(ttfont):
 
 def main():
     ttfont = TTFont(sys.argv[1])
-    split_slnt(ttfont)
+    split_slnt(ttfont, sys.argv[2])
 
 
 if __name__ == "__main__":

+ 0 - 7
Scripts/subset_for_web.py

@@ -58,13 +58,6 @@ def touchup_for_web(ttfont):
     os2.usWinAscent = 1946
     os2.usWinDescent = 512
 
-    roman = instantiateVariableFont(ttfont, {"ital": 0.0})
-    italic = instantiateVariableFont(ttfont, {"ital": 1.0})
-    dir_name = os.path.dirname(ttfont.reader.file.name)
-    roman_filename = os.path.join(dir_name, "Roboto[wdth,wght].ttf")
-    italic_filename = os.path.join(dir_name, "Roboto-Italic[wdth,wght].ttf")
-    roman.save(roman_filename)
-    italic.save(italic_filename)
     ttfont.save(ttfont.reader.file.name)
 
 

+ 18 - 11
sources/build-min.sh

@@ -1,26 +1,33 @@
 set -e
 
+mkdir -p fonts
 
-#Make VF
+#Make unhinted VF
 fontmake -m sources/Roboto-min.designspace -o variable --output-path fonts/Roboto[ital,wdth,wght].ttf
-
 # Remove MVAR
 python Scripts/drop_mvar.py fonts/Roboto[ital,wdth,wght].ttf
+# Fix STAT
+statmake --designspace sources/Roboto-min.designspace --stylespace sources/Roboto-min.stylespace fonts/Roboto[ital,wdth,wght].ttf
+# Add smooth gasp table
+python Scripts/fix_gasp.py fonts/Roboto[ital,wdth,wght].ttf "65535=15"
 
-# Transfer Hints and compile them
-python -m vttLib mergefile sources/vtt-hinting.ttx fonts/Roboto[ital,wdth,wght].ttf
-python -m vttLib compile fonts/Roboto[ital,wdth,wght].ttf --ship
-mv fonts/Roboto[ital,wdth,wght]#1.ttf fonts/Roboto[ital,wdth,wght].ttf
 
+# Make hinted
+# Transfer Hints and compile them
+mkdir -p fonts/hinted
+cp fonts/Roboto[ital,wdth,wght].ttf fonts/hinted/Roboto[ital,wdth,wght].ttf
+python -m vttLib mergefile sources/vtt-hinting.ttx fonts/hinted/Roboto[ital,wdth,wght].ttf
+python -m vttLib compile fonts/hinted/Roboto[ital,wdth,wght].ttf --ship
+mv fonts/hinted/Roboto[ital,wdth,wght]#1.ttf fonts/hinted/Roboto[ital,wdth,wght].ttf
 # Add gasp table
-python Scripts/fix_gasp.py fonts/Roboto[ital,wdth,wght].ttf "8=8,65535=15"
+python Scripts/fix_gasp.py fonts/hinted/Roboto[ital,wdth,wght].ttf "8=8,65535=15"
 
-# Fix STAT
-statmake --designspace sources/Roboto-min.designspace --stylespace sources/Roboto-min.stylespace fonts/Roboto[ital,wdth,wght].ttf
 
 # Make web
+# TODO confirm we don't need to subset
 mkdir -p fonts/web
-python Scripts/subset_for_web.py fonts/Roboto[ital,wdth,wght].ttf fonts/web/Roboto[ital,wdth,wght].ttf
+python Scripts/subset_for_web.py fonts/hinted/Roboto[ital,wdth,wght].ttf fonts/web/Roboto[ital,wdth,wght].ttf
 # Can be removed once all browsers support slnt and ital axes properly
-python Scripts/split_slnt_vf.py fonts/web/Roboto[ital,wdth,wght].ttf
+mkdir -p fonts/web/split
+python Scripts/split_slnt_vf.py fonts/web/Roboto[ital,wdth,wght].ttf fonts/web/split