Skip to main content

TorchFont logo

TorchFont: A Machine Learning Library for Vector Fonts

License: MIT Python Version CI Documentation PyPI Downloads PyPI version Rust PyTorch

TorchFont is an unofficial library based on PyTorch for deep learning with vector fonts. It is not affiliated with or endorsed by the PyTorch project.

TorchFont is local-first: point CodepointDataset or GlyphIdDataset at a font directory or a repository checkout that already exists on disk, and TorchFont turns font files into lightweight glyph references. CodepointDataset indexes one sample per face and codepoint, while GlyphIdDataset indexes one sample per face and glyph, reaching ligatures and alternates no codepoint maps to. Load outlines explicitly with LoadGlyph in your transform pipeline when tensors are needed.

Installation

The package requires Python 3.10+ and PyTorch 2.5+.

Install TorchFont with uv:

uv add torchfont

Or with pip:

pip install torchfont

Quickstart

from torch.nn.utils.rnn import pad_sequence
from torch.utils.data import DataLoader

from torchfont import CodepointData, ElementType, Outline
from torchfont.datasets import CodepointDataset
from torchfont.transforms import LoadGlyph


def collate_fn(samples: list[CodepointData[Outline]]):
    outlines = [sample.data for sample in samples]
    return {
        "types": pad_sequence(
            [outline.types for outline in outlines],
            batch_first=True,
            padding_value=ElementType.PAD,
        ),
        "coords": pad_sequence(
            [outline.coords for outline in outlines], batch_first=True
        ),
    }


dataset = CodepointDataset(
    root="~/fonts",  # or "tests/fonts" in this repository
    patterns=("*.ttf",),
    codepoints=range(0x20, 0x7F),  # printable ASCII
    transform=LoadGlyph(),
)

loader = DataLoader(
    dataset,
    batch_size=8,
    shuffle=True,
    collate_fn=collate_fn,
)
batch = next(iter(loader))

print(batch["types"].shape)  # (8, L)
print(batch["coords"].shape)  # (8, L, 6)

What TorchFont Focuses On

  • local font directories and repository checkouts as the input boundary
  • local font indexing by codepoint or by glyph id, plus explicit outline loading through lightweight glyph references
  • torchvision.transforms.v2-style semantic pipelines for adapting glyph samples
  • PyTorch DataLoader integration through an explicit, customizable collate_fn

Manage font repository synchronization with Git or another tool, then point CodepointDataset(root=...) or GlyphIdDataset(root=...) at the resulting directory.

Citing TorchFont

If you find TorchFont useful in your work, please consider citing the following BibTeX entry:

@software{fujioka2025torchfont,
    author = {Fujioka, Takumu},
    title  = {{TorchFont}: A Machine Learning Library for Vector Fonts},
    year   = {2025},
    url    = {https://github.com/torchfont/torchfont}
}

Metadata

Release files for torchfont 0.13.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchfont 0.13.10
File Size Uploaded Provenance Actions
torchfont-0.13.10.tar.gz 3.2 MB Without provenance Details for torchfont-0.13.10.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for torchfont 0.13.10
File Actions
torchfont-0.13.10-cp314-cp314t-win_amd64.whl CPython 3.14 CPython 3.14 free-threading Windows x86-64 Details for torchfont-0.13.10-cp314-cp314t-win_amd64.whl
torchfont-0.13.10-cp314-cp314t-manylinux_2_35_aarch64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.35+ ARM64 Details for torchfont-0.13.10-cp314-cp314t-manylinux_2_35_aarch64.whl
torchfont-0.13.10-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 Details for torchfont-0.13.10-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
torchfont-0.13.10-cp314-cp314t-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 Details for torchfont-0.13.10-cp314-cp314t-macosx_11_0_arm64.whl
torchfont-0.13.10-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for torchfont-0.13.10-cp310-abi3-win_amd64.whl
torchfont-0.13.10-cp310-abi3-manylinux_2_35_aarch64.whl CPython 3.10 abi3 Linux glibc 2.35+ ARM64 Details for torchfont-0.13.10-cp310-abi3-manylinux_2_35_aarch64.whl
torchfont-0.13.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for torchfont-0.13.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
torchfont-0.13.10-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for torchfont-0.13.10-cp310-abi3-macosx_11_0_arm64.whl

Total release size: 27.6 MB

Release files / torchfont-0.13.10.tar.gz

Download URL torchfont-0.13.10.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
031b8f689f7c5b0d9a3e288997e7712d36b85cbe29c2a9cfccdc23d98a631e2b
BLAKE2b-256 checksum
How to use checksums
b4b0c04759df0fea69bffa258999e9e822038ae8104432b96b53a90613758f60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp314-cp314t-win_amd64.whl

Download URL torchfont-0.13.10-cp314-cp314t-win_amd64.whl
Size 2.9 MB
Tags CPython 3.14 CPython 3.14 free-threading Windows x86-64
SHA-256 checksum
How to use checksums
663a36dbca5a9febc7a36eafd89b86ea51f80f705dad8c44e269121fb355179b
BLAKE2b-256 checksum
How to use checksums
e65a78d06742c5d383ccb7d6a8bc1e6226c57bc97a93e5327cc519f75ec36683
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp314-cp314t-manylinux_2_35_aarch64.whl

Download URL torchfont-0.13.10-cp314-cp314t-manylinux_2_35_aarch64.whl
Size 3.8 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.35+ ARM64
SHA-256 checksum
How to use checksums
24d6e343afdee66867f6f8575b6aafddc17f7a66939a04aea8bec90a8ae0f481
BLAKE2b-256 checksum
How to use checksums
9c767f82bb51c4cf20864a921a7483173eb901861359f6887a1a7f458ac222ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL torchfont-0.13.10-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
e6494f3b6f3284be32e7b3d5383b2c339a48aa3fc65d78c72fe07177d1e0562a
BLAKE2b-256 checksum
How to use checksums
943333518ef7b7f6a2f2057e0fb82cfd20ed0ec5332f37ed9ba9dbaf47fb076f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp314-cp314t-macosx_11_0_arm64.whl

Download URL torchfont-0.13.10-cp314-cp314t-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3425b78722bc5ed764a2b1e87ff9bad0517b039bb9850b88cc1be0ffd8771a4e
BLAKE2b-256 checksum
How to use checksums
055d47ae15227ca15945b1ec37a90125ec844a22f644057e6f94d8c867054a68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp310-abi3-win_amd64.whl

Download URL torchfont-0.13.10-cp310-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
b5827709253aad55b4504982c2a961a3c8dab7d4c7ad62a5f43a2cda79d27f48
BLAKE2b-256 checksum
How to use checksums
d8d86a2e9b3de746adc900f96e2ede127861b23fd0d42afce48aa0830e8b6b7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp310-abi3-manylinux_2_35_aarch64.whl

Download URL torchfont-0.13.10-cp310-abi3-manylinux_2_35_aarch64.whl
Size 3.8 MB
Tags CPython 3.10 Linux glibc 2.35+ ARM64 abi3
SHA-256 checksum
How to use checksums
5e372648513edcb46fa1b50b47737fffd636257e25f2b150bd2f55750779d91e
BLAKE2b-256 checksum
How to use checksums
43464e475cf838bf68d1ff7aa7c831ec4ae2645d7c61a6ab34a7ecb625523e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL torchfont-0.13.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
387a0cd17dbed83f95bf27f249efd7b6cfac57b56ee50e4a3913ef6c1ced98a7
BLAKE2b-256 checksum
How to use checksums
69fc7d1b17bd35cddb1bbbc230a8af8a380622601d9c90b6948b4b519a191793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torchfont-0.13.10-cp310-abi3-macosx_11_0_arm64.whl

Download URL torchfont-0.13.10-cp310-abi3-macosx_11_0_arm64.whl
Size 2.5 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
eae424c5101539ecb68128b836a617e19a0d83dc39135de5684b6c16561e2d3c
BLAKE2b-256 checksum
How to use checksums
f9b59e5ea8a8cddc1911273e5cc7d104042c2560ab4d9fd631050fe40ea8914f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for torchfont 0.13.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.13.10 This release

9 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page