Font Subsetter API
Cut a TTF, OTF or WOFF font down to the characters you need (text, Unicode ranges, Latin or Vietnamese presets) and get WOFF2, WOFF and CSS.
Upload a font as multipart file (TTF, OTF, WOFF or a TrueType collection with face_index) and say which characters to keep: sample text, unicodes ranges (U+0020-007E, U+1EA0-1EF9) and / or a preset: latin, latin-ext (Google Fonts ranges), vietnamese (Basic Latin + Latin-1 + every precomposed Vietnamese letter + combining tone marks + ₫), vietnamese-only or digits. The font is subset with HarfBuzz hb-subset, keeping the glyphs reachable through OpenType layout (ligatures, accents).
Choose format woff2 (default), woff, ttf or all. The response has the sizes before and after, missing_characters the font does not contain, vietnamese_support (full / partial / none), a CSS @font-face block with unicode-range, and the files as base64 (output=binary returns the font itself). Layout features: features=default (HarfBuzz default set), all, or a list such as kern,liga; drop_features removes some; hinting=false drops hinting for smaller files; pin_axes=true turns a variable font into its default instance.
WOFF2 input is not accepted (send the TTF / WOFF). Fonts up to 30 MB. Only subset fonts whose licence allows it (e.g. SIL OFL); responsibility for the font licence stays with you.
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
file | body | file | yes | TTF, OTF, WOFF or TTC font (multipart, raw body or file_base64), max 30 MB. | |
text | body | string | no | Sample text: every character in it is kept. | |
unicodes | body | string | no | Unicode ranges, e.g. U+0020-007E, U+20AB (wildcards like U+1E?? allowed). | |
preset | body | string | no | latin, latin-ext, vietnamese, vietnamese-only, digits (comma list allowed). | |
format | body | string | no | woff2 | woff2, woff, ttf or all (comma list allowed). |
features | body | string | no | default | OpenType layout features to keep: default, all or a list like kern,liga,ss01. |
drop_features | body | string | no | Feature tags to remove, e.g. dlig,salt. | |
hinting | body | boolean | no | true | false removes TrueType hinting (smaller files). |
pin_axes | body | boolean | no | false | Variable fonts: keep only the default instance. |
family | body | string | no | font-family name in the CSS (default: the font’s family name). | |
output | body | string | no | json | json (files as base64) or binary (the first chosen format as a file). |
Example
curl -X POST "https://apibox.io.vn/v1/font-subset" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@./my-file"const form = new FormData();
form.append('file', fileInput.files[0]);
const res = await fetch('https://apibox.io.vn/v1/font-subset', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body: form,
});
console.log(await res.json());import requests
res = requests.post(
"https://apibox.io.vn/v1/font-subset",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"file": open("my-file", "rb")},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/font-subset');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => ['file' => new CURLFile('my-file')],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"font": {
"family": "Be Vietnam Pro",
"style": "Regular",
"full_name": "Be Vietnam Pro Regular",
"postscript_name": "BeVietnamPro-Regular",
"input_format": "ttf",
"input_bytes": 132948,
"characters_in_font": 459
},
"requested": 311,
"kept": 309,
"missing": 2,
"missing_characters": "̩‛",
"missing_ranges": "U+0329, U+201B",
"vietnamese_support": "full",
"features": "default",
"hinting": true,
"sizes": {
"original": 132948,
"woff2": 30884,
"woff": 35096
},
"saved_percent": 76.8,
"unicode_range": "U+0020-007E, U+00A0-00FF, U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0306, U+0309, U+0323, U+1EA0-1EF9, U+2013-2014, U+2018-201A, U+201C-201D, U+2026, U+20AB",
"css": "@font-face {\n font-family: 'Be Vietnam Pro';\n font-style: normal;\n font-weight: 400;\n font-display: swap;\n src: url('BeVietnamPro-Regular-subset.woff2') format('woff2'),\n url('BeVietnamPro-Regular-subset.woff') format('woff');\n unicode-range: U+0020-007E, U+00A0-00FF, …, U+1EA0-1EF9, …, U+20AB;\n}",
"files": {
"woff2": {
"filename": "BeVietnamPro-Regular-subset.woff2",
"content_base64": "d09GMgABAAAAAHikABEAAAABScwAAHhGAAEAAAAA…"
},
"woff": {
"filename": "BeVietnamPro-Regular-subset.woff",
"content_base64": "d09GRgABAAAAAIkYABEAAAABScwAAQAAAAAAAAAA…"
}
},
"ms": 177
}
Use cases
- Make Vietnamese web fonts load fast without losing diacritics
- Create a tiny icon or logo font with only the letters of a title
- Check whether a font supports all Vietnamese letters before using it
- Convert TTF to WOFF2 / WOFF with a ready @font-face snippet
FAQ
Why do Vietnamese characters break with the Google "latin" subset?
Letters such as ă, ơ, ư, đ and the tones (ạ, ế, ữ…) live in Latin Extended ranges. Use preset=vietnamese to keep Basic Latin plus every precomposed Vietnamese letter and the combining marks in one file.
How is the WOFF2 made?
The subset font is compressed with Brotli in WOFF2 format with untransformed tables (the spec’s null transform for glyf / loca). Browsers load it like any WOFF2; files are a few percent larger than with the glyf transform.
Does it tell me which characters are missing?
Yes: missing_characters and missing_ranges list requested characters that are not in the font’s cmap, and vietnamese_support says full, partial or none.
Related APIs
Image Metadata & EXIF
Read image dimensions, format, EXIF camera data, capture settings and GPS location from JPEG, PNG, WebP, HEIC, AVIF, GIF and more – upload or URL.
PDFPDF Metadata
Read PDF metadata: page count, title, author, creator, producer, dates, PDF version, encryption, form fields and the size of each page (A4, Letter…).
PDF₫Quote & Receipt PDF
Generate clean PDF quotations, receipts, orders and simple invoices from JSON, with Vietnamese text, VAT, totals in words and a VietQR code for payment.