<?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[Renaming the glyph problem]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm renaming all glyphs in CurrentFont based on <code>glyphNameFormatter.reader.u2n</code>.</p>
<p dir="auto">To do that I'm using <code>RFont.rename(oldname,newname)</code> script. After a few months of using this code, I have the following throwback (so far I saw it only on one, healthy-looking ufo):</p>
<pre><code class="language-console">File "unicodeStuff.py", line 57, in doit
  File "lib/fontObjects/fontPartsWrappers.pyc", line 1649, in renameGlyph
  File "lib/fontObjects/fontPartsWrappers.pyc", line 1318, in renameGlyph
  File "lib/fontObjects/doodleLayer.pyc", line 181, in renameGlyph
  File "/Applications/TypeDesign/RoboFont3.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 262, in __getitem__
  File "lib/fontObjects/doodleLayer.pyc", line 58, in loadGlyph
  File "/Applications/TypeDesign/RoboFont3.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 179, in loadGlyph
KeyError: 'uni2611 not in layer'
</code></pre>
<p dir="auto">I was trying everything, I have rewritten the script with a different slightly approach over five times. It throws the same message, with around five different glyphs that throw an error (it depends on the version of my script).</p>
<p dir="auto">I cannot find the issue in the font.</p>
<p dir="auto">Before the running script, the glyph that causes the error exists in the font. Later it eighter completely disappear, or if I write its name in the search console, the RF crashes.</p>
<p dir="auto">Any suggestions?</p>
]]></description><link>https://forum.robofont.com/topic/624/renaming-the-glyph-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 11 Aug 2026 12:24:05 GMT</lastBuildDate><atom:link href="https://forum.robofont.com/topic/624.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Apr 2019 00:10:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Renaming the glyph problem on Thu, 18 Apr 2019 09:58:01 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm renaming all glyphs in CurrentFont based on <code>glyphNameFormatter.reader.u2n</code>.</p>
<p dir="auto">To do that I'm using <code>RFont.rename(oldname,newname)</code> script. After a few months of using this code, I have the following throwback (so far I saw it only on one, healthy-looking ufo):</p>
<pre><code class="language-console">File "unicodeStuff.py", line 57, in doit
  File "lib/fontObjects/fontPartsWrappers.pyc", line 1649, in renameGlyph
  File "lib/fontObjects/fontPartsWrappers.pyc", line 1318, in renameGlyph
  File "lib/fontObjects/doodleLayer.pyc", line 181, in renameGlyph
  File "/Applications/TypeDesign/RoboFont3.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 262, in __getitem__
  File "lib/fontObjects/doodleLayer.pyc", line 58, in loadGlyph
  File "/Applications/TypeDesign/RoboFont3.app/Contents/Resources/lib/python3.6/defcon/objects/layer.py", line 179, in loadGlyph
KeyError: 'uni2611 not in layer'
</code></pre>
<p dir="auto">I was trying everything, I have rewritten the script with a different slightly approach over five times. It throws the same message, with around five different glyphs that throw an error (it depends on the version of my script).</p>
<p dir="auto">I cannot find the issue in the font.</p>
<p dir="auto">Before the running script, the glyph that causes the error exists in the font. Later it eighter completely disappear, or if I write its name in the search console, the RF crashes.</p>
<p dir="auto">Any suggestions?</p>
]]></description><link>https://forum.robofont.com/post/2269</link><guid isPermaLink="true">https://forum.robofont.com/post/2269</guid><dc:creator><![CDATA[RafaŁ Buchner]]></dc:creator><pubDate>Thu, 18 Apr 2019 09:58:01 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Thu, 18 Apr 2019 07:31:36 GMT]]></title><description><![CDATA[<p dir="auto">do you have an example script that causes this issue?</p>
]]></description><link>https://forum.robofont.com/post/2271</link><guid isPermaLink="true">https://forum.robofont.com/post/2271</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Thu, 18 Apr 2019 07:31:36 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Sat, 20 Apr 2019 11:13:39 GMT]]></title><description><![CDATA[<p dir="auto">ofcourse</p>
<pre><code>from glyphNameFormatter.reader import u2n, n2u, u2U
def getNameFromUnicode(g):
    name = u2n(g.unicode)
    return name
    
def doit(font):
    renamingDict = {}
    for glyph in font:
        old_name = glyph.name
        new_name = getNameFromUnicode(glyph)

        if new_name is None:
            continue
        else:
            if new_name not in renamingDict.keys():
                if new_name != old_name:
                    renamingDict[old_name] = new_name
                for glyph2 in font:
                    if glyph2.name.split(".")[0] == old_name:
                        old_name2 = glyph2.name
                        new_name2 = glyph2.name.replace(old_name,new_name)
                        if new_name2 not in renamingDict.keys():
                            if new_name2 != old_name2:
                                renamingDict[old_name2] = new_name2
    reducedRenamingDictKeys = list(set(list(renamingDict.keys())))
    
    for old in reducedRenamingDictKeys:
        if old in font.keys():
            glyph = font[old]
            if len(glyph.contours) != 0:
                font.renameGlyph(old,renamingDict[old])
                for glyph2 in font:
                    for comp in glyph2.components:
                        if comp.baseGlyph == old:
                            comp.baseGlyph = renamingDict[old]
    for old in reducedRenamingDictKeys:
        
        glyph = font[old]
        if len(glyph.contours) == 0:
    
            font.renameGlyph(old,renamingDict[old])
            for glyph2 in font:
                for comp in glyph2.components:
                    if comp.baseGlyph == old:
                        comp.baseGlyph = renamingDict[old]
    
font = CurrentFont()
doit(font)
</code></pre>
]]></description><link>https://forum.robofont.com/post/2273</link><guid isPermaLink="true">https://forum.robofont.com/post/2273</guid><dc:creator><![CDATA[RafaŁ Buchner]]></dc:creator><pubDate>Sat, 20 Apr 2019 11:13:39 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Sat, 20 Apr 2019 15:30:20 GMT]]></title><description><![CDATA[<p dir="auto">When renaming a glyph (line 32) the old glyph name does not exist anymore (line 38).</p>
<p dir="auto">(side note: <code>keys()</code> from a dictionary are always unique, see line 25)</p>
]]></description><link>https://forum.robofont.com/post/2274</link><guid isPermaLink="true">https://forum.robofont.com/post/2274</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Sat, 20 Apr 2019 15:30:20 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Sat, 20 Apr 2019 15:42:40 GMT]]></title><description><![CDATA[<p dir="auto">removing the renaming 'old' glyph name from your <code>reducedRenamingDictKeys</code> list, on the first rename, will help</p>
]]></description><link>https://forum.robofont.com/post/2275</link><guid isPermaLink="true">https://forum.robofont.com/post/2275</guid><dc:creator><![CDATA[frederik]]></dc:creator><pubDate>Sat, 20 Apr 2019 15:42:40 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Tue, 23 Apr 2019 15:04:10 GMT]]></title><description><![CDATA[<p dir="auto">shit, it was much easier than I thought,<br />
I should feel a bit ashamed. Thanks</p>
]]></description><link>https://forum.robofont.com/post/2277</link><guid isPermaLink="true">https://forum.robofont.com/post/2277</guid><dc:creator><![CDATA[RafaŁ Buchner]]></dc:creator><pubDate>Tue, 23 Apr 2019 15:04:10 GMT</pubDate></item><item><title><![CDATA[Reply to Renaming the glyph problem on Mon, 22 Jul 2019 21:32:13 GMT]]></title><description><![CDATA[<p dir="auto">This post was helpful to me – thanks <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/207">@RafaŁ-Buchner</a> and <a class="plugin-mentions-user plugin-mentions-a" href="https://forum.robofont.com/uid/1">@frederik</a>!</p>
<p dir="auto">It took me a bit to get everything working, so I thought I'd post my updates here for the next person who needs it.</p>
<pre><code># a script to find glyphs with unicode names and give them human-readable names
# started from https://forum.robofont.com/topic/624/renaming-the-glyph-problem/6


from glyphNameFormatter.reader import u2n, n2u, u2U
from vanilla.dialogs import *
import pprint

def updateGlyphName(f):
    f.features.text = feaText


def getNameFromUnicode(g):
    name = u2n(g.unicode)
    return name


def getReadableNames(font):
    renamingDict = {}
    for glyph in font:
        old_name = glyph.name

        if "uni" in old_name:  # and "." not in old_name:
            new_name = getNameFromUnicode(glyph)

            if new_name is None:
                continue
            else:
                if new_name not in renamingDict.keys():
                    if new_name != old_name:
                        renamingDict[old_name] = new_name
                    for glyph2 in font:
                        if glyph2.name.split(".")[0] == old_name:
                            old_name2 = glyph2.name
                            new_name2 = glyph2.name.replace(old_name, new_name)
                            if new_name2 not in renamingDict.keys():
                                if new_name2 != old_name2:
                                    renamingDict[old_name2] = new_name2
    pprint.pprint(renamingDict)
    renamingDictKeys = list(renamingDict.keys())

    for old in reversed(renamingDictKeys):
        if old in font.keys():
            glyph = font[old]
            if len(glyph.contours) != 0:
                font.renameGlyph(old, renamingDict[old])
                print("\t", old, "→", renamingDict[old])
                for glyph2 in font:
                    for comp in glyph2.components:
                        if comp.baseGlyph == old:
                            comp.baseGlyph = renamingDict[old]

                renamingDictKeys.remove(old)

    for old in reversed(renamingDictKeys):
        glyph = font[old]
        if len(glyph.contours) == 0:
            font.renameGlyph(old, renamingDict[old])
            print("\t", old, "→", renamingDict[old])
            for glyph2 in font:
                for comp in glyph2.components:
                    if comp.baseGlyph == old:
                        comp.baseGlyph = renamingDict[old]

# allows you to select one or multiple UFOs

inputFonts = getFile(
    "select UFOs", allowsMultipleSelection=True, fileTypes=["ufo"])

for fontPath in inputFonts:
    # set showInterface to True if you wish to see the font window
    f = OpenFont(fontPath, showInterface=False)

    print("----------------------------------\n")
    print("----------------------------------\n")
    print(f.path, "\n")
    print("----------------------------------\n")

    getReadableNames(f)

    # comment these out to test run
    f.save()
    f.close()

</code></pre>
]]></description><link>https://forum.robofont.com/post/2539</link><guid isPermaLink="true">https://forum.robofont.com/post/2539</guid><dc:creator><![CDATA[StephenNixon]]></dc:creator><pubDate>Mon, 22 Jul 2019 21:32:13 GMT</pubDate></item></channel></rss>