oficina / slides Public

Clone
git clone https://amadan.net/oficina/slides

Plain git — no account needed to clone.

Download

Download this file

1# Custom fonts for Oficina, starting in Slides — design
2
3Short design, 2026-11-23, by Claude Opus 5.5 from conversation with Paul
4the same day. Not yet approved.
5
6## Intent
7
8Paul wants to set a deck in Timeless Sans, the face the HalfStack talk
9used, and the same for any font he has the right to use. Upload it once,
10pick it like any other font, and everything that can't use it falls back
11to the next font, as CSS does. Docs and Sheets should be able to use the
12same machinery later.
13
14Timeless Sans comes as a variable WOFF2 (`TimelessSansVF.woff2`). Its
15licence (Timeless Free Font License 1.2) allows embedding in a website
16and forbids committing it to a repository or handing it out.
17
18## Goals
19
201. A person uploads font files to their font library in Slides and picks
21 an uploaded family for a deck's headings or body.
222. Everyone who can see the deck (editor, viewer, share and follow links,
23 presenter and slide windows) sees it in that font, behind the font
24 gate: no flash, and a family late past the gate's deadline falls back.
253. Slide pictures and the PDF use the font when the upload is a static
26 TrueType face whose embedding flags allow it; otherwise they fall back
27 to the deck's next font.
284. The upload, checking, storage and serving are one shared Go module that
29 Docs can adopt without copying.
30
31## Non-goals
32
33- A suite-wide library in Home. Home stays as designed (theme only, no
34 storage). The module keeps that door open.
35- Converting fonts: WOFF2 decompression and instancing variable fonts for
36 pictures and PDF. Those files serve the web only; pictures and PDF fall
37 back. Possible later.
38- Fonts from a URL or a font service.
39- Docs and Sheets adoption (next, separately).
40
41## Anti-goals
42
43- A font file that can attack a viewer or the server. Every upload is
44 parsed and refused if malformed before it is stored.
45- A font reaching anyone who can't see a deck that uses it, or anyone
46 else's library.
47- Committing or redistributing a font: files live only in the app's
48 object store, never in a repository, a bundle or an export bundle.
49- A flash: the gate's rule holds.
50- Embedding a font in a PDF when its own flags forbid it.
51
52## Approaches
53
541. **A shared module; fonts stored per app (chosen by Paul).** One Go
55 module does parsing, metadata, checks, storage keys and serving; each
56 app keeps the files in its own store. Upload once per app.
572. A font library in Home. True "upload once", but reverses Home's
58 founding rules (§5.4, theme-only preferences, no storage).
593. Gotenberg (server-side Chrome) for PDFs. Not needed: Slides' own PDF
60 engine already embeds TrueType subsets, and Chrome's output would
61 differ from the editor and pictures.
62
63## The design
64
65**The module.** Package `amadan.net/oficina/estilo.git/typeface` in the
66estilo repo beside `theme` (estilo is one Go module), because estilo is
67already what every Oficina app imports. It owns:
68
69- `Inspect(data []byte) (Face, error)`: accepts TTF, OTF, WOFF and WOFF2;
70 refuses anything else or anything malformed. `Face` carries the family
71 and style names from the `name` table, weight, italic, whether it is
72 variable (and its weight range), the outline kind (TrueType or CFF), the
73 `OS/2` embedding flags, and a SHA-256 ref.
74- Limits: 10 MiB a file, 16 faces a family, 32 families a person.
75- `Pictures(f Face) bool`: true for a static TrueType-outline face whose
76 flags allow embedding (installable, editable or print-and-preview).
77- Serving helpers: content type, `nosniff`, long caching by ref, and a
78 CSP that allows nothing.
79- No storage of its own and no routes: the app gives it bytes and stores
80 the result with its existing blob store.
81
82**In Slides.**
83
84- **Library.** A person's fonts: `fonts` rows (owner, family, faces) and
85 the files in the object store, uploaded through the same signed-upload
86 path pictures use, then inspected before they are kept. Account menu
87 gains *Fonts*: a page listing families with a sample line, upload, and
88 delete (a deck still using a deleted family keeps its own reference,
89 below).
90- **Using one in a deck.** Choosing an uploaded family in Deck settings
91 copies a reference into the deck, as pictures are: the deck's document
92 records `{family, faces: [{ref, weight, italic, variable}]}` under
93 `meta.fontFiles`, and the server records which refs the deck may serve
94 (like `DeckAsset`). So anyone who can see the deck can load its fonts,
95 and nobody can load a font through a deck that doesn't use it.
96 `meta.fonts` keeps its stacks; the uploaded family goes first and the
97 theme's family follows as the fallback.
98- **Serving.** `/d/{sqid}/fonts/{ref}`, `/s/{token}/fonts/{ref}`,
99 `/p/{session}/fonts/{ref}`, each checking the deck's record, as assets
100 do. Same origin, so the CSP doesn't change.
101- **The gate.** The manifest lists the deck's uploaded faces beside the
102 catalog's; the editor, viewer, share, follow, presenter and slide
103 windows all wait for them under the same deadline.
104- **Pictures and PDF.** The layout engine measures with an uploaded face
105 where `Pictures` is true; the SVG names the family with the fallback
106 stack; the PDF embeds a subset. Otherwise both use the fallback, as
107 today.
108- **The core and the API.** `meta.fontFiles` travels on `set_meta` with
109 vectors in Rust, JS and Go, as the fixtures rule requires; the API
110 describes it; the font name pattern (`fontPattern`) already admits
111 ordinary family names.
112
113**Words.** New strings (the Fonts page, upload errors, the Deck settings
114group, and a reminder to upload only fonts the person may use on the
115web) go through Paul's copy review before they are written.
116
117## Testing
118
119- `Inspect` against real files: TTF, OTF (CFF), WOFF, WOFF2, variable,
120 and malformed, truncated and oversize files.
121- A deck in an uploaded font: viewer, share link and presenter load it
122 behind the gate; a deck that doesn't use it can't serve it; another
123 person can't read your library.
124- Pictures and PDF embed a static TrueType face, and fall back for a
125 WOFF2, a variable font and a face whose flags forbid embedding.
126- Existing decks render byte for byte as today.
127
128## Left to the builder
129
130Table and column names, the page's layout within estilo's patterns, the
131exact limits if a real font needs more.
132