Nadav Benedek, Ariel Shamir, Ohad Fried
This repository is the official implementation of: NIV: Neural Axis Variations for Variable Font Generation.
environment.yml: Conda environment specification.code/: Python source files for training and generation.model/: Trained model checkpoint folder (used byttf_to_var.py)dataset_sample/: Sample of the prepared dataset (split files, dataset license, and a small set of XML files). To generate the full dataset, run the two commands in Quick Start:data_get_variable_google_fonts.pydata_prepare_training_data.py
Set up the conda environment. This may take a few minutes.
conda env create -f environment.yml
conda activate niv_envUse this script to clone the Google Fonts repository into google-fonts subdirectory, and extract only variable-font TTF files into google-fonts-variable. This takes a few minutes.
python code/data_get_variable_google_fonts.pyUse this step to convert and preprocess a folder of .ttf fonts into XML training files in the dataset folder. This should take around 15 minutes.
Example:
python code/data_prepare_training_data.py \
--fonts-dir google-fonts-variable \
--out-dir dataset \
--skip-composites \
--normalize-upm \
--only-axes wght,wdth,slnt,opszAlternatively, you can download the prepared dataset from Hugging Face:
pip install -U huggingface_hub
hf download ndvb/NIV \
--repo-type dataset \
--local-dir datasetTrain the model using the dataset directory and the predefined train/test split which is specified in dataset_sample for consistent results. The default argument for best performance is to load dataset into RAM (around 50GB of RAM). You can skip this step and use a trained model.
python code/niv_model_train.py \
--data-dir dataset \
--fixed-split-dir dataset_sample \
--seed 42 \
--output-dir model_output \
--train-loss mse \
--eval-loss mse \
--split-method font \
--eval-steps 20000 \
--only-axes wght,wdth,slnt,opsz \
--epochs 80Evaluate on font-split:
python code/niv_model_train.py \
--data-dir dataset \
--fixed-split-dir dataset_sample \
--load-checkpoint model \
--seed 42 \
--train-loss mse \
--eval-loss mse \
--split-method font \
--only-axes wght,wdth,slnt,opsz \
--only-evalpython code/ttf_to_var.py /path/to/font.ttf --model /path/to/model/best --axes wght,wdth,slnt,opsz --unicode-range 0x20-0x7E --delta-level 4Output is saved next to the source font as *_var.ttf.
If you find this work useful in your research, please consider citing:
@article{benedek2026niv,
title={NIV: Neural Axis Variations for Variable Font Generation},
author={Benedek, Nadav and Shamir, Ariel and Fried, Ohad},
journal={arXiv preprint arXiv:2606.05261},
year={2026}
}