Skip to content

Instantly share code, notes, and snippets.

@kateliev
Created May 30, 2022 21:07
Show Gist options
  • Save kateliev/4204f40e3692f88028138bcb92ec6d97 to your computer and use it in GitHub Desktop.
Save kateliev/4204f40e3692f88028138bcb92ec6d97 to your computer and use it in GitHub Desktop.
A simple layer removal tool for FontLab 8
#FLM: Remove Layers by Name
#---------------------------------------------------------------
# Removes layers which names contain a given string
#---------------------------------------------------------------
# (C) Vassil Kateliev, 2022 (http://www.kateliev.com)
# - Dependancies
import fontlab as fl6
import fontgate as fgt
# - Config:
# -- A partial layer name to search for
str_remove_layer = '#instance'
# -- Remove all glyphs that are associated with layer given
remove_glyphs = True
# - Process
packages = [fl6.flPackage(font) for font in AllFonts()]
for package in packages:
for layer_name in package.masters:
if str_remove_layer in layer_name:
package.removeMaster(layer_name, remove_glyphs)
print('REMOVE:\t Font: {}; Layer: {};'.format(package.path, layer_name))
# - Finish
print('DONE:\t Remove layers by name!')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment