Skip to content

Instantly share code, notes, and snippets.

@kateliev
Created June 26, 2022 19:37
Show Gist options
  • Save kateliev/52c9402d2a3fe90760fcbf436529326f to your computer and use it in GitHub Desktop.
Save kateliev/52c9402d2a3fe90760fcbf436529326f to your computer and use it in GitHub Desktop.
List Hybrid Component glyphs for FontLab 8
#FLM: List Hybrid Component glyphs
#---------------------------------------------------------------
# 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
from typerig.proxy.fl.objects.font import pFont
from typerig.proxy.fl.objects.glyph import eGlyph
# - Init
font = pFont()
font_masters = font.masters()
hybrid_glyphs = []
for glyph in font.glyphs(extend=eGlyph):
try:
hybrid_layers = [layer_name for layer_name in font_masters if glyph.isHybridComponent(layer_name)]
if len(hybrid_layers):
hybrid_glyphs.append(glyph.name)
print("Found:\tGlyph: {};\tLayers: {};".format(glyph.name, ", ".join(hybrid_layers)))
except (AttributeError):
print("Warn:\tGlyph: {};\tIs possbily empty or missing a master layer!".format(glyph.name))
print("\nDone:\tFound Hybrid Component Glyphs: {};".format(len(hybrid_glyphs)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment