Generating trial fonts ↩
Many designers and foundries like to offer trial versions of their fonts. Such fonts are often limited versions of the complete fonts, with a reduced character set and/or with a reduced set of features.
The FontToolsAn open-source library for manipulating font files with Python. module includes a very powerful subsetter which can be used to generate trial fonts. It provides several options to remove data from a font – from removing glyphs to OpenType features, kerning, hinting, font names, etc.
Using the subsetter in a script
RoboFont comes with FontTools as an embedded module, so you can use it in any script.
The example script below does the following:
- open a dialog to select an existing UFO font
- generate a complete OpenType font from the UFO
- close the font without saving any changes
- generate a trial font by subsetting the complete font
- remove the complete font
from fontTools import subset font = OpenFont() fullPath = font.path.replace('.ufo', '_Full.otf') trialPath = font.path.replace('.ufo', '_Trial.otf') # generate full otf font.info.familyName += ' Trial' font.generate(path=fullPath, format='otf', decompose=True, checkOutlines=True, releaseMode=True) font.close() # subset full otf options = subset.Options() # print(dir(options)) font = subset.load_font(fullPath, options) subsetter = subset.Subsetter(options) subsetter.populate(text='ABCDXYZ abcdxyz') subsetter.subset(font) subset.save_font(font, trialPath, options) # delete full otf import os os.remove(fullPath) # open generated trial font in UI to check OpenFont(trialPath)
Using the subsetter in Terminal
If FontTools is installed in the system Python, the subsetter is also available in Terminal as the command line tool
pyftsubset myFolder/myFont.otf --text='ABCDXYZ abcdxyz'
See the included
--help for more information about each option.