diff --git a/NOTICE.md b/NOTICE.md index 03314d8c8..db202a80f 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -53,3 +53,54 @@ own switch in the admin panel. https://cloud.google.com/maps-platform/terms `server/assets/airports.json` is built from **OurAirports** (https://ourairports.com/data/), released into the public domain. + +## Typefaces: Studio books and the app + +Every typeface a book can be set in, and the app's own (Poppins, MuseoModerno, +Geist), is self-hosted from the **@fontsource** npm packages, which redistribute +the families published on Google Fonts split into subsets by script. The catalogue of book faces is +`shared/src/book/book-fonts.data.ts`. Each package carries its licence and the +copyright notice of the family's authors in its `LICENSE` file. + +Both licences allow a font to be bundled with software and embedded in a +document made with it, so a printed or exported book may carry the faces it is +set in. No family is renamed, redrawn or sold on its own. SIL OFL 1.1: https://openfontlicense.org. Apache 2.0: +https://www.apache.org/licenses/LICENSE-2.0 + +| Family | Package | Licence | +|---|---|---| +| Abril Fatface | `@fontsource/abril-fatface` | SIL Open Font License 1.1 | +| Alfa Slab One | `@fontsource/alfa-slab-one` | SIL Open Font License 1.1 | +| Allura | `@fontsource/allura` | SIL Open Font License 1.1 | +| Anton | `@fontsource/anton` | SIL Open Font License 1.1 | +| Archivo Black | `@fontsource/archivo-black` | SIL Open Font License 1.1 | +| Bebas Neue | `@fontsource/bebas-neue` | SIL Open Font License 1.1 | +| Big Shoulders Display | `@fontsource/big-shoulders-display` | SIL Open Font License 1.1 | +| Bodoni Moda | `@fontsource/bodoni-moda` | SIL Open Font License 1.1 | +| Bricolage Grotesque | `@fontsource/bricolage-grotesque` | SIL Open Font License 1.1 | +| Caveat | `@fontsource/caveat` | SIL Open Font License 1.1 | +| Cormorant Garamond | `@fontsource/cormorant-garamond` | SIL Open Font License 1.1 | +| Dancing Script | `@fontsource/dancing-script` | SIL Open Font License 1.1 | +| DM Mono | `@fontsource/dm-mono` | SIL Open Font License 1.1 | +| DM Serif Display | `@fontsource/dm-serif-display` | SIL Open Font License 1.1 | +| EB Garamond | `@fontsource/eb-garamond` | SIL Open Font License 1.1 | +| Fraunces | `@fontsource/fraunces` | SIL Open Font License 1.1 | +| Great Vibes | `@fontsource/great-vibes` | SIL Open Font License 1.1 | +| Homemade Apple | `@fontsource/homemade-apple` | Apache License 2.0 | +| Inter | `@fontsource/inter` | SIL Open Font License 1.1 | +| Kaushan Script | `@fontsource/kaushan-script` | SIL Open Font License 1.1 | +| League Gothic | `@fontsource/league-gothic` | SIL Open Font License 1.1 | +| Lora | `@fontsource/lora` | SIL Open Font License 1.1 | +| Montserrat | `@fontsource/montserrat` | SIL Open Font License 1.1 | +| MuseoModerno | `@fontsource/museomoderno` | SIL Open Font License 1.1 | +| Oswald | `@fontsource/oswald` | SIL Open Font License 1.1 | +| Pacifico | `@fontsource/pacifico` | SIL Open Font License 1.1 | +| Parisienne | `@fontsource/parisienne` | SIL Open Font License 1.1 | +| Permanent Marker | `@fontsource/permanent-marker` | Apache License 2.0 | +| Playfair Display | `@fontsource/playfair-display` | SIL Open Font License 1.1 | +| Poppins | `@fontsource/poppins` | SIL Open Font License 1.1 | +| Sacramento | `@fontsource/sacramento` | SIL Open Font License 1.1 | +| Satisfy | `@fontsource/satisfy` | Apache License 2.0 | +| Shrikhand | `@fontsource/shrikhand` | SIL Open Font License 1.1 | +| Yellowtail | `@fontsource/yellowtail` | Apache License 2.0 | +| Geist Sans | `@fontsource/geist-sans` | SIL Open Font License 1.1 | diff --git a/client/bookFontPrecache.js b/client/bookFontPrecache.js new file mode 100644 index 000000000..ee52f1651 --- /dev/null +++ b/client/bookFontPrecache.js @@ -0,0 +1,67 @@ +import { BOOK_FONT_FACES, BOOK_FONTS_PRECACHED } from '@trek/shared'; + +/** + * Which font files the service worker installs with the app. + * + * The precache takes every woff and woff2 the build emits, and with the book's + * catalogue at thirty four families that is every weight, both styles and + * every script subset of each: megabytes fetched at install by every user, + * most of it for faces no book of theirs is set in. So the book's faces are + * held to this: + * + * - The faces the app itself draws (Poppins and MuseoModerno for the chrome, + * imported in src/main.tsx) stay exactly as they were. + * - The faces the book shipped with before the catalogue grew + * (`BOOK_FONTS_PRECACHED`) keep their latin woff2, so a book set in them + * still opens offline before Studio was ever opened online. + * - Every other file of a book family, woff, other subsets, new families, + * real italics, is left to the `book-fonts` runtime cache in vite.config.js, + * which the Studio fills with the faces of each book it opens + * (src/components/Studio/bookFontWarm.ts). + * + * Shared by vite.config.js and its test, which reads the filter against file + * names as the build writes them. + */ + +/** The faces src/main.tsx imports for the app chrome, which the book shares; bookFontPrecache.test.ts checks this copy. */ +export const APP_FACES = { + poppins: [300, 400, 500, 600, 700], + museomoderno: [400, 700, 800], +}; + +/** The book packages, longest name first, so `dm-serif-display` is never read as `dm-…`. */ +const BOOK_PACKAGES = [...new Set(Object.values(BOOK_FONT_FACES).map((f) => f.pkg))].sort( + (a, b) => b.length - a.length +); + +const PRECACHED = new Map( + Object.entries(BOOK_FONTS_PRECACHED).map(([id, weights]) => [BOOK_FONT_FACES[id].pkg, new Set(weights)]) +); + +/** + * A font file as the build names it, `---