45 lines
1.5 KiB
Markdown
45 lines
1.5 KiB
Markdown
# Server-side font files
|
|
|
|
This directory is scanned by `server.js` at startup. Each `.ttf` or `.otf` file
|
|
is registered with node-canvas via `registerFont()` so that exports render
|
|
text in the same fonts the editor previews.
|
|
|
|
## Filename convention
|
|
|
|
```
|
|
<Family_Name>-<Variant>.ttf
|
|
```
|
|
|
|
- Spaces in family names become underscores in the filename so the file is
|
|
portable across operating systems. The server replaces them back to spaces
|
|
at registration time.
|
|
- The variant is parsed for the substrings `Bold` and `Italic` to set the
|
|
`weight` and `style` registration options. `Regular` (or anything else) is
|
|
treated as the default weight.
|
|
|
|
Examples:
|
|
| File | Family | Weight | Style |
|
|
|---|---|---|---|
|
|
| `Roboto-Regular.ttf` | Roboto | normal | normal |
|
|
| `Roboto-Bold.ttf` | Roboto | bold | normal |
|
|
| `DM_Sans-Regular.ttf` | DM Sans | normal | normal |
|
|
| `Open_Sans-BoldItalic.ttf` | Open Sans | bold | italic |
|
|
|
|
## Populating this directory
|
|
|
|
```
|
|
npm run fetch-fonts
|
|
```
|
|
|
|
This downloads TTFs for the editor's font list from the Fontsource jsDelivr
|
|
CDN. Re-running is a no-op for already-present files; pass `--force` to
|
|
re-download.
|
|
|
|
## What if I leave it empty?
|
|
|
|
The server still starts and exports still work, but every text element will
|
|
render in whatever fallback font the host system happens to have for the
|
|
requested family. On a stock Alpine container that's a generic sans-serif. On
|
|
macOS dev machines, system-installed fonts usually fill in for the common
|
|
names but not the more specialized ones.
|