torchfont.datasets.folderΒΆ

Utilities for turning local font folders into indexed glyph datasets.

Notes

Fonts are cached by absolute path to minimize redundant disk access during dataset iteration, so edits on disk require an explicit cache clear.

Examples

Iterate glyph samples from a directory of fonts:

from torchfont.datasets import FontFolder

dataset = FontFolder(root="~/fonts")
sample, target = dataset[0]

Functions

default_loader(file, instance_index, codepoint)

Convert a glyph outline to tensor representations.

load_font(file)

Load a font file and cache the resulting TTFont instance.

Classes

FontFolder(root, *[, codepoint_filter, ...])

Dataset that yields glyph samples from a directory of font files.