CF-Font: Content Fusion for Few-shot Font Generation

Chi Wang, Min Zhou, Tiezheng Ge, Yuning Jiang, Hujun Bao, Weiwei Xu

TL;DR

CF-Font improves few-shot font generation by adaptively blending content features from multiple "basis fonts" and refining style vectors during inference. By introducing a projection-based loss that prioritizes character skeletons over pixel-perfect matching, the model produces significantly cleaner results for complex logographic characters like Chinese.

What Problem Does This Paper Address?

Creating a complete font for logographic languages is a monumental task. While English has 26 letters, Chinese requires over 60,000 characters. Few-shot font generation (FFG) aims to automate this by learning a new style from just a handful of reference images.

Most existing FFG methods rely on content and style disentanglement. They take a "content" feature from a standard source font (like Song or Kai) and try to wrap it in a "style" feature extracted from reference images. However, this disentanglement is rarely perfect. If the source font is structurally very different from the target (e.g., a thick source vs. a thin target), the model often fails to "forget" the source's characteristics, leading to artifacts like broken strokes or unwanted blobs.

Methods

The authors propose three novel components to bridge the gap between source and target domains:

  1. Content Fusion Module (CFM): Instead of relying on a single source font, CF-Font uses a set of "basis fonts" selected via clustering. For any target font, the module calculates adaptive weights based on similarity to these bases and blends their content features. This creates a tailored content representation that is structurally closer to the target. Visualization of content fusion
Figure 3. Visualization of content fusion. The yellow and red arrows are denoted for content features from the commonly used source font Kai [31] and the nearest font of the target respectively. The blue arrow represents the interpolation of content features of basis fonts to approximate the target.
  1. Iterative Style-vector Refinement (ISR): Standard models typically average the style vectors of the few provided reference images. CF-Font treats this average as an initial guess and then performs a few iterations of backpropagation during the inference stage to fine-tune the style vector specifically for that target font. The framework of the model including ISR
Figure 2. The framework of our model. (a) We first train the DGN [42] and use PCL to enhance the supervision of character skeletons. (b) After the model converges, content features of all training fonts are clustered and basis fonts are selected according to cluster centers. The original content encoder is replaced by CFM, and original content features are changed to fused features of basis fonts. Then we continue to train the model so that it adapts to fused content features. (c) In inference, we utilize ISR to polish the style of a font. The extracted mean style vector is treated as the only trainable variable to be fine-tuned for a few iterations.
  1. Projected Character Loss (PCL): Traditional pixel-wise losses (L1/L2) are easily confused by minor misalignments. PCL projects character images into multiple 1D probability distributions (histograms) along different axes. By minimizing the distance between these distributions, the model focuses on the global "skeleton" and topology of the character rather than just local pixel values. Illustration of PCL projections
Figure 4. Illustration of PCL. We project the binary characters into multi-direction 1D spaces (distinguished by color) and cal- culate normalized histograms for each. It is obvious that for the different fonts with the same character, the projected distributions vary along with the skeletons and are less sensitive to textures or colors.

Datasets

The researchers built a dataset of 300 Chinese fonts, encompassing both printed and handwritten styles.

  • Character Set: 6,446 characters per font, covering the GB/T 2312 standard.
  • Split: 240 fonts for training and 60 "unseen" fonts for testing generalization.
  • Few-shot Setting: The model is evaluated using only 16 randomly picked reference characters for each target style.

Key Insights and Ideas

  • Content is not Style-Neutral: A core insight is that the "content" feature extracted from a font still carries stylistic baggage. By using a linear combination of basis fonts, the model can find a "neutral" starting point that minimizes the difficulty of the style transfer.
  • Skeleton Over Pixels: The success of PCL demonstrates that for fonts, structural integrity (the skeleton) is more important than per-pixel accuracy. As shown in Figure 5, PCL-based retrieval finds characters with much more consistent structures than L1-based retrieval. L1 vs PCL retrieval results
  • Inference-Time Optimization: ISR shows that "learning" doesn't have to stop after training. A quick optimization step during deployment can significantly sharpen the stylistic details of the output.
Figure 5. L1 vs PCL. We retrieve the closest character of all train- ing fonts to the top-left one by L1, PC-WDL, and PC-KL, respec- tively. The top ten results of each loss are listed from left to right, top to down. It can be seen that the skeletons vary greatly in the column of L1 but are quite consistent in those of PCL.

Key Results

CF-Font consistently outperformed state-of-the-art (SOTA) methods like DG-Font and MX-Font across multiple metrics:

  • Quantitative: On unseen fonts, it improved the L1 error by 5.7% and the FID (Fréchet Inception Distance) by 5.0% compared to the previous best method.
  • Qualitative: Visual comparisons show that CF-Font avoids the "mismatched style" and "erroneous skeleton" issues that plague other models, especially in complex handwritten styles. Qualitative comparison with SOTA
  • User Study: In a blind test with 20 participants, CF-Font was preferred 21.58% of the time, surpassing the second-place method (CG-GAN) by a large margin.
Figure 6. Qualitative comparison with state-of-the-art methods on Chinese poems. As mentioned earlier, we use multiple source fonts and pick the best results for these comparison methods for fairness. Here we just plot font Song as an example of source fonts for convenience. We mark erroneous skeletons with red boxes and other mismatch styles, such as stroke style, joined-up style, and body frame [26], with blue boxes.

Limitations and Future Work

Despite its strengths, the model still struggles with extremely complex characters that have high stroke density and tight layouts, where it may occasionally miss strokes or produce structural errors.

The authors suggest that future work could explore vector font generation. Since vector characters are scale-invariant and mathematically defined by paths, they might offer a more robust way to handle the fine-grained details of complex logographic scripts.

Summary updated

BibTeX
@inproceedings{wang2023cf,
  author = {Chi Wang and Min Zhou and Tiezheng Ge and Yuning Jiang and Hujun Bao and Weiwei Xu},
  title = {{CF-Font: Content Fusion for Few-shot Font Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2023},
}
Figure