Abstract
Generating a new font library is a very labor-intensive and time-consuming job for glyph-rich scripts. Few-shot font generation is thus required, as it requires only a few glyph references without fine-tuning during test. Existing methods follow the style-content disentanglement paradigm and expect novel fonts to be produced by combining the style codes of the reference glyphs and the content representations of the source. However, these few-shot font generation methods either fail to capture content-independent style representations, or employ localized component-wise style representations, which is insufficient to model many Chinese font styles that involve hyper-component features such as inter-component spacing and "connected-stroke". To resolve these drawbacks and make the style representations more reliable, we propose a self-supervised cross-modality pre-training strategy and a cross-modality transformer-based encoder that is conditioned jointly on the glyph image and the corresponding stroke labels. The cross-modality encoder is pre-trained in a self-supervised manner to allow effective capture of cross- and intra-modality correlations, which facilitates the content-style disentanglement and modeling style representations of all scales (stroke-level, component-level and character-level). The pre-trained encoder is then applied to the downstream font generation task without fine-tuning. Experimental comparisons of our method with state-of-the-art methods demonstrate our method successfully transfers styles of all scales. In addition, it only requires one reference glyph and achieves the lowest rate of bad cases in the few-shot font generation task 28% lower than the second best.
Introduction
Creating a new Chinese font is a Herculean task, often requiring the manual design of over 80,000 characters. While "Few-Shot Font Generation" (FFG) aims to automate this by learning a style from a few examples, existing models struggle with the complexity of Chinese scripts.
Most current methods try to separate "content" (the character's structure) from "style" (the artistic flair). However, they often focus on localized components like radicals. This approach fails to capture "hyper-component" features: the way strokes flow into each other in cursive (connected-stroke) or the specific spacing between different parts of a character. Furthermore, many models require a large number of reference glyphs to produce a decent result, which isn't always possible for rare or historical handwriting.
Methodology
The XMP-Font framework introduces a cross-modality transformer that learns to generate entire Chinese font libraries using just one reference glyph. The approach hinges on three main innovations:
- Cross-Modality Transformer Encoder: Instead of looking only at images, the model is fed two streams: the glyph image and a sequence of stroke labels. By using a Transformer architecture with self- and cross-attention layers, the model learns the deep alignment between how a character looks and how it is structurally built.
- Self-Supervised Pre-training: Before learning to generate fonts, the encoder is pre-trained on a massive dataset. Similar to how BERT is trained on text, the model is tasked with "reconstructing" masked strokes and images. This forces the encoder to understand the relationship between different scales of style (stroke-level, component-level, and character-level).
- Style-Content Decoupling & LSTM Stroke Loss: A decoupling network using Efficient Channel Attention (ECA) modules separates the fused features into distinct style and content maps. To ensure structural integrity, a pre-trained LSTM-based stroke order predictor enforces a "stroke loss," penalizing the model if the generated character doesn't follow the correct structural logic of Chinese writing.
The Power of Strokes
Previous models used "components" (radicals) as the atomic unit. But there are over 200 components in Chinese, making it hard to see them all in a few reference glyphs. There are only about 28 basic strokes, making it much easier for a model to achieve full "coverage" and generalize to unseen characters. By freezing the encoder after pre-training, the model becomes a "style expert" that doesn't need to be fine-tuned for every new font.
Experimental Results
The researchers utilized the Founder font libraries for evaluation, comparing XMP-Font against five major competitors, including MX-Font, LF-Font, and StarGAN-v2. XMP-Font outperformed all baseline models in both quantitative metrics and human preference:
- Quantitative Performance: It achieved the lowest FID (Fréchet Inception Distance) scores, indicating the generated images were the most realistic and closest to the target distribution.
- User Study: In a subjective test, users preferred XMP-Font's results significantly more often than the second-best model (MX-Font), especially in the "Unseen Fonts" category.
- Robustness: The model showed a 28% lower rate of "bad cases" (unrecognizable or structurally broken characters) compared to the next best method. It successfully captured difficult styles like "connected-stroke" cursive, where other models produced disconnected or messy results.
Conclusion
XMP-Font demonstrates that cross-modality pre-training is a powerful tool for few-shot font generation. By modeling style at multiple scales—from individual strokes to entire characters—it captures nuances that previous component-based methods missed. While the model currently requires stroke labels, limiting its immediate application to scripts without predefined stroke genres, it sets a new benchmark for high-quality, low-resource font generation.
Summary updated