More variable fonts nonsense



  • After a request to add more axes to the previous simple variable fonts tutorial the follow up escalated a bit. Since there are several files I thought it might be better to put them on github.


  • admin

    this is super cool!



  • @frederik thank you!

    There is one 'issue' that makes it difficult to abstract the code. And I was wondering if this could be implemented differently in drawbot.
    when setting the fontVariations the axis tag cannot be a variable:
    fontVariations( axisTag = someValue )

    It would be quite convenient to do:

    myAxis = 'wght' # or whatever
    # ... do some stuff with myAxis
    # ... and then just place the variable name
    fontVariations( myAxis = someValue )
    

    or to just iterate through axes without ever having to type the axistag.


  • admin

    You can convert a dictionary to keyword arguments:

    myVariations = {
        "wght": 100,
        "wdth": 900
    }
    fontVariations(**myVariations)
    

    similar a list/tuple can be converted to a arguments:

    myColor = (1, 0, 1)
    fill(*myColor)
    stroke(*myColor)
    rect(10, 10, 100, 100)
    


  • oh, yes!
    that is of course a very nice solution.
    will update some of the scripts in the next days.
    thanks!


  • admin

    listFontVariations() returns a (ordered) dict that can be adapted and reused as **keyword arguments while applying the font variations.



  • Are you able to run that code in Drawbot? The import from helper_functions doesn’t seem to work (?) @jo



  • @Christine hello!
    I just downloaded the zip from github and did test a few of the scripts in drawbot without any issue. did you change the folder structure and / or do you get an error message? what OS are you using?



  • Hoi 🙂
    I’m using OS 10.13.6, Drawbot says ModuleNotFoundError: No module named 'helper_functions'

    ––– ah, sorry, I just saw that there’s an extra file with the helper functions.


Log in to reply