FontGPT logo

fontgpt v2.5

A 168.6M-parameter decoder-only transformer that draws font glyphs as Bézier outlines: show it a few glyphs from a TTF or OTF and it draws others in that style.

The successor to fontgpt v2. This release uses the final EMA weights from the v3 training run.

Quick start

Tested with Python 3.12 and PyTorch 2.15 (CPU).

hf download tenzer0/fontgpt-v2.5 --local-dir fontgpt-v2.5
cd fontgpt-v2.5
pip install -r requirements.txt
python generate.py --font some.ttf --refs "HOno" --glyphs "abcdefg" --out out/ --compare --ttf
  • Input: --font (TTF/OTF), --refs (characters with outlines in that font; default Hoag), --glyphs (characters to draw). Varied reference letters usually convey more about the style than similar ones.
  • Output: specimen.png, one U+XXXX.svg per drawn glyph, and optionally generated.ttf (--ttf). --compare adds the input font’s original glyphs to the specimen where available.
  • Decoding: --decode median (default) uses the median of the coordinate distribution within the chosen structural role; other tokens use the top prediction. --decode greedy uses the top prediction throughout. --temperature 0.8 samples instead; set --seed for reproducibility. Also --device cpu|cuda|auto, --batch, and --max_tokens (default 900 per glyph).
  • If fontgpt_v2.5.pt is not beside generate.py, the CLI downloads it from the release repo.

What's in the repo

File What
fontgpt_v2.5.pt Inference weights from the v3 EMA at step 72,600, unchanged from the graded checkpoint. Contains model and data configs, tokenizer metadata and source IDs; no optimizer state.
config.json Step, parameter count, and model and data configs.
generate.py Inference CLI: read references and write PNG, SVG and optional TTF.
code/ Model, structured outline2 tokenizer, and batched grammar-constrained decoder. code/COMMIT records the source revision.
requirements.txt Python dependencies.
assets/ Logo and benchmark charts.

Improvements, differences and fixes

Compared with v2:

  • Improvements: letters draw better (FE64 letters, median decode: 0.632 vs 0.618), and the teacher-forced loss on held-out fonts is lower for every glyph class. With up to 12 reference glyphs it recovers much of the all-glyph gap below.
  • Differences: a structured outline2 tokenizer (vocabulary 3,714; token IDs incompatible with v2); 18 layers, 168.6M parameters; three times longer (72,600 steps, about 10.3B tokens); 22 data banks (361,334 fonts); ships the final EMA.
  • Fixes: 13,385 more near-copies of evaluation fonts dropped; an untested stretch-and-nudge augmentation removed; fonts the outline converter used to lose recovered.
  • Weaker: all glyphs, FE64 median 0.5275 to 0.4216: digits and punctuation often never end (95% of digits and 59% of punctuation under greedy) and draw a repeated watermark-like outline. v2.6 fixes this.

Results

FE64: strict mean shape IoU by release

Made-8: strict mean shape IoU by release

Panel: strict mean shape IoU by release

Bars use strict shape IoU at each release’s default benchmark decode. The published v1 and v1 RL results use greedy; their legacy CLI samples by default.

Held-out drawings

FE64 uses the same 5,758 target glyphs from 64 held-out fonts for all three versions. Shape IoU compares each outline with the input font’s glyph without position alignment (higher is better); failed or budget-forced draws score zero. The saved v1.5 and v2 grades used judge j1; v2.5 used j2r.

Strict mean shape IoU, four references v1.5 v2 v2.5 v2.5 vs v2
Greedy 0.5003 0.5177 0.4107 −0.1069
Median (default) 0.5109 0.5275 0.4216 −0.1059

With four references, v2.5 improves on letters but loses ground on digits and symbols. Giving v2.5 up to 12 reference glyphs per target recovers much of the overall gap.

Pretraining

Training and test loss over training steps for v1.5, v2 and v2.5

v1.5 and v2 use the same tokenizer and held-out test glyphs. v2.5 uses a different tokenizer, so its per-token loss is shown separately on the same training-step axis.

Training

  • Model: 18 layers, width 768, 12 query heads and 3 key/value heads, SwiGLU, U-Net skips, attention gates, a character-label embedding, and one cross-attention layer. Context window: 2,560 tokens; vocabulary: 3,714.
  • Tokenizer: structured outline2 with a 1/128-em grid, full coordinate range, and no learned token merges. Token IDs are not compatible with v2.
  • Schedule: 72,600 steps at a nominal 142,400 tokens per step (about 10.3B tokens at that budget), with linear learning-rate decay over the final 60%. NorMuon for matrix parameters and AdamW for the rest; EMA decay 0.9995.
  • Data: 361,334 fonts in the manifest across 22 outline banks, with near-copies of evaluation fonts excluded. Most training sequences put reference letters first.
  • Training and judge code: acb149e43a8576b596e7ebd052f3204d4b5134f8.

Limitations

  • Digits and punctuation can turn into repeated watermark-like outlines. Use v2 if you need reliable non-letter glyphs.
  • The tokenizer covers ASCII ! to ~ only. No accented characters or other scripts.
  • Complex glyphs can exhaust the decode budget. Long reference sets must leave room in the 2,560-token window. The CLI flags budget-constrained or incomplete output.
  • Variable fonts are read at their default instance. Glyphs are generated individually; there is no kerning or hinting.

Versions

Version Where Tokenizer Notes
v1 tenzer0/fontgpt-v1 pen walk first release
v1 RL tenzer0/fontgpt-v1, fontgpt_v1_rl.pt pen walk v1 with rendered-shape reward training
v1.5 tenzer0/fontgpt-v1.5 outline2 native Bézier outlines
v2 tenzer0/fontgpt-v2 outline2 stronger all-ASCII completion than v2.5
v2.5 this repo structured outline2 final v3 EMA; stronger letters, weaker digits and punctuation
v2.6 tenzer0/fontgpt-v2.6 pen walk + HOP best held-out drawings of the pretrained releases
Downloads last month
60
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support