Scalable Font Reconstruction with Dual Latent Manifolds

Nikita Srivatsan, Si Wu, Jonathan T. Barron, Taylor Berg-Kirkpatrick

This paper, "Scalable Font Reconstruction with Dual Latent Manifolds," presents a significant step forward in automated typography. By treating font generation as a matrix factorization problem with disentangled latent spaces for both style and shape, the authors enable high-quality font reconstruction that scales to thousands of characters and generalizes to entirely new glyph shapes.

TL;DR

The authors propose a deep generative model that disentangles font style from character shape using dual latent manifolds. Combined with a novel adaptive wavelet-based loss function, this approach allows for high-fidelity font reconstruction and few-shot generalization to unseen characters across large, sparse datasets like Google Fonts and Chinese Simplified.

What Problem Does This Paper Address?

Creating a complete font is an enormous task. While basic Latin alphabets are small, Unicode 13.0.0 contains over 140,000 character types. Consequently, most fonts are "sparse"—they only support a small subset of characters relevant to the designer's culture. As shown in Figure 1, the Google Fonts library has a long tail of fonts with many missing glyphs, creating an accessibility gap for users of less common orthographies.

Figure 1: Supported glyphs in Google Fonts organized by character type and font. A blue pixel indicates that column’s font includes that row’s character. Our pro- posed model allows font reconstruction over this large, sparse character set.

Existing automated methods often struggle to scale. Many treat character types as fixed categories, meaning they cannot generate a character shape the model hasn't seen during training. Others use discriminative models that lack a probabilistic prior, making them brittle when data is scarce.

Methods

The core of the paper is a generative factorization model. They view a font corpus as a matrix where rows are character types and columns are font styles.

Dual Latent Manifolds

Unlike previous work that only models font style as a latent variable, this model learns two separate manifolds:

  1. $Y_i$ (Character Shape): A latent variable representing "what" to write (e.g., the underlying structure of an 'A' or a specific Chinese radical).
  2. $Z_j$ (Font Style): A latent variable representing "how" to write it (e.g., bold, italic, serif).

A glyph $X_{ij}$ is generated by a decoder conditioned on both $Y_i$ and $Z_j$. To handle the "few-shot" nature of the task, they use a pair of inference networks (encoders) that pool information across rows or columns to estimate these latent variables from just a few observed examples.

Architecture: The "What" and the "How"

The decoder uses a U-Net-like structure with a clever twist: the font style variable $Z_j$ acts as a HyperNetwork. Instead of being a simple input, $Z_j$ determines the weights of the final convolutional filters. Meanwhile, the character shape $Y_i$ serves as the initial activation at the top of the decoder. This asymmetry forces the model to learn spatial structure in the $Y$ manifold and fine stylistic details in the $Z$ manifold.

Figure 2: Overview of our generative factorization model, and important architecture details. Glyphs in the same row share a latent variable Yi representing character shape, and those in the same column share Zj representing font style. These variables are inferred by a network that takes in an entire row or column. Our decoder combines these representations to output a distribution on the glyph image.

Adaptive Wavelet Loss

Standard $L_2$ pixel loss produces blurry images, and GANs are notoriously difficult to train. The authors introduce a loss that projects images into a wavelet space (specifically CDF 9/7). Unlike the Global Discrete Cosine Transform (DCT), wavelets capture both frequency and spatial location. They then model these coefficients using an adaptive distribution that can shift between heavy-tailed (Cauchy-like) for sharp edges and Normal-like for smooth areas.

Datasets

The authors evaluated their model on two large-scale datasets:

  • Google Fonts: 2,017 fonts covering 2,000 character types (Latin, Greek, Cyrillic, etc.).
  • Chinese Simplified: 623 fonts covering 2,000 characters. This is particularly challenging due to the high stroke complexity of Chinese glyphs.

They also introduced a preprocessing step to remove "near-duplicate" fonts, ensuring the model is tested on its ability to generalize to truly novel styles.

Key Insights and Ideas

  • Disentanglement is Scalability: By learning a manifold for character shapes, the model can perform "zero-shot" style transfer to characters it has never seen in a specific font, and "few-shot" reconstruction for character shapes it has never seen at all during training.
  • Location Matters: Typography is inherently spatial. The move from DCT (global) to Wavelets (local) allows the model to reason about where a stroke is located, which is vital for maintaining character identity.
  • The Power of Priors: Using a VAE framework with Gaussian priors provides a smoother, more interpolatable latent space than purely discriminative approaches.

Key Results

The model was compared against EMD (a popular discriminative baseline) and a Nearest Neighbor (NN) baseline.

  • Quantitative: On Google Fonts, the Dual Manifold model outperformed all baselines in Structural Similarity (SSIM). For "unknown" characters (those not seen during training), it maintained high performance, proving its generalization capability.
  • Qualitative: The model produces much sharper and more stylistically consistent glyphs than EMD. Figure 4 demonstrates the smoothness of the manifolds, showing successful interpolation between bold/light styles and different character structures simultaneously.
  • Human Evaluation: In Amazon Mechanical Turk studies, users preferred the Dual Manifold reconstructions over EMD roughly 50% of the time, compared to ~40% for EMD.

Limitations and Future Work

  • Complex Glyphs: On the Chinese Simplified dataset, a simple Nearest Neighbor approach sometimes outperformed the model on "known" characters. This suggests that for extremely complex shapes, the model still struggles to capture every fine stroke perfectly.
  • Pixel vs. Vector: The model operates on pixels. In professional typography, vector formats (TTF/OTF) are standard. The authors suggest that future work could apply this manifold approach to stroke-based or vector representations.
  • Contextual Independence: The model generates characters in isolation. It does not currently account for kerning or how characters look when placed next to each other in a word.

Summary updated

BibTeX
@inproceedings{srivatsan2021scalable,
  author = {Nikita Srivatsan and Si Wu and Jonathan T. Barron and Taylor Berg-Kirkpatrick},
  title = {{Scalable Font Reconstruction with Dual Latent Manifolds}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.emnlp-main.244},
}
Figure