177 lines
4.6 KiB
HTML
Raw Normal View History

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Glyphnames versus GLIF-names</title>
<link href="../default.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div id="modellogo">
<img src="../img/drawmodel_header.jpg" width="595" height="112" />
</div>
<div class="leftcontent">
<h2 class="crb-seealso">
RoboFab
</h2>
<p class="menu">
<a href="../index.html">
Home
</a>
<br />
<a href="../download/license.html">
Download v1.1.1
</a>
<br />
<a href="../intro.html">
Intro
</a>
<br />
<a href="../install.html">
Install Notes
</a>
<br />
<a href="../history.html">
History
</a>
<br />
<a href="../executive.html">
Summary
</a>
</p>
<p class="menu">
<a href="index.html">
How to's
</a>
<br />
<a href="../objects/index.html">
Fab Objects
</a>
<br />
<a href="../objects/model.html">
Fab Map
</a>
<br />
<a href="../tools/index.html">
Fab Tools
</a>
<br />
<a href="../ufo/index.html">
UFO Overview
</a>
<br />
<a href="../limitations.html">
Fab Limitations
</a>
</p>
<p class="menu">
<a href="../links/index.html">
Links
</a>
<br />
<a href="../glossary/index.html">
Glossary
</a>
<br />
<a href="../credits.html">
Credits
</a>
</p>
<br />
<br />
<p class="crb-uplink"><a href="index.html">Back to How To</a></p>
<br />
<br />
<p class="menu">
</p>
</div>
<div class="footer">
<a href="../feedback.html">
Feedback
</a>
<br />
<a href="../map.html">
Sitemap
</a>
<br />
Please also refer to the
<a href="../download/license.html">
Legal
</a>
<br />
Copyright 2003-2005 RoboFab
<br />
version 1.1.1
</div>
<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 &quot;_&quot; (underscore), including &quot;.&quot;</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>
<pre>
# examples of glyphname to glif name transformations
from robofab.tools.glyphNameSchemes import glyphNameToShortFileName
# a short name
print glyphNameToShortFileName(&quot;accent&quot;, None)
>>> &quot;accent.glif&quot;
# a short name, starting with capital letter
print glyphNameToShortFileName(&quot;Accent&quot;, None)
>>> &quot;A_ccent.glif&quot;
# a really long name - note the hexadecimal hash at the end
print glyphNameToShortFileName(&quot;this_is_a_very_long_glyph_name.altswash2&quot;, None)
>>> &quot;this_is_a_very_lon340a8fa5.glif&quot;
# a name with a period in it, 1
print glyphNameToShortFileName(&quot;a.alt&quot;, None)
>>> &quot;a_alt.glif&quot;
# a name with a period in it, 2
print glyphNameToShortFileName(&quot;.notdef&quot;, None)
>>> &quot;_notdef.glif&quot;
# a name with non-ascii characters
print glyphNameToShortFileName(&quot;&uuml;nic&oslash;de&quot;, None)
>>> &quot;_nic_de.glif&quot;
</pre>
</div>
</body>
</html>