Skip to content

Font Support

Jinny You edited this page Mar 23, 2026 · 7 revisions

Default Font Embedding

ThorVG Web adopts default font, enabling essential glyph rendering even in environments where no font is explicitly loaded.

Default Font Information

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 +-=().

Embedding tool

A tool for embedding the default font into the WASM binary. Converts a TTF file into a C++ header with LZSS-compressed data.

Source Code

font_to_hex.py

Usage

# Extract glyphs (fonttools)
$ pyftsubset DMSans-Regular.ttf \
    --text="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 +-=()." \
    --output-file=DMSans-subset.ttf

# Convert to code
$ python3 font_to_hex.py <input.ttf> <output.h>

# Replace wasm/common/tvgWasmDefaultFont.h with the generated header data.

Clone this wiki locally