Quickstart
For more information on how knead works, refer to the user
guide.
Installation
The latest release of knead can be installed from PyPI:
pip install knead
The bleeding edge development branch of knead can be installed from GitHub:
pip install git+https://github.com/font-bakers/knead.git
Usage
On the command line:
knead --input INPUT_FORMAT --output OUTPUT_FORMAT --directory PATH/TO/DATA/
- The
--inputand--outputflags must be one of: ttf: a.ttffont file.ttx: a.ttxXML format of the font. For more details, refer to thefonttoolsdocumentation.json: a.jsonformat of the font.pb: a.pbserialized protobuf format of each glyph in each font.-
npy: a.npyformat of samples from quadratic Bezier curves in each glyph in each font. -
The
--directorymust have the following structure:
data
└── ttf
├── Georgia.ttf
└── ...
In other words, --directory is not the directory containing the .ttf files.
It is a directory that contains a subdirectory (called ttf) containing the
.ttf files.
It is recommended that users organize their data similarly: that is, each directory contains only subdirectories with the same data in various different data formats. In this way, each directory can be semantically associated with a single data set, irrespective of its data format.
As knead does each conversion, a new subdirectory will be made in data/,
each with the corresponding file extension.Ultimately, after .ttf files are
completely converted and sampled to .npy files, the data/ directory will
have the following structure:
data
├── json
│ ├── Georgia.json
│ └── ...
├── npy_with_640_samples
│ ├── Georgia.A_upper.npy
│ ├── Georgia.B_upper.npy
│ ├── Georgia.C_upper.npy
│ └── ...
├── pb
│ ├── Georgia.A_upper.pb
│ ├── Georgia.B_upper.pb
│ ├── Georgia.C_upper.pb
│ └── ...
├── ttf
│ ├── Georgia.ttf
│ └── ...
└── ttx
├── Georgia.ttx
└── ...
In the event of a fatal error during the data preprocessing, knead will simply
catch the exception and write the error message (along with a stack trace) to a
knead.log file.
Optional Flags
Optional flags only matter if certain values are passed for the required flags
(e.g. if --output npy is passed), and always default to some value.
-
--normalize: Whether or not to normalize thexandycoordinates of the control points by the em box size. Pass--normalizeto set to True, and pass--nonormalizeto set to False. Defaults to True. Only relevant if--output jsonis passed. -
--num_samples: The number of samples to evaluate per quadratic Bezier curve. Defaults to 640. Only relevant if--output npyis passed. -
--max_num_points_in_contour: The maximum allowable number of control points per contour. Any glyphs containing contours with more than this number of control points will raise aRuntimeErrorupon conversion. Defaults to 60. Only relevant if--output npyis passed.