<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Preserve empty glyphs when applying defcon sort order through script]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/474/can-i-apply-a-smart-sort-for-glyph-order-via-script">Can I apply a "smart sort" for Glyph Order via script?</a></p>
<p dir="auto">I have <a href="https://github.com/thundernixon/robofont-drawing-helpers/blob/95f86f7f508972c4ddf5a165e23df133c2d839a7/make-selected-alt_glyphs-default.py" rel="nofollow">a script</a> to make suffixed (alternate) glyphs into non-suffixed ("default") glyphs.</p>
<p dir="auto">However, without a sorting step, this places the new "default" glyph at the end of the glyph order.</p>
<p dir="auto">When I apply a new glyph order, as suggested in the earlier thread posted above, it removes A) all template glyphs, and B) the /space glyph.</p>
<p dir="auto">This is quite disruptive to a UFO, and means that I keep deleting spaces.</p>
<p dir="auto">One workaround I can think of is:</p>
<ul>
<li>save the current glyphOrder as a list</li>
<li>create a dictionary for empty glyphs</li>
<li>checking through glyphs of a font
<ul>
<li>if a glyph has no contours
<ul>
<li>save its data to the dictionary. unicodes, width, inclusion in groups, inclusion in kerning pairs, maybe more (?)</li>
</ul>
</li>
</ul>
</li>
<li>perform the glyph swap</li>
<li>apply the sort order</li>
<li>re-add the glyphs from the empty-glyphs dictionary</li>
<li>re-assert the saved glyphOrder, and add the new glyph at the end</li>
</ul>
<p dir="auto">However, this feels a bit easy to mess up and possibly inefficient.</p>
<p dir="auto">So, this leaves me with two questions:</p>
<ol>
<li>
<p dir="auto">Is there a way to cue the built-in "smart sort" feature from a script, as per the old, original question?</p>
</li>
<li>
<p dir="auto">If not, is there a smarter way to save and restore the empty glyphs?</p>
</li>
</ol>
<p dir="auto">Thanks so much for any pointers!</p>
]]></description><link>https://forum.robofont.com/topic/647/preserve-empty-glyphs-when-applying-defcon-sort-order-through-script</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Jul 2026 07:16:02 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/647.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 May 2019 03:18:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Preserve empty glyphs when applying defcon sort order through script on Thu, 01 Aug 2019 00:07:18 GMT]]></title><description><![CDATA[<p dir="auto">Re: <a href="/topic/474/can-i-apply-a-smart-sort-for-glyph-order-via-script">Can I apply a "smart sort" for Glyph Order via script?</a></p>
<p dir="auto">I have <a href="https://github.com/thundernixon/robofont-drawing-helpers/blob/95f86f7f508972c4ddf5a165e23df133c2d839a7/make-selected-alt_glyphs-default.py" rel="nofollow">a script</a> to make suffixed (alternate) glyphs into non-suffixed ("default") glyphs.</p>
<p dir="auto">However, without a sorting step, this places the new "default" glyph at the end of the glyph order.</p>
<p dir="auto">When I apply a new glyph order, as suggested in the earlier thread posted above, it removes A) all template glyphs, and B) the /space glyph.</p>
<p dir="auto">This is quite disruptive to a UFO, and means that I keep deleting spaces.</p>
<p dir="auto">One workaround I can think of is:</p>
<ul>
<li>save the current glyphOrder as a list</li>
<li>create a dictionary for empty glyphs</li>
<li>checking through glyphs of a font
<ul>
<li>if a glyph has no contours
<ul>
<li>save its data to the dictionary. unicodes, width, inclusion in groups, inclusion in kerning pairs, maybe more (?)</li>
</ul>
</li>
</ul>
</li>
<li>perform the glyph swap</li>
<li>apply the sort order</li>
<li>re-add the glyphs from the empty-glyphs dictionary</li>
<li>re-assert the saved glyphOrder, and add the new glyph at the end</li>
</ul>
<p dir="auto">However, this feels a bit easy to mess up and possibly inefficient.</p>
<p dir="auto">So, this leaves me with two questions:</p>
<ol>
<li>
<p dir="auto">Is there a way to cue the built-in "smart sort" feature from a script, as per the old, original question?</p>
</li>
<li>
<p dir="auto">If not, is there a smarter way to save and restore the empty glyphs?</p>
</li>
</ol>
<p dir="auto">Thanks so much for any pointers!</p>
]]></description><link>https://forum.robofont.com/post/2394</link><guid isPermaLink="true">https://forum.robofont.com/post/2394</guid><dc:creator><![CDATA[StephenNixon]]></dc:creator><pubDate>Thu, 01 Aug 2019 00:07:18 GMT</pubDate></item><item><title><![CDATA[Reply to Preserve empty glyphs when applying defcon sort order through script on Tue, 30 Jul 2019 13:49:32 GMT]]></title><description><![CDATA[<p dir="auto">hi <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/230">@StephenNixon</a>,</p>
<p dir="auto">try using <code>f.templateGlyphOrder</code> instead of <code>f.glyphOrder</code> for sorting:</p>
<pre><code class="language-python">f = CurrentFont()
newGlyphOrder = f.naked().unicodeData.sortGlyphNames(f.templateGlyphOrder, sortDescriptors=[dict(type="cannedDesign", ascending=True, allowPseudoUnicode=True)])
f.templateGlyphOrder = newGlyphOrder
</code></pre>
<p dir="auto">see <a href="https://robofont.com/documentation/building-tools/api/fontParts/rfont/#RFont.templateGlyphOrder" rel="nofollow">FontParts &gt; RFont.templateGlyphOrder</a></p>
<p dir="auto">ps. there are other <code>RFont</code> attributes related to template glyphs:</p>
<ul>
<li><code>f.templateGlyphs</code></li>
<li><code>f.templateSelectedGlyphNames</code></li>
<li><code>f.templateKeys</code></li>
</ul>
]]></description><link>https://forum.robofont.com/post/2395</link><guid isPermaLink="true">https://forum.robofont.com/post/2395</guid><dc:creator><![CDATA[gferreira]]></dc:creator><pubDate>Tue, 30 Jul 2019 13:49:32 GMT</pubDate></item><item><title><![CDATA[Reply to Preserve empty glyphs when applying defcon sort order through script on Wed, 31 Jul 2019 23:44:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/22">@gferreira</a> said in <a href="/post/2395">Preserve empty glyphs when applying defcon sort order through script</a>:</p>
<blockquote>
<pre><code class="language-python">newGlyphOrder = f.naked().unicodeData.sortGlyphNames(f.templateGlyphOrder, sortDescriptors=[dict(type="cannedDesign", ascending=True, allowPseudoUnicode=True)])
f.templateGlyphOrder = newGlyphOrder
</code></pre>
</blockquote>
<p dir="auto">Oh, interesting!</p>
<p dir="auto">Sure enough, changing <code>glyphOrder</code> to <code>templateGlyphOrder</code> fixed my script. It now works just as hoped. :)</p>
<p dir="auto">Thanks so much for point out that difference to me!</p>
]]></description><link>https://forum.robofont.com/post/2399</link><guid isPermaLink="true">https://forum.robofont.com/post/2399</guid><dc:creator><![CDATA[StephenNixon]]></dc:creator><pubDate>Wed, 31 Jul 2019 23:44:32 GMT</pubDate></item></channel></rss>