What Font File Obfuscation Actually Does
Font obfuscation transforms a font file so it cannot be used directly if someone downloads it. The most common approach for web fonts is:
- XOR-encrypt the font bytes with a secret key.
- Serve the encrypted bytes as a generic file (e.g.,
.bin) — not as a.ttfor.woff2. - Decrypt in JavaScript when the page loads.
- Load via
FontFace+ Blob URL so the font is never registered from a direct URL [citation:3][citation:29].
The result: a bot that crawls your CSS and downloads every .woff2 file gets nothing useful. A human user sees the correct font. But a determined reverse engineer can still extract the decrypted font from browser memory or DevTools.
What This Tool Generates
| Output | What It Is | Where to Put It |
|---|---|---|
| Encrypted font (.bin) | XOR-encrypted bytes, served as a generic binary | Your server, e.g. /fonts/secret.bin |
| JavaScript loader | Fetches the .bin, decrypts, creates Blob URL, loads FontFace | Your page or a bundled JS file |
The JavaScript Loader Explained
The generated loader does the following:
// 1. Fetch the encrypted bytes
const res = await fetch('/fonts/secret.bin');
const encrypted = new Uint8Array(await res.arrayBuffer());
// 2. XOR-decrypt with the same key
const key = new TextEncoder().encode('your-secret-key');
const decrypted = new Uint8Array(encrypted.length);
for (let i = 0; i < encrypted.length; i++) {
decrypted[i] = encrypted[i] ^ key[i % key.length];
}
// 3. Create a Blob and a temporary URL
const blob = new Blob([decrypted], { type: 'font/ttf' });
const url = URL.createObjectURL(blob);
// 4. Load via FontFace API
const face = new FontFace('MyProtectedFont', `url(${url})`);
await face.load();
document.fonts.add(face);
// 5. Revoke the URL (font stays in memory)
URL.revokeObjectURL(url);
Because the URL is a blob: URL that is revoked immediately after loading, the font never appears as a persistent, downloadable file in the Network tab [citation:3].
What Font Obfuscation Cannot Do
- It cannot make the font unstealable. The browser must decrypt and use the font. A determined user can dump the decrypted bytes from memory [citation:3][citation:29].
- It cannot stop hotlinking if the encrypted file is public. If someone finds your
.bin, they can still download it — they just can't use it as a font without your key. - It cannot replace font licensing. This is a technical deterrent, not a legal one. Always enforce your font licenses.
- It cannot work without JavaScript. Users with JS disabled will see fallback fonts. Always specify fallbacks in CSS.
Font Subsetting — The Stronger Protection
pyftsubset (fonttools) can generate a subset before you obfuscate.
Legal & Licensing Reality
Many font licenses prohibit modification, including encryption or subsetting. Before obfuscating a font:
- Check the license — does it allow modification or subsetting?
- Some licenses (e.g., SIL OFL) allow modification but prohibit using the Reserved Font Name.
- Commercial fonts often prohibit any modification — contact the foundry.
Frequently Asked Questions
Is font obfuscation secure?
How does XOR encryption work here?
Why use FontFace + Blob URL instead of @font-face?
@font-face points to a URL that anyone can find in the Network tab. FontFace + Blob URL creates the font from memory, so no persistent URL exists to download [citation:3].Can I use this with WOFF2?
font/woff2) when creating the Blob.Does this affect performance?
What happens if JavaScript is disabled?
font-family: 'MyProtectedFont', Arial, sans-serif;.Can I use different keys for different fonts?
Is my font uploaded to your server?
Can I obfuscate variable fonts?
Does this work with CORS?
fetch() call to download the .bin must be same-origin or CORS-enabled. If your font is on a CDN, configure CORS headers on the CDN. Alternatively, inline the encrypted bytes as Base64 in your JavaScript.