Features update

RoboFont Forums Help / General Features update

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Thom 8 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4310

    Thom
    Participant

    Hi,

    I’m trying to build a script for my features.
    I open (or make) the features.fea file and write stuff into the file.
    The problem is: it’s not updated in the features UI.
    f.update() doesn’t to the trick.

    Who can help?

    Thanks!

    my sketch:

    f = CurrentFont()
    g = CurrentGlyph()
    
    path = f._get_path() + "/features.fea"
    
    fea = open(path, "w")
    
    liga = "feature liga { \n"
    for g in f:
        if g.name == 'fi':
            liga+= "    sub f i by fi;\n"
        if g.name == 'ffi':
            liga+= "    sub f f i by ffi;\n"
        if g.name == 'fl':
            liga+= "    sub f l by fl;\n"    
    liga += "} liga;\n\n"
    
    fea.write(liga)
    
    fea.close()
    
    #4312

    frederik
    Keymaster

    mm, why would you rewrite the source file?
    RoboFont will see this change only when you jumped to an other application and back to RoboFont.

    But I strongly encourage you not to do it like this :)

    
    f = CurrentFont()
    
    ## get the fea text
    feaText = f.features.text
    
    
    for i in range(100):
        feaText += "# halleluja\n"
    
    f.features.text = feaText
    
    

    ps: also strongly advised: never ever use private callback, private callbacks are callbacks starting with and “_” (underscore) those allows developers to change underlaying API stuff with bothering the top level API.

    so:

    f = CurrentFont()
    print f.path
    

    thanks

    #4313

    Thom
    Participant

    Yes, this is easier and does exactly what I want!

    Thanks Frederik!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.