SOLVED Can't open UFO: ValueError



  • Hi Robofont forum!
    I'm new to the game so this might be a very basic question:
    I'm trying to open a .UFO font exported from Glyphs but Robofont won't accept its format. The error displayed in output is:

    Can't open UFO: ValueError Invalid value ('1') for attribute postscriptBlueFuzz.

    Can anybody help me understand what the problem is here?
    Thanks in advance!


  • admin

    No idea, I guess it is a bug in Glyphs...



  • First of all, thank you very much for the fast reply! Both solutions work perfectly.
    To answer @frederik's question: I generated the UFO myself from a font made from scratch in Glyphs. Any idea what parameter or option I could have set wrong to get string instead of integer?



  • @Morula-Type you can also fix the XML in fontinfo.plist by hand:

    • open the UFO package in Finder (right click + Show Package Contents)
    • open the file fontinfo.plist in a code editor
    • look for <key>postscriptBlueFuzz</key>
    • in the line below, replace the <string> tag with <integer>:
      <string>1</string>
      <integer>1</integer>

    this approach can help you understand how the UFO format works. if you need to do it multiple times, use the script :)

    cheers!


  • admin

    He Morula Type!!!

    the UFO has a string (text) entry for the postscriptBlueFuzz info value. Which is not allowed. This value must be a integer or a float.

    This is not good, where did you get the UFO from?

    run this inside RoboFont to get it fixed!

    enjoy

    from fontParts.ui import GetFile
    
    # get the path to the file
    path = GetFile()
    print("fixing ufo:", path)
    
    # import the ufo reader/writer
    from fontTools.ufoLib import UFOReaderWriter
    
    # create a dummy simple info class to store the info
    
    class SimpleInfo(dict):
        
        def __setattr__(self, key, value):
            self[key] = value
        
        def __getattr__(self, key):
            return self.get(key, None)
        
    # if we have a path 
    if path:
        # read the ufo, but dont validate
        reader = UFOReaderWriter(path, validate=False)
        # create a info object
        info = SimpleInfo()
        # read the info from the ufo
        reader.readInfo(info)
        # change the postscriptBlueFuzz to an integer
        info.postscriptBlueFuzz = int(info.postscriptBlueFuzz)
        # write it back into the ufo
        reader.writeInfo(info)
    
    # DONE!
    

Log in to reply