xtract.bot
POST /api/font-subset

Strip a font to only the Unicode codepoints you need — the standard web-perf optimization for self-hosted fonts. Ranges, U+ syntax, and literal characters supported.

Strips a TTF/OTF down to only the glyphs needed for a given set of Unicode codepoints — the standard web-perf optimization for self-hosted fonts. Output keeps the same format as the input. The `codepoints` field accepts a permissive spec: - Literal characters: `Hello,World!` - ASCII ranges: `A-Z,a-z,0-9` - Hex codepoints: `U+0041`, `U+0041-U+005A` - Mixed: `A-Za-z0-9.,U+2014U+2026` (em-dash, ellipsis) Typical use: ship a 4 KB Latin-only subset instead of a 200 KB full-Unicode font for marketing landing pages.

Inputs

NameTypeDefaultDescription
font*fileTTF or OTF font.
codepoints*stringCodepoint spec — literal chars, ASCII ranges (A-Z, 0-9), and U+XXXX[-U+YYYY] ranges. Whitespace and commas are separators.

Response

Modes: binary, json. Cache: yes (24h TTL).

Code samples

Built from the ascii-letters example.

# Download or substitute the example input:
#   curl -O https://xtract.bot/examples/font-info/DejaVuSansMono.ttf
FONT=$(base64 -w0 < DejaVuSansMono.ttf)

curl -X POST https://api.xtract.bot/api/font-subset \
  -H "Content-Type: application/json" \
  -H "Accept: application/octet-stream" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "codepoints": "A-Z,a-z",
  "font": "'"$FONT"'"
}'