Official implementation of CoDeFont
Project Website · GitHub Repository
One-shot Font Generation (OFG) aims to synthesize a target glyph by transferring the stylistic characteristics of a single reference glyph while preserving the structure of the target character. However, accurately capturing font style from a single reference image remains challenging due to the limited stylistic information available in a single glyph, and this challenge is further amplified for complex scripts. We propose CoDeFont, a script-agnostic OFG framework that addresses this challenge through multi-level style-content factorization and progressive style-content reconciliation. CoDeFont independently aggregates complementary style and structural information across multiple spatial levels to obtain factor-specific representations, while a contrastive objective explicitly encourages separation between style and content embeddings. During reconstruction, the disentangled representations are progressively injected through multi-level style conditioning, enabling stylistic information to be incorporated at different decoding resolutions while preserving the underlying glyph structure. We evaluate CoDeFont on structurally distinct Bengali and Latin scripts across seen and unseen font styles. Extensive quantitative and qualitative analyses demonstrate consistent improvements over existing state-of-the-art methods, highlighting the effectiveness of the proposed framework for OFG across diverse writing systems.
Qualitative comparison of generated results. Replace this placeholder with the actual experimental figure.
Additional examples and comparisons.
Note: The image paths above are proposed locations for figures. Add the corresponding image files to
docs/before using these sections.
CoDeFont/
├── dataloader/ # Data loading and preprocessing
├── docs/ # Documentation and figures
├── losses/ # Loss functions
├── models/ # Model and network components
├── scripts/ # Training and inference Python modules
├── train.sh # Training entry point
├── infer.sh # Inference entry point
├── LICENSE # License information
└── README.md # Project documentation
| File | Purpose |
|---|---|
train.sh |
Start model training |
infer.sh |
Run inference using trained checkpoints |
scripts/train.py |
Training implementation invoked through python -m scripts.train |
scripts/infer.py |
Inference implementation invoked through python -m scripts.infer |
dataloader/ |
Data-loading components used by the pipeline |
models/ |
Model architecture and network components |
losses/ |
Training objectives and loss implementations |
docs/ |
Documentation and visual assets |
The Python module paths shown above follow the launch commands in the shell scripts.
Clone the repository:
git clone https://github.com/rejoycs/codefont.git
cd codefontCreate and activate a Python environment, then install the dependencies required by the implementation.
conda create -n codefont python=3.10
conda activate codefontInstall a compatible PyTorch build for your CUDA environment, followed by the project's Python dependencies.
The training and inference scripts expect language-specific directories.
For example, the launchers construct paths using:
Dataset_bengali/
results_bengali/
results_bengali_out/
ckpt/
Prepare the dataset in the format expected by the data-loading implementation before running the scripts. Check the dataset configuration and preprocessing code for the required directory structure and image format.
The repository provides train.sh as the main training entry point.
bash train.shTo specify another language:
bash train.sh englishThe script invokes scripts.train with the following configured parameters:
- Batch size:
64 - Embedding dimension:
64 - Image size:
64 × 64 - Epochs:
500 - Device:
cuda:0 - Test interval:
1
Training checkpoints are configured under ckpt/, with separate paths for the style encoder, content encoder, decoder, and discriminator.
Use infer.sh to generate results using trained model checkpoints.
bash infer.shTo run inference for another language:
bash infer.sh englishThe script invokes scripts.infer and reads the configured style encoder, content encoder, and decoder checkpoints.
By default, the output directory is:
results_bengali_out/
For another language, the output directory follows the pattern results_<language>_out/.
Important: Run inference only after the required model checkpoints are available at the paths expected by infer.sh. Verify that the dataset and checkpoint paths match your local setup.
The current shell scripts define the primary execution parameters. To change the default language, batch size, embedding dimension, image size, checkpoint locations, or device, edit train.sh or infer.sh as appropriate.
For a different GPU, update the --DEVICE argument. For CPU execution, first confirm that the underlying implementation supports CPU inference and training.
If you use CoDeFont in your research, please cite the associated paper.
@misc{chakraborty2026codefontoneshotfontgeneration,
title={CoDeFont: One-Shot Font Generation via Multi-Scale Factor-Specific Representation Learning},
author={Rejoy Chakraborty and Prasun Roy and Saumik Bhattacharya and Umapada Pal},
year={2026},
eprint={2610.21364},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2610.21364},
}Please refer to the official project website for project information.
This project is distributed under the Apache License 2.0. See LICENSE for details.


