Templates
Fonts
Four fonts are built in and cost nothing: inter (the default), source-serif, jetbrains-mono and system. Every script has a fallback, so Arabic, Hindi, Japanese and the rest always render. See languages.
For your brand's typeface, name it. DevilPDF loads it for that document.
#Google Fonts
Set font or heading_font to any family on fonts.google.com, spelled the same way:
{
"template": "invoice",
"data": { "number": "INV-1001" },
"options": { "font": "Lora", "heading_font": "Playfair Display" }
}DevilPDF asks Google for regular through bold, plus italics, and steps down to the styles the family actually has. A misspelt family returns invalid_request with the name it could not find, never a document in the wrong font.
To use a family only in your own CSS, list it in fonts:
{
"html": "<h1 class=\"title\">Quarterly report</h1>",
"css": ".title { font-family: 'Bebas Neue', sans-serif; }",
"options": { "fonts": ["Bebas Neue"] }
}#Your own font files
Give the file's public https URL. Add one entry per weight or style you use:
{
"template": "tpl_8Jq2mVx4",
"data": {},
"options": {
"font": "Brand Sans",
"fonts": [
{ "family": "Brand Sans", "url": "https://cdn.example.com/brand-regular.woff2" },
{ "family": "Brand Sans", "url": "https://cdn.example.com/brand-bold.woff2", "weight": 700 },
{ "family": "Brand Sans", "url": "https://cdn.example.com/brand-italic.woff2", "style": "italic" }
]
}
}| Field | Type | Default | Description |
|---|---|---|---|
family | string | The name you use in font, heading_font or CSS. Letters, digits and spaces. | |
url | string | Public https URL of a .woff2, .woff, .ttf or .otf file. .woff2 is smallest and fastest. | |
weight | number or string | 400 | The file's weight, 100 to 900. For a variable font, a range: "100 900". |
style | string | "normal" | normal or italic. |
The file must be reachable without a login, and you need the right to embed it in documents. Most commercial font licences need a web or app licence for this.
#In templates
Put the same font, heading_font and fonts in the template's settings and every render uses them. A request can still override them for one document.
#Speed and characters
The built-in fonts are already loaded in the renderer, so they add nothing. A Google or custom font adds a little to the first document that uses it (Google's stylesheet and the file are fetched once, then kept), and very little after.
A font only draws the characters it has. When it has no glyph for a character (a Latin font meeting Arabic or Japanese, say), DevilPDF falls back to Inter and then to the right script font, so nothing comes out as empty boxes.
#Full HTML documents
When you send a complete HTML document (<html>…</html>) without the print kit, DevilPDF leaves it exactly as written. Load fonts the usual way in your own <head>, with a <link> to Google Fonts or an @font-face rule.