torchfont.io.pensΒΆ

Utilities for replaying vector glyphs into dense tensor representations.

Notes

Every stroke recorded by TensorPen is finalized with an explicit end-of-sequence token, which makes batching and masking downstream far less error-prone.

Examples

Capture a glyph as tensors:

pen = TensorPen(glyph_set)
glyph.draw(pen)
types, coords = pen.get_tensor()

Classes

TensorPen(glyph_set)

FontTools pen that records glyph outlines as PyTorch tensors.