torchfont.datasets.folderΒΆ

Font folder dataset utilities for glyph loading and indexing.

Examples

Iterate glyph samples from a directory of fonts:

from torchfont.datasets import FontFolder
dataset = FontFolder(root="~/fonts")
sample, target = dataset[0]
Guidance:

Fonts are cached by absolute path to limit redundant disk access during dataset iteration.

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.