.ttf Export error

I have a script that clears layers and replaces them with a filled rectangle.

When I try to export I get this:

Thoughts on how to troubleshoot?

I don’t understand. What does it have to do with the script?

I’m new to scripting. I took your Fill Rectangles script and modified it for a more targeted solution. The source OFL font has too many glyphs and there are kerning issues. The script deletes glyphs that are not needed, clears the remaining glyph layer and adds a rectangle to the layer with the original glyph metrics. Then I have to clean up the features and update the font info. After all this, when I attempt to export the font, I get the error above. I tried correct path direction and tidy up paths but those didn’t help. The unmodified original font exports fine (other than kerning issues as noted in another post). I’m trying to understand how to troubleshoot the error and narrow it down to a cause.

Weird. Can you send me the script and .glyphs file? To support (at) (this website without ‘www’ or ‘forum’). I will have a look.

The export problems are not because of what the script does. They occur because you attempt to reverse engineer a large compiled font with a lot of kerning. Perhaps it is better to test your script with simpler, smaller fonts first. There is a tutorial about handling existing fonts.

The script itself is fine. There is one minor problem with the way you set font infos:

	thisFont.versionMinor = .001
except Exception as e:
	print("\n⚠️ Script Error:\n")
	raise e

First Font.versionMinor is an integer, so it would have to be =1.

Secondly, raising the error you just caught seems to defeat the purpose. Consider just print(e) instead.

You correctly used the variable thisFont here, but in other places in the code you still refer to Glyphs.font. Minor issue, but still.

One tip about lists:

redactoList = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z",

First, the semicolon at the end is not necessary.

Then, you can speed up things a bit if you use a tuple instead of a list for hardcoded, predefined collections. A tuple is immutable and therefore does not take as much memory. All you have to do is exchange the square brackets [] for round parentheses (). You can even do stuff like this:

redactoList = tuple( AZ + AZ.lower() ) + ("zero","one","two","three","four","five","six","seven","eight","nine")