New to Typophile? Accounts are free, and easy to set up.
So I see that a FL font object has a "classes" attribute that's a list of the classes in the font.
1) Is there a way to filter this list to only see kerning classes?
2) When I try to copy kerning classes via script, e.g. —
fl.font2.classes = fl.font1.classes
This will copy the class members properly, but it loses the state of the left glyph / right glyph checkboxes in the class panel. Where does that data live?
8 Oct 2011 — 3:13pm
Filter for kerning classes by matching the first character of each class with an underscore:
classes = fl.font.classes for c in range( len(classes) ): class_text = classes[c] if class_text[0] == "_": print class_text8 Oct 2011 — 3:41pm
You can also save a copy of your classes as a text file from the "Classes" menu. In the upper left corner of the window is a tiny icon which when clicked reveals the option to "Save classes". You can either import this file completely as a replacement classes file, append some parts of it, or copy paste from a text editor the things you want.
9 Oct 2011 — 12:45am
The FontLab Font object offers the folowing methods to access class attributes:
9 Oct 2011 — 8:17am
Thanks Eigi. Mission accomplished
# copy kern class information from source kernClasses = [] kernClassesToBooleans = {} for index, glyphClass in enumerate(sourceFLFont.classes): if glyphClass.startswith("_"): kernClasses.append(glyphClass) kernClassesToBooleans[glyphClass] = (sourceFLFont.GetClassLeft(index), sourceFLFont.GetClassRight(index)) # clear target; copy classes targetFLFont.classes = [] targetFLFont.classes = kernClasses # copy booleans into target for index, kernClass in enumerate(targetFLFont.classes): leftBool, rightBool = kernClassesToBooleans[kernClass] targetFLFont.SetClassFlags(index, leftBool, rightBool)