# gftools-builder: Config-driven font project builder This utility wraps fontmake and a number of post-processing fixes to build variable, static OTF, static TTF and webfonts from Glyphs, Designspace/UFO or UFO sources, in a way that attempts to bring the outputs close to the [Google Fonts guidelines](https://googlefonts.github.io/gf-guide/). ## Basic builds The builder is driven by a configuration file in the [YAML](https://circleci.com/blog/what-is-yaml-a-beginner-s-guide/) format. By convention, these files are placed in the `sources/` subdirectory of your font repository, and are usually called `config.yaml`. (You can give them different names if you have multiple families in the same repository; `config.yaml` is just a convention. We'll look at building multiple families later.) The most basic configuration file simply tells the builder where to find the font sources: ```yaml sources: - Texturina.glyphs - Texturina-Italic.glyphs ``` To build this font family from the command line, use: ```shell $ gftools builder sources/config.yaml ``` This will then build: * Variable fonts for both sources, placing them in the `fonts/variable` directory; `gftools-fix` will be run on them, and they will have a STAT table build which relates the upright to the italic and vice versa. * All static instances with TrueType outlines, in `fonts/ttf`. These will be autohinted, and `gftools-fix` will be run on them. * All static instances with CFF outlines, in `fonts/otf`. `gftools-fix` will be run on them. * Variable and static TTF WOFF2 webfonts, in `fonts/webfonts`. In other words, the command above will produce 166 different outputs! ## Customizing the basic build process A more complete YAML configuration file for the Texturina family would look like this: ```yaml sources: - Texturina.glyphs - Texturina-Italic.glyphs axisOrder: - opsz - wght outputDir: "../fonts" familyName: Texturina version: 1.005 stat: - name: Width tag: wdth values: - name: UltraCondensed value: 50 ... - name: Weight tag: wght values: - name: Regular value: 400 flags: 2 ... instances: Texturina[wght].ttf: - coordinates: wght: 400 - coordinates: wght: 500 - familyName: "Texturina Exotic" styleName: "Medium" coordinates: wght: 500 ... Texturina-Italic[wght].ttf: - coordinates: wght: 700 ... vttSources: Texturina[wght].ttf: vtt-roman.ttx Texturina-Italic[wght].ttf: vtt-italic.ttx ... ``` The build can be customized by adding the following keys to the YAML file: - `sources`: Required. An array of Glyphs, UFO or designspace source files. - `logLevel`: Debugging log level. Defaults to `INFO`. - `stat`: A STAT table configuration. This may be either a list of axes and values as demonstrated above, or a dictionary mapping each variable font to a per-source list. If neither `stylespaceFile` or `stat` are provided, a STAT table is generated automatically using `gftools.stat`. The Flags key's values are explained in the [OpenType spec](https://learn.microsoft.com/en-us/typography/opentype/spec/stat#flags). - `instances`: A list of static font TTF instances to generate from each variable font as demonstrated above. If this argument isn\'t provided, static TTFs will be generated for each instance that is specified in the source files. - `buildVariable`: Build variable fonts. Defaults to true. - `buildStatic`: Build static fonts (OTF or TTF depending on `$buildOTF` and `$buildTTF`). Defaults to true. - `buildOTF`: Build OTF fonts. Defaults to true. - `buildTTF`: Build TTF fonts. Defaults to true. - `buildWebfont`: Build WOFF2 fonts. Defaults to `$buildStatic`. - `outputDir`: Where to put the fonts. Defaults to `../fonts/` - `vfDir`: Where to put variable fonts. Defaults to `$outputDir/variable`. - `ttDir`: Where to put TrueType static fonts. Defaults to `$outputDir/ttf`. - `otDir`: Where to put CFF static fonts. Defaults to `$outputDir/otf`. - `woffDir`: Where to put WOFF2 static fonts. Defaults to `$outputDir/webfonts`. - `cleanUp`: Whether or not to remove temporary files. Defaults to `true`. - `autohintTTF`: Whether or not to autohint TTF files. Defaults to `true`. - `autohintOTF`: Whether or not to autohint OTF files. Defaults to `false`. - `ttfaUseScript`: Whether or not to detect a font\'s primary script and add a `-D