Interpolate script



  • Hello all,
    Not sure if this is Robofab or Robofont related:
    When I try to run this script (grabbed from robofab.com) :

    # robothon 2009
    # interpolate two glyphs in the same font a bunch of times
    from robofab.world import CurrentFont
    f = CurrentFont()
    for i in range(0, 10):
        factor = i * .1
        name = "result_%f" % factor
        print "interpolating", name
        f[name].interpolate(factor, f["A"], f["B"])
    f.update()
    

    I get this error:

    interpolating result_0.000000
    Traceback (most recent call last):
      File "", line 9, in 
      File "lib/fontObjects/robofabWrapper.pyc", line 3173, in __getitem__
      File "lib/fontObjects/robofabWrapper.pyc", line 3180, in getGlyph
    RoboFontError: Glyph result_0.000000 not in font.</code>
    

    Any idea why? Since it says "Robofont Error"… I might as well ask here :)



  • thank you!


  • admin

    you are asking the font for a glyph that doesn't exist

    # robothon 2009
    # interpolate two glyphs in the same font a bunch of times
    from robofab.world import CurrentFont
    f = CurrentFont()
    for i in range(0, 10):
        factor = i * .1
        name = "result_%f" % factor
        print "interpolating", name
    
        # create a new glyph
        f.newGlyph(name, clear=True)
    
        f[name].interpolate(factor, f["A"], f["B"])
    f.update()
    

    good luck