# Fonts

The slide renderer draws text only with the fonts bundled with it (`public/slides/fonts`, served at
`https://app.flaghand.com/slides/fonts/`). It never uses a system font, so the editor's preview, an agent's render and the photos
TikTok gets have the same letters. Each one's license allows embedding it in software, redistributing it and commercial
use; the images it draws are ours to post. `GET /api/v1/slideshows/styles` lists them with their licenses.

| Family (`font`) | Files | License | Copyright |
|---|---|---|---|
| TikTok Sans (`tiktok-sans`) | `TikTokSans-400.ttf`, `-600`, `-800` | SIL Open Font License 1.1 | 2024 TikTok Inc. |
| Geist (`geist`) | `Geist-500.ttf`, `-700` | SIL Open Font License 1.1 | 2024 The Geist Project Authors |
| Bebas Neue (`bebas-neue`) | `BebasNeue-400.ttf` | SIL Open Font License 1.1 | 2010 Dharma Type |
| Cormorant Garamond (`cormorant-garamond`) | `CormorantGaramond-500.ttf`, `-500-Italic` | SIL Open Font License 1.1 | 2015 the Cormorant Project Authors |
| Twemoji Mozilla (emoji) | `TwemojiMozilla.ttf` | Graphics: CC BY 4.0. Font code: Apache 2.0 | Graphics: Twitter, Inc. and other contributors. Code: 2016-2018 Mozilla Foundation |

The license texts sit next to the files: `OFL-TikTokSans.txt`, `OFL-Geist.txt`, `OFL-BebasNeue.txt`,
`OFL-CormorantGaramond.txt` and `LICENSE-TwemojiMozilla.md`. None of the four OFL fonts declares a Reserved Font Name, so
the instances below keep their names.

Emoji graphics: [Twemoji](https://github.com/twitter/twemoji) by Twitter, Inc. and other contributors, licensed under
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), in Mozilla's COLR font build. Shapes unchanged.

## Where they come from

The OFL fonts are Google Fonts' copies, at these commits of [google/fonts](https://github.com/google/fonts):

| Family | Source | Commit |
|---|---|---|
| TikTok Sans | `ofl/tiktoksans/TikTokSans[opsz,slnt,wdth,wght].ttf` | `2750b521bd22ce141f12617194ab0e04cf5d12d5` |
| Geist | `ofl/geist/Geist[wght].ttf` | `718e1db4deb9e4d9d85a0ead1b9f5fde2761ccfd` |
| Bebas Neue | `ofl/bebasneue/BebasNeue-Regular.ttf` | `61f595f96445e9c2316b50d1ba3d79ef91f72b0a` |
| Cormorant Garamond | `ofl/cormorantgaramond/CormorantGaramond[wght].ttf` and `-Italic[wght].ttf` | `3dd78844021e948ceb633d1dcee3f7885561b5d9` |

Twemoji Mozilla is `Twemoji.Mozilla.ttf` from [mozilla/twemoji-colr](https://github.com/mozilla/twemoji-colr) release
v0.7.0 (COLR version 0 color layers, which the renderer reads directly).

The variable fonts are cut to fixed instances with fontTools 4.60.1, so the renderer reads plain outlines:

```sh
fonttools varLib.instancer 'TikTokSans[opsz,slnt,wdth,wght].ttf' wght=600 wdth=100 opsz=36 slnt=0 -o TikTokSans-600.ttf   # and 400, 800
fonttools varLib.instancer 'Geist[wght].ttf' wght=500 -o Geist-500.ttf                                                        # and 700
fonttools varLib.instancer 'CormorantGaramond[wght].ttf' wght=500 -o CormorantGaramond-500.ttf                                 # and the italic
```

Bebas Neue and Twemoji Mozilla are the upstream files as they are.

SHA-256 of each file as bundled:

```
bdccf84623378ed8e6708e42fe425742533aca99fe13f5e95c6ac5bb02b4400f  TikTokSans-400.ttf
41143070ddc0dc584a314b1f8a3f3c522348c1f0a8848bd041c9a6563ca8d5fc  TikTokSans-600.ttf
ca34e2f469da3c598e75d81b66b13b2e4622a93e9d35d0194fc7e24a5d0c1882  TikTokSans-800.ttf
8506ffe20ba09a234cfb5a0764bb6b7685fdc301b228ea93a85951ee17b698bb  Geist-500.ttf
b1a90664ce1b0f120f8f0dd7cc0f1a8be7f7f7c08358209048828a2bbacb3c3b  Geist-700.ttf
08e4623805102d819f58601e46e345648846075e363b2ceb23313c2d1c83ec73  BebasNeue-400.ttf
6da9d95045f95e8ea3fb1828bf042923fa7a5e97641e4c6bc49f634479751a6f  CormorantGaramond-500.ttf
d7247573fe3a9656ac57dc02bc8bd9d2b5f366fe367b550472de86ddaa4b0b42  CormorantGaramond-500-Italic.ttf
6d90152ee0d29e82fe2a87793af5aa4b7ad13e6538360889e141e81ed299ee8e  TwemojiMozilla.ttf
```

## The renderer's code

The renderer also includes others' code, each under a license that allows using and redistributing it commercially:
libjpeg-turbo 2.1.5.1 (IJG and BSD 3-clause) and libwebp 1.6.0 (BSD 3-clause) in `photo.wasm`, resvg-wasm 2.6.2
(Mozilla Public License 2.0) and opentype.js 2.0.0 (MIT). This software is based in part on the work of the Independent
JPEG Group. The license texts are in [`/slides/NOTICES.md`](https://app.flaghand.com/slides/NOTICES.md), served next to the renderer.

## Adding a font

Only a font whose license allows embedding, redistribution and commercial use (the OFL, Apache 2.0, CC BY, or a public
domain dedication); never one that is free for personal use only. Put its file and license text in
`public/slides/fonts/`, add it to `FONTS` in `scheduler/src/slides/doc.js` with its license, record it here, add a
golden fixture that uses it, and bump `RENDERER` (a new font can change how missing characters fall back).

Characters a family lacks are drawn in TikTok Sans, and emoji in Twemoji. A character none of them has is left out, and
the render says so in its `warnings`.
