SOLVED Generate font with limited character set

  • Hi,

    I'm new to RoboFont so this might be an easy to solve question. I just don't know how to do it...

    I'm working on a font with three alternate glyph sets for every uppercase character, managed as stylistic sets in the OpenType font (set 1, 2 and 3). Users who know how to use OpenType fonts can play with the stylistic alternates as they like.

    But I would like to generate a second version of the font for users that don't want or don't know how to use the OpenType features (f.e. people that use the font in Word). In that version, all uppercase characters should be replaced with the alternate designs from set 1. All other stylistic alternates (also set 2 and 3) can be deleted in this version.

    How can I generate these two fonts (the OpenType with all alternates and the one-option-version) from the same UFO?

    All help very much appreciated!


  • admin

    @pieterpjotr super enjoy!!

  • Thanks Frederik! This script does exactly what I was looking for.

  • admin

    He Pieter

    a script could help you out:

    # get the current font
    font = CurrentFont()
    # make a copy of it
    destFont = font.copy()
    # make a list of glyphs to swap
    # this could be built automatically if a fixed glyph naming pattern is used
    glyphsToSwap = [
       ("A", "A.alt"), 
       ("B", "B.alt"),
    # loop over all pairs of glyphs to swap
    for dest, source in glyphsToSwap:
        # get the glyph objects with those names
        destGlyph = destFont[dest]
        sourceGlyph = destFont[source]
        # insert them in the destination font
        destFont.insertGlyph(sourceGlyph, dest)
        destFont.insertGlyph(destGlyph, source)
    # generate the font
        format="otf",                            # in .otf format
        path=font.path.replace(".ufo", ".otf"),  # into the same folder
        checkOutlines=True,                      # with remove overlap
        decompose=True,                          # and decompose 

    Maybe you want to swap them in kerning and kern groups too...

    This script allows you to keep the existing feature file.

    good luck!