Batch Generate script no EOT?

Hi Georg, I’m using your Batch Generate script and I slightly modified it to include WOFF2 and EOT. I have no issues with WOFF2 only but if I add the EOT relevant lines I get this in the macro panel:

G2.5.2 (1161)

== Exporting EOT ==

Traceback (most recent call last):

File "Batch Generate 2.py", line 49, in <module>

print instance.generate(Format = "EOT", FontPath = os.path.expanduser(web_path), AutoHint = TTF_AutoHint, RemoveOverlap = RemoveOverlap, UseSubroutines = UseSubroutines, UseProductionNames = UseProductionNames)

File "GlyphsApp/GlyphsApp/__init__.py", line 3722, in __Instance_Export__

KeyError: "The font format is not supported: EOT (only 'OTF' and 'TTF')"

I’m also testing the script in G2.4.4 (1075) and in this case it only exports TTF ad OTF, even if in the macro panel I see

== Exporting TTF ==

True

== Exporting OTF ==

True

== Exporting WOFF ==

True

== Exporting WOFF2 ==

True

== Exporting EOT ==

True

How can I get the script to also export EOTs? And why is it not exporting the web formats in 2.4.4?
Thank you!
Alessia

Try the latest beta please. Go to Glyphs > Preferences > Updates, activate both checkboxes and press the Update button.

That was a fast reply! I was some versions behind. But I still get the same result, no EOT and the same report.

I have updated the script to the latest API.

Thank you! Is there anyway I can make the old version of the script export EOT, WOFF and WOFF2 in 2.4.4? Will 2.5.2 be released as stable release soon?

Not in 2.4.4. There is a stable 2.5.1 that should work. But the 2.5.2 should be stable enough to export your fonts.

The script doesn’t work in 2.5.1 (1141)
This is what I get:
Traceback (most recent call last):
File “Batch Generate.py”, line 34, in
print instance.generate(Format=OTF, FontPath=os.path.expanduser(otf_path), AutoHint=OTF_AutoHint, RemoveOverlap=RemoveOverlap, UseSubroutines=UseSubroutines, UseProductionNames=UseProductionNames)
File “GlyphsApp/GlyphsApp/init.py”, line 3728, in Instance_Export
TypeError: ‘NSKVONotifying_GSFont’ object is not callable

Unfortunately at work we are using only stable releases to export files.

There is a bug in the generate() method in the wrapper. Here is the code from the current wrapper that works in 2.5.1

otf_path = "~/Desktop"
from GlyphsApp import _ExporterDelegate_

def __Instance_Export__(self, Format=OTF, FontPath=None, AutoHint=True, RemoveOverlap=True, UseSubroutines=True, UseProductionNames=True, Containers=None, ConvertNames=False, DecomposeSmartStuff=True):

	if Format not in [OTF, WOFF, WOFF2, TTF, UFO]:
		raise KeyError('The font format is not supported: %s (only \'OTF\' and \'TTF\')' % Format)

	ContainerList = None
	if Containers is not None:
		ContainerList = []
		for Container in Containers:
			if Container in [PLAIN, WOFF, WOFF2, EOT]:
				ContainerList.append(Container.lower())
			else:
				raise KeyError('The container format is not supported: %s (only \'WOFF\' \'WOFF2\' \'plain\' and \'EOT\')' % Container)

	if Format == UFO:
		if not FontPath:
			print("!", FontPath)
			raise ValueError('Please provide a FontPath')
		instanceFont = self.interpolatedFont
		return instanceFont.export(Format=Format, FontPath=FontPath, UseProductionNames=UseProductionNames, DecomposeSmartStuff=DecomposeSmartStuff)
	else:
		Font = self.font
		if FontPath is None:
			FontPath = NSUserDefaults.standardUserDefaults().objectForKey_("OTFExportPath")

		Format = Format.lower()	# GSExportInstanceOperation uses Format as file .extension
		Exporter = NSClassFromString("GSExportInstanceOperation").alloc().initWithFont_instance_outlineFormat_containers_(Font, self, Format, ContainerList)
		if FontPath is None:
			FontPath = NSUserDefaults.standardUserDefaults().objectForKey_("OTFExportPath")
		Exporter.setInstallFontURL_(NSURL.fileURLWithPath_(FontPath))
		# the following parameters can be set here or directly read from the instance.
		Exporter.setAutohint_(AutoHint)
		Exporter.setRemoveOverlap_(RemoveOverlap)
		Exporter.setUseSubroutines_(UseSubroutines)
		Exporter.setUseProductionNames_(UseProductionNames)

		Exporter.setTempPath_(os.path.expanduser("~/Library/Application Support/Glyphs/Temp/")) # this has to be set correctly.

		Delegate = _ExporterDelegate_.alloc().init() # the collectResults_() method of this object will be called on case the exporter has to report a problem.
		Exporter.setDelegate_(Delegate)
		Exporter.main()
		if Delegate.result is True:
			self.lastExportedFilePath = Exporter.finalFontPath()
		else:
			self.lastExportedFilePath = None
		return Delegate.result
print __Instance_Export__(Font.instances[0], Format=OTF, FontPath=os.path.expanduser(otf_path))

Thanks again! I’m definitely doing something wrong, if I use the code you just sent, I only get the first instance OTF in the folder I specify in otf_path at the very top.

The code is only doing that. Have a look at the last line and adjust it how you need it. You need to replace any instance.generate( with __Instance_Export__(instance in the main script (and add the method to that script).

Got it! Thank you!