Search code examples
svgfontsfont-facefont-awesomefontforge

Is it possible to create fonts (TTF) from SVGs from the command line?


I have a set of SVGs I want to turn into a font (TTF) - but it has to be done in an automated fashion - is this possible?

It seems as though fontforge, etc all require some human interaction.


Solution

  • It is possible with fontforge:

    import fontforge
    
    # create an empty font in memory
    font = fontforge.font()
    
    # Create a char in the unicode 41 pos (an "A")
    glyph = font.createChar(41, 'A')
    
    # Import the glyph info
    glyph.importOutlines('/path/to/svg/foo.svg')
    
    # Write the font from memory to a TTF file
    font.generate('/output/math/foo.ttf')