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

pvanderlaan's picture

Hi,

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?

Thanks,

-Paul van der Laan

www.type-invaders.com

k.l.'s picture

It's a font-object related function:
SetClassFlags(classIndex,isFirst,isSecond)
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"
isSECOND_TAG = "_2ND"
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)
        else:
            f.SetClassFlags(cIdx, 1, 1)

Then update font.

pvanderlaan's picture

Helpful as ever - thank you, Karsten!

-Paul

Syndicate content Syndicate content