Learning to Generate Stylized Handwritten Text via a Unified Representation of Style, Content, and Noise

Honglie Wang, Yan-Ming Zhang, Wangzi Yao, Fei Yin, Cheng-Lin LiuICLR 2026

TL;DR

InkSpire is a novel diffusion transformer model for handwritten text generation (HTG) that unifies style, content, and noise into a single shared latent space, eliminating the need for complex, separate encoders. By training directly on raw multi-line images using a masked infilling strategy, it achieves state-of-the-art bilingual (English and Chinese) handwriting synthesis and enables highly realistic, fine-grained text editing.

What Problem Does This Paper Address?

Handwritten Text Generation aims to synthesize realistic handwriting that mimics a specific person's unique style—such as slant, stroke thickness, and cursiveness—based on a digital text input.

Recently, diffusion models have dominated this space, but they typically rely on a fragmented architecture. They use separate, dedicated encoders to process the "style" (a reference image of the handwriting) and the "content" (the text to be written). This separation requires complex training pipelines and handcrafted loss functions to force the different features to interact.

Comparison of HTG architectures

Furthermore, standard preprocessing often involves cropping and resizing single lines of text to a fixed height. This distorts highly slanted writing and completely destroys "inter-line" style cues—the natural way a person's handwriting flows from one line to the next.

Methods

The authors propose InkSpire, an encoder-less framework that treats handwriting generation as an "in-context" image editing task.

  • Unified Latent Space: Instead of using separate encoders, InkSpire takes the raw handwritten image and spatially concatenates it with a "content image" (the target text rendered in a standard font). Both are compressed through a single pre-trained Variational Autoencoder (VAE) into a shared latent space.
  • Multi-Line Masked Infilling: During training, the model looks at a large patch of a multi-line handwritten page. A random mask hides parts of the text. The unmasked regions act as the "style reference," and the model learns to denoise and infill the masked regions based on the standard-font content image.
  • Layout Generation via CFM: Before generating the final image, InkSpire uses a Conditional Flow Matching (CFM) model to predict the layout (bounding boxes) for each character, ensuring the text is spaced naturally before the image generation phase begins.
Absolute vs. Relative Layout Representation
  • Rotated Aligned Position Encoding (R-APE): Because the model concatenates the standard-font image and the handwritten image, standard positional encodings get confused on long text lines. R-APE is a custom positional encoding scheme that explicitly aligns the standard-font tokens with their corresponding target handwritten tokens, improving structural accuracy.
  • Architecture: The core image generator is built on the pre-trained FLUX.1-Fill-dev diffusion transformer, fine-tuned using Low-Rank Adaptation (LoRA).

Key Insights and Ideas

  • Encoders are a Bottleneck: Ditching dedicated style and content encoders actually improves performance. By feeding everything into a single diffusion transformer, the model naturally learns richer interactions between what the text says and how it should look, without needing manually designed loss functions.
  • Context is King for Style: Training on raw, multi-line patches rather than isolated, resized lines is crucial. It preserves the natural scale of the handwriting and allows the model to learn inter-line consistency, preventing the "printed font" look that plagues models trained on heavily compressed single lines.
  • Bilingual Synergy: A single unified model can master both phonemic (English) and logographic (Chinese) writing systems simultaneously. The shared latent space is robust enough to handle the vastly different structural rules of both languages.

Key Results

InkSpire significantly outperforms prior state-of-the-art models (like One-DM, DiffPen, and TGC-Diff) across both languages:

  • English (IAM dataset): Achieved a Frechet Inception Distance (FID) of 7.92 (down from DiffPen's 12.89) and a Kernel Inception Distance (KID) of 4.83 (down from 9.73), indicating vastly superior image quality and style fidelity.
  • Chinese (ICDAR2013 dataset): Achieved an FID of 10.98 (down from TGC-Diff's 23.43).
  • Human Evaluation: In a "plausibility study" where users had to guess if an image was real or generated by InkSpire, users guessed correctly only ~53% of the time. Because 50% is random chance, this means InkSpire's outputs are virtually indistinguishable from authentic human handwriting.
  • Zero-Shot Editing: Because it is trained on masked infilling, InkSpire can perform seamless character-level editing—such as erasing and rewriting a single word in a handwritten paragraph while perfectly matching the surrounding ink and style.

Limitations and Future Work

The authors note a fascinating failure mode: the model sometimes hallucinates "crossed-out" or erased artifacts in empty spaces. This happens because the training data contains real human errors where writers habitually struck out mistakes, and the model learned to mimic this correction behavior even when not prompted to. Future work will focus on extending the framework to encompass more languages and diverse datasets to further enhance the model's zero-shot generalization capabilities.

Summary updated

BibTeX
@inproceedings{wang2026learning,
  author = {Honglie Wang and Yan-Ming Zhang and Wangzi Yao and Fei Yin and Cheng-Lin Liu},
  title = {{Learning to Generate Stylized Handwritten Text via a Unified Representation of Style, Content, and Noise}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=FBPuLChGNX},
}
Figure