Glyphnames versus GLIF-names

The names of the GLIF xml files, in the UFO are related to the glyph names. It used to be a 1:1 relationship, but then glyphnames grew really long and some file systems don't support long filenames. So something had to give.


The objectsFL.RFont.writeUFO() method can take a special callback function in order to convert the actual glyphname to a suitable filename. The goal is to create unique filenames so that glyphs won't overwrite each other's exports, also comply to certain filesystems which require filenames to be shorter than a certain number of characters, while retaining a high level of human-readability. Have a look at robofab/tools/ for the currently available callbacks. With glyphNameSchemes, the glyphName and the glif filename no longer have a direct relationship.

glyphNameToShortFileName(glyphName, glyphSet)

Features a garuanteed maximum filename (default 31 characters) for really long glyphnames, and clash testing.

glyphNameToShortFileName is the default naming scheme for exporting UFOs from FontLab. For most everyday use, this callback does all the work and there is no need to tweak it. Below are some examples to give you an idea of what the callback does:

# robofab manual
#     Glifnames howto
#    glyphNameToShortFileName examples

# examples of glyphname to glif name transformations
from import glyphNameToShortFileName

# a short name
print glyphNameToShortFileName("accent", None)

# a short name, starting with capital letter
print glyphNameToShortFileName("Accent", None)

# a really long name - note the hexadecimal hash at the end
print glyphNameToShortFileName("this_is_a_very_long_glyph_name.altswash2", None)

# a name with a period in it, 1
print glyphNameToShortFileName("a.alt", None)

# a name with a period in it, 2
print glyphNameToShortFileName(".notdef", None)
➔ Download this.