From 142aa61295d4d2c6f1137381709a2570f0f0555d Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 23 Oct 2026 19:02:12 +0200 Subject: [PATCH] feat(studio): 34 typefaces with real weights and italics, a categorised font picker The book catalogue grows from 7 families to 34, all self-hosted through @fontsource under the SIL OFL 1.1 or the Apache License 2.0: condensed and poster faces, heavy retro display, elegant display serifs, Montserrat, twelve scripts and DM Mono. Weights run from 100 to 900, each family offering only the weights it ships, and the serifs gain real italics. The catalogue lives in @trek/shared (book-fonts.data.ts) with each family's roles (display, heading, body, script, mono), weights, italics and letter width, so the Studio, the findings, the design engine and the assistant read one list. Page operations and the design engine set a weight a family lacks at its nearest one, describe_book_page names the role and the weight, and font_mix no longer counts scripts and mono faces, warning above three. The Studio gets StudioFontPicker: the current family set in itself, a searchable list grouped by kind with every family in its own face and the book's own families first, and a weight slider over the weights the family has. Faces load only when used; the assistant's page snapshot embeds only the faces a page draws, the service worker installs only the latin files of the original seven families, and the faces of an opened book are cached for offline use. BOOK_SCHEMA_REV goes to 2. --- NOTICE.md | 51 ++ client/bookFontPrecache.js | 67 +++ client/package.json | 27 + client/scripts/size-baseline.json | 2 +- client/src/components/Studio/PageNumbers.tsx | 4 +- client/src/components/Studio/SpreadView.tsx | 4 +- client/src/components/Studio/StudioCanvas.tsx | 4 +- .../Studio/StudioFontPicker.test.tsx | 112 ++++ .../components/Studio/StudioFontPicker.tsx | 198 +++++++ .../src/components/Studio/StudioInspector.tsx | 8 +- client/src/components/Studio/StudioShell.tsx | 3 + .../Studio/StudioTravelInspector.tsx | 5 +- .../Studio/StudioTypeControls.test.tsx | 71 ++- .../components/Studio/StudioTypeControls.tsx | 105 ++-- .../src/components/Studio/TravelElements.tsx | 6 +- client/src/components/Studio/bookFontFaces.ts | 194 ++++++- .../components/Studio/bookFontWarm.test.ts | 79 +++ client/src/components/Studio/bookFontWarm.ts | 64 +++ client/src/components/Studio/bookFonts.ts | 143 ++---- client/src/components/Studio/fontPicker.ts | 47 ++ client/src/components/Studio/pageSnapshot.ts | 4 + .../components/Studio/snapshotFonts.test.ts | 190 +++++++ client/src/components/Studio/snapshotFonts.ts | 233 +++++++++ client/src/styles/studio-fonts.css | 174 +++++++ client/src/styles/studio.css | 32 +- .../tests/unit/pwa/bookFontPrecache.test.ts | 93 ++++ .../tests/unit/studio/bookFontFaces.test.ts | 28 +- client/tests/unit/studio/bookFonts.test.ts | 20 +- .../tests/unit/studio/useBookStore.test.tsx | 8 +- client/vite.config.js | 21 + package-lock.json | 270 ++++++++++ .../assistant/assistant-book-design.prompt.ts | 4 +- server/tests/e2e/journey-book.e2e.test.ts | 13 +- .../book-design/book-design-cards.test.ts | 7 +- .../unit/nest/journey-book.service.test.ts | 15 +- .../journey-book-design.service.test.ts | 9 +- shared/src/book/book-element-ops.schema.ts | 3 +- shared/src/book/book-findings-design.spec.ts | 6 + shared/src/book/book-findings-design.ts | 26 +- shared/src/book/book-findings.ts | 15 +- shared/src/book/book-fonts.data.ts | 481 ++++++++++++++++++ shared/src/book/book-fonts.spec.ts | 207 ++++++++ shared/src/book/book-fonts.ts | 188 +++++++ shared/src/book/book-op-enums.ts | 15 +- shared/src/book/book-ops-elements.ts | 9 +- shared/src/book/book-ops.ts | 7 +- shared/src/book/book-schema-rev.spec.ts | 27 +- shared/src/book/book-schema-rev.ts | 2 +- shared/src/book/book.schema.ts | 18 +- shared/src/book/describe-spread.ts | 7 +- shared/src/book/design/design-book.ts | 5 +- shared/src/book/design/design-compose.ts | 9 +- shared/src/book/design/design-framing.ts | 6 +- shared/src/book/design/design-spreads.ts | 4 +- shared/src/book/design/design-style.spec.ts | 29 +- shared/src/book/design/design-style.ts | 16 +- shared/src/i18n/ar/index.ts | 2 + shared/src/i18n/ar/journey.ts | 1 - shared/src/i18n/ar/studioFonts.ts | 31 ++ shared/src/i18n/az/index.ts | 2 + shared/src/i18n/az/journey.ts | 2 - shared/src/i18n/az/studioFonts.ts | 31 ++ shared/src/i18n/br/index.ts | 2 + shared/src/i18n/br/journey.ts | 1 - shared/src/i18n/br/studioFonts.ts | 31 ++ shared/src/i18n/ca/index.ts | 2 + shared/src/i18n/ca/journey.ts | 1 - shared/src/i18n/ca/studioFonts.ts | 31 ++ shared/src/i18n/cs/index.ts | 2 + shared/src/i18n/cs/journey.ts | 1 - shared/src/i18n/cs/studioFonts.ts | 31 ++ shared/src/i18n/de/index.ts | 2 + shared/src/i18n/de/journey.ts | 1 - shared/src/i18n/de/studioFonts.ts | 31 ++ shared/src/i18n/en/index.ts | 2 + shared/src/i18n/en/journey.ts | 1 - shared/src/i18n/en/studioFonts.ts | 31 ++ shared/src/i18n/es/index.ts | 2 + shared/src/i18n/es/journey.ts | 1 - shared/src/i18n/es/studioFonts.ts | 31 ++ shared/src/i18n/et/index.ts | 2 + shared/src/i18n/et/journey.ts | 1 - shared/src/i18n/et/studioFonts.ts | 31 ++ shared/src/i18n/fr/index.ts | 2 + shared/src/i18n/fr/journey.ts | 1 - shared/src/i18n/fr/studioFonts.ts | 31 ++ shared/src/i18n/gr/index.ts | 2 + shared/src/i18n/gr/journey.ts | 1 - shared/src/i18n/gr/studioFonts.ts | 31 ++ shared/src/i18n/hu/index.ts | 2 + shared/src/i18n/hu/journey.ts | 1 - shared/src/i18n/hu/studioFonts.ts | 31 ++ shared/src/i18n/id/index.ts | 2 + shared/src/i18n/id/journey.ts | 1 - shared/src/i18n/id/studioFonts.ts | 31 ++ shared/src/i18n/it/index.ts | 2 + shared/src/i18n/it/journey.ts | 1 - shared/src/i18n/it/studioFonts.ts | 31 ++ shared/src/i18n/ja/index.ts | 2 + shared/src/i18n/ja/journey.ts | 1 - shared/src/i18n/ja/studioFonts.ts | 31 ++ shared/src/i18n/ko/index.ts | 2 + shared/src/i18n/ko/journey.ts | 1 - shared/src/i18n/ko/studioFonts.ts | 31 ++ shared/src/i18n/nl/index.ts | 2 + shared/src/i18n/nl/journey.ts | 1 - shared/src/i18n/nl/studioFonts.ts | 31 ++ shared/src/i18n/pl/index.ts | 2 + shared/src/i18n/pl/journey.ts | 1 - shared/src/i18n/pl/studioFonts.ts | 31 ++ shared/src/i18n/ru/index.ts | 2 + shared/src/i18n/ru/journey.ts | 1 - shared/src/i18n/ru/studioFonts.ts | 31 ++ shared/src/i18n/sk/index.ts | 2 + shared/src/i18n/sk/journey.ts | 1 - shared/src/i18n/sk/studioFonts.ts | 31 ++ shared/src/i18n/sv/index.ts | 2 + shared/src/i18n/sv/journey.ts | 1 - shared/src/i18n/sv/studioFonts.ts | 31 ++ shared/src/i18n/th/index.ts | 2 + shared/src/i18n/th/journey.ts | 1 - shared/src/i18n/th/studioFonts.ts | 31 ++ shared/src/i18n/tr/index.ts | 2 + shared/src/i18n/tr/journey.ts | 1 - shared/src/i18n/tr/studioFonts.ts | 31 ++ shared/src/i18n/uk/index.ts | 2 + shared/src/i18n/uk/journey.ts | 1 - shared/src/i18n/uk/studioFonts.ts | 31 ++ shared/src/i18n/vi/index.ts | 2 + shared/src/i18n/vi/journey.ts | 1 - shared/src/i18n/vi/studioFonts.ts | 31 ++ shared/src/i18n/zh-TW/index.ts | 2 + shared/src/i18n/zh-TW/journey.ts | 1 - shared/src/i18n/zh-TW/studioFonts.ts | 31 ++ shared/src/i18n/zh/index.ts | 2 + shared/src/i18n/zh/journey.ts | 1 - shared/src/i18n/zh/studioFonts.ts | 31 ++ shared/src/index.ts | 1 + 138 files changed, 3921 insertions(+), 394 deletions(-) create mode 100644 client/bookFontPrecache.js create mode 100644 client/src/components/Studio/StudioFontPicker.test.tsx create mode 100644 client/src/components/Studio/StudioFontPicker.tsx create mode 100644 client/src/components/Studio/bookFontWarm.test.ts create mode 100644 client/src/components/Studio/bookFontWarm.ts create mode 100644 client/src/components/Studio/fontPicker.ts create mode 100644 client/src/components/Studio/snapshotFonts.test.ts create mode 100644 client/src/components/Studio/snapshotFonts.ts create mode 100644 client/src/styles/studio-fonts.css create mode 100644 client/tests/unit/pwa/bookFontPrecache.test.ts create mode 100644 shared/src/book/book-fonts.data.ts create mode 100644 shared/src/book/book-fonts.spec.ts create mode 100644 shared/src/book/book-fonts.ts create mode 100644 shared/src/i18n/ar/studioFonts.ts create mode 100644 shared/src/i18n/az/studioFonts.ts create mode 100644 shared/src/i18n/br/studioFonts.ts create mode 100644 shared/src/i18n/ca/studioFonts.ts create mode 100644 shared/src/i18n/cs/studioFonts.ts create mode 100644 shared/src/i18n/de/studioFonts.ts create mode 100644 shared/src/i18n/en/studioFonts.ts create mode 100644 shared/src/i18n/es/studioFonts.ts create mode 100644 shared/src/i18n/et/studioFonts.ts create mode 100644 shared/src/i18n/fr/studioFonts.ts create mode 100644 shared/src/i18n/gr/studioFonts.ts create mode 100644 shared/src/i18n/hu/studioFonts.ts create mode 100644 shared/src/i18n/id/studioFonts.ts create mode 100644 shared/src/i18n/it/studioFonts.ts create mode 100644 shared/src/i18n/ja/studioFonts.ts create mode 100644 shared/src/i18n/ko/studioFonts.ts create mode 100644 shared/src/i18n/nl/studioFonts.ts create mode 100644 shared/src/i18n/pl/studioFonts.ts create mode 100644 shared/src/i18n/ru/studioFonts.ts create mode 100644 shared/src/i18n/sk/studioFonts.ts create mode 100644 shared/src/i18n/sv/studioFonts.ts create mode 100644 shared/src/i18n/th/studioFonts.ts create mode 100644 shared/src/i18n/tr/studioFonts.ts create mode 100644 shared/src/i18n/uk/studioFonts.ts create mode 100644 shared/src/i18n/vi/studioFonts.ts create mode 100644 shared/src/i18n/zh-TW/studioFonts.ts create mode 100644 shared/src/i18n/zh/studioFonts.ts 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, `---