48 lines
2.3 KiB
XML
48 lines
2.3 KiB
XML
|
<?xml version="1.0" encoding="utf-8"?>
|
|||
|
<xml>
|
|||
|
<include src="settings/generic.xml" />
|
|||
|
<synopsis generate="1" name="Glyphnames versus GLIF-names" description="how to use Robofab's glyph naming schemes for UFO export" keywords="howto glyph ufo export" />
|
|||
|
<title>Glyphnames versus GLIF-names</title>
|
|||
|
<div class="content">
|
|||
|
<h1>Glyphnames versus GLIF-names</h1>
|
|||
|
<p>
|
|||
|
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.
|
|||
|
</p>
|
|||
|
|
|||
|
|
|||
|
<h2>GlyphNamingSchemes</h2>
|
|||
|
<p>
|
|||
|
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/glyphNameSchemes.py for the currently available callbacks. With glyphNameSchemes, the glyphName and the glif filename no longer have a direct relationship.
|
|||
|
</p>
|
|||
|
|
|||
|
<h3>glyphNameToShortFileName(glyphName, glyphSet)</h3>
|
|||
|
<p>
|
|||
|
Features a garuanteed maximum filename (default 31 characters) for really long glyphnames, and clash testing.
|
|||
|
</p>
|
|||
|
<ul>
|
|||
|
<li>all non-ascii characters are converted to "_" (underscore), including "."</li>
|
|||
|
<li>all glyphnames which are too long are truncated and a hash is added at the end</li>
|
|||
|
<li>the hash is generated from the whole glyphname</li>
|
|||
|
<li>finally, the candidate glyphname is checked against the contents.plist
|
|||
|
and a incrementing number is added at the end if there is a glyph with that name already.</li>
|
|||
|
</ul>
|
|||
|
|
|||
|
<p>
|
|||
|
glyphNameToShortFileName is the <strong>default naming scheme</strong> 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:
|
|||
|
|
|||
|
</p>
|
|||
|
|
|||
|
<pythonsource src="examples/usageGlifnames.py"/>
|
|||
|
|
|||
|
<python type="output"><![CDATA[
|
|||
|
"accent.glif"
|
|||
|
"A_ccent.glif"
|
|||
|
"this_is_a_very_lon340a8fa5.glif"
|
|||
|
"a_alt.glif"
|
|||
|
"_notdef.glif"
|
|||
|
"_nic_de.glif"
|
|||
|
]]></python>
|
|||
|
|
|||
|
</div>
|
|||
|
</xml>
|