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

Primary tabs

3 posts / 0 new
Last post
Paul van der Laan's picture
Joined: 4 Mar 2007 - 8:56am
How to set left/right classes in FL with Python?
0

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

Karsten Luecke's picture
Offline
Joined: 6 Aug 2005 - 8:41am
0

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.

Paul van der Laan's picture
Joined: 4 Mar 2007 - 8:56am
0

Helpful as ever - thank you, Karsten!

-Paul