You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,55 @@ pnpm dev
49
49
50
50
Navigate to `localhost:9876`
51
51
52
+
## Fonts
53
+
54
+
PubPub uses three main font families, plus CJK variants:
55
+
56
+
-**Source Sans 3** — headers, titles, UI text
57
+
-**Source Serif 4** — body text in pubs
58
+
-**Outfit** — landing page
59
+
-**Noto Serif TC/JP/KR/SC** and **Noto Sans TC/JP/KR/SC** — CJK content
60
+
61
+
All fonts are variable-weight woff2 files from [Fontsource](https://fontsource.org/), hosted on S3 at `assets.pubpub.org/fonts/<hash>/`. The font files are not stored in this repo.
62
+
63
+
### How it works
64
+
65
+
A single `fonts.css` on S3 contains all the `@font-face` declarations (~940 rules) for every font family. Each rule uses `unicode-range` subsetting, so browsers only download the woff2 slices for characters actually on the page.
66
+
67
+
The font CSS is loaded via `<link>` tags in `server/Html.tsx` (web) and `workers/tasks/export/html.tsx` (PDF exports), so the browser can start fetching it in parallel with other resources.
68
+
69
+
### Cache busting
70
+
71
+
Files on `assets.pubpub.org` have a long TTL. To avoid cache issues, all font files live under a content-hashed directory (`/fonts/<hash>/`). The hash is derived from the sha256 of all generated files. If nothing changes, the hash stays the same and nothing gets re-uploaded. If anything changes, you get a new directory and new URLs automatically.
72
+
73
+
Old versions remain on S3 harmlessly — they'll just stop being referenced.
74
+
75
+
### Updating fonts
76
+
77
+
Run the upload script:
78
+
79
+
```
80
+
# Dry run — downloads fonts, generates CSS, shows what would happen, updates source files
81
+
scripts/upload-fonts-to-s3.sh --dry-run
82
+
83
+
# Real run — same as above, but also uploads to S3
0 commit comments