I’m trying to generate a full range of files but I’m stuck on woff2. Am I missing something for the argument? The file that gets generated appears to be a woff as it is the same size as a woff.
This is my current function :
instance.generate(Format = "WOFF2", FontPath = os.path.expanduser(web_path + "/" + font.familyName + " - " + font.masters[0].name + ".woff2"), AutoHint = TTF_AutoHint, RemoveOverlap = RemoveOverlap, UseSubroutines = UseSubroutines, UseProductionNames = UseProductionNames)
This is my code ( or rather a little of mine and a lot of examples I plundered online) :
# MenuTitle: Batch Generate Fonts
# -*- coding: utf-8 -*-
__doc__=""" Batch Generate Fonts. """
import os
from robofab.interface.all.dialogs import GetFolder
fileFolder = GetFolder("Pick a directory...")
folderPath = '~/Desktop/TEMP_FONT_INSTANCES'
folderPathRelative = os.path.expanduser(folderPath)
if not os.path.exists(folderPathRelative):
os.makedirs(folderPathRelative)
otf_path = folderPath + "/otf"
otf_pathRelative = os.path.expanduser(otf_path)
if not os.path.exists(otf_pathRelative):
os.makedirs(otf_pathRelative)
ttf_path = folderPath + "/ttf"
ttf_pathRelative = os.path.expanduser(ttf_path)
if not os.path.exists(ttf_pathRelative):
os.makedirs(ttf_pathRelative)
ufo_path = folderPath + "/ufo"
ufo_pathRelative = os.path.expanduser(ufo_path)
if not os.path.exists(ufo_pathRelative):
os.makedirs(ufo_pathRelative)
web_path = folderPath + "/web"
web_pathRelative = os.path.expanduser(web_path)
if not os.path.exists(web_pathRelative):
os.makedirs(web_pathRelative)
fileFolder = os.path.expanduser(fileFolder)
fileNames = os.listdir(fileFolder)
OTF_AutoHint = True
TTF_AutoHint = True
RemoveOverlap = True
UseSubroutines = True
UseProductionNames = True
for fileName in fileNames:
if os.path.splitext(fileName)[1] == ".glyphs":
font = GSFont(os.path.join(fileFolder, fileName))
print font.familyName
for instance in font.instances:
print "== Exporting OTF --> " + otf_path + "/" + font.familyName + " - " + font.masters[0].name + ".otf"
instance.generate(Format = "OTF", FontPath = os.path.expanduser(otf_path + "/" + font.familyName + " - " + font.masters[0].name + ".otf"), AutoHint = OTF_AutoHint, RemoveOverlap = RemoveOverlap, UseSubroutines = UseSubroutines, UseProductionNames = UseProductionNames)
print
for instance in font.instances:
print "== Exporting TTF --> " + ttf_path + "/" + font.familyName + " - " + font.masters[0].name + ".ttf"
instance.generate(Format = "TTF", FontPath = os.path.expanduser(ttf_path + "/" + font.familyName + " - " + font.masters[0].name + ".ttf"), AutoHint = TTF_AutoHint, RemoveOverlap = RemoveOverlap, UseProductionNames = UseProductionNames)
print
for instance in font.instances:
print "== Exporting WOFF --> " + web_path + "/" + font.familyName + " - " + font.masters[0].name + ".woff"
instance.generate(Format = "WOFF", FontPath = os.path.expanduser(web_path + "/" + font.familyName + " - " + font.masters[0].name + ".woff"), AutoHint = TTF_AutoHint, RemoveOverlap = RemoveOverlap, UseSubroutines = UseSubroutines, UseProductionNames = UseProductionNames)
print
for instance in font.instances:
print "== Exporting WOFF 2 --> " + web_path + "/" + font.familyName + " - " + font.masters[0].name + ".woff2"
instance.generate(Format = "WOFF2", FontPath = os.path.expanduser(web_path + "/" + font.familyName + " - " + font.masters[0].name + ".woff2"), AutoHint = TTF_AutoHint, RemoveOverlap = RemoveOverlap, UseSubroutines = UseSubroutines, UseProductionNames = UseProductionNames)
print