GlyphOrderAndAliasDB and nam file with Python/FLS-macros

Arno Enslin's picture

I sometimes need GlyphOrderAndAliasDB files for the AFDKO in the same order as the index in FontLab. But I am not competent in Python scripting (although I have coded this script today). If you want to optimize the code, you are welcome.

------

Now I have added a script, that generates a nam file. This is useful for example, if you want to have the same Unicode points in different fonts, that are partly in the PUA. (The script does not generate Unicode points, but it reads the Unicode points of an encoded font.)

------

Updated on 09.11.10. Save me (context menu) as zip file.

agisaak's picture

Thanks Arno,

I haven't tried the script yet, but I had been thinking of learning python to perform this exact task.

André

Arno Enslin's picture

You only have to add "#FLM: Build GlyphOrderAndAliasDB" or another title beginning with "#FLM: " to the top of the code, if you want to store it in your macro folder.

Arno Enslin's picture

I have added a few more versions. And forget my previous message, because the files include titles now. "py_.txt" has to be replaced by ".py", because "py" is not an extension, that is allowed as attachement here.

And here you can find info about the tkfile dialog: http://tkinter.unpythonic.net/wiki/tkFileDialog

Mark Simonson's picture

Thanks, Arno! I needed to do this recently, but I used search and replace in a text editor to do it. Looks like using this script will make it much simpler the next time.

Arno Enslin's picture

Now I have added a script, that generates a nam file. This is useful for example, if you want to have the same Unicode points in different fonts, that are partly in the PUA. (The script does not generate Unicode points, but it reads the Unicode points of an encoded font.)

The code is not elegant. But I am an absolute beginner. It would be better to compare the length of the strings instead of comparing numbers or to compare hex numbers instead of decimal numbers.

Arno Enslin's picture

Now the code of the nam file generator is more elegant.

Arno Enslin's picture

I am still working on the scripts. Two questions:

After the dialog, where you want to save the file, has closed, the focus is not anymore on FontLab. You first have to click on the title bar of FontLab or on another point in FontLab. The user may be unsure then and click on another font window than the window of the active font. How can I give the focus to FontLab again in the end of the script?

And in the script the root directory is indicated by a slash (initialdir="/"). Does this also work on the Mac? Probably not. So I had to check first, if you are on Mac on PC and set a variable for the root directory. But which character(s) indicate the root directory?

Arno Enslin's picture

I have cleaned up the code and fixed a few bugs. Now it also works, if more than one font is opened. You have to change the file type to zip. Just put the content of the zip (the two folders) into your macro folder. I assume, they work on Mac and PC now, although I could test them on PC only.

Syndicate content Syndicate content