How to set left/right classes in FL with Python?

pvanderlaan's picture


I know the classes in FontLab can be accessed by using the "fl.classes" property in Python, but how do I set the right/left checkboxes in the classes window?

...Any chance that the unofficial Python API reference might be updated some time?


-Paul van der Laan

k.l.'s picture

It's a font-object related function:
You need to iterate through classes, and depending on whether the class is 1st/left or 2nd/right (e.g. check if a tag is found in class names), set the according flag(s):

isFIRST_TAG = "_1ST"
f = fl.font
classes = f.classes
for cIdx in range(len(classes)):
    cName = classes[cIdx].split(":",1)[0]
    if cName.startswith("_"):
        if isFIRST_TAG in cName:
            f.SetClassFlags(cIdx, 1, 0)
        elif isSECOND_TAG in cName:
            f.SetClassFlags(cIdx, 0, 1)
            f.SetClassFlags(cIdx, 1, 1)

Then update font.

pvanderlaan's picture

Helpful as ever - thank you, Karsten!


Syndicate content Syndicate content