SOLVED Copy selected layers to new font

  • Hi, new to RF and scripting; this is probably a simple question because I can't find it addressed anywhere (or I'm framing the question wrong):

    I have a master version of my modular script Kast with all the layers needed to build its various versions:

    Screen Shot 2019-11-16 at 6.34.33 AM.png

    I'd like to selectively export its layers to new fonts (top right, top left, left right, etc.). I can get the master's layers names, create a new font, but I can't figure out the next steps. Even just a nudge with the proper methods would be appreciated.

  • @gferreira I think those were the clues I needed—thanks!

  • hello @MauriceMeilleur,

    if I understand it correctly, you would like to make individual styles by combining some of the layers?

    if so, have a look at Boolean Glyph Math. you can get individual glyph layers with glyph.getLayer(layerName).

    hope this helps, good luck!

  • Thanks, Frederik! But my goal is to generate fonts from different combinations of layers from the master.

    So the ideal pseudocode would read like this (I think), for example to create a font with the top-facing sides in the virtual cubes in my design:

    font1 = master UFO with all layers
    font2 = new font with one layer
    for layer in font1:
         if layer name = top or top_background:
              for each glyph in layer:      
                   copy paths in glyph to corresponding glyph in font2
         else pass

  • admin

    Do you need each layer as a separate UFO? if so you can export each glyph to a new font object and work from there

    if not:

    You can generate manually with the generate menu item and select a specific layer.

    or for now:

    import os
    destRoot = 'root/folder/to/store/binaryFont'
    font = CurrentFont()
    for layer in font.layers:
        layerName =
        path = os.path.join(destRoot, f"{layerName}-{}-{}.otf")
        # the naked layer object has a separate generate api
        layer.naked().generate(path=path, format="otf")

    This will move in future version to font.generate(..., layerName="background") where the layerName argument will selecte a specific layer.

    hope this helps