# Vernis sélectif brillant sur un magazine toucher doux

> Deux vernis en tons directs : toucher doux sur toutes les pages, brillant sur les photos et le titre du magazine, à voir dans Folio et les vues des finitions.

- Version HTML: https://postext.dev/fr/cookbook/spot-uv-photo-magazine
- Recette Nº 192 · Sortie et intégration · Niveau 3 (Avancé) · Sorties: Canvas, PDF
- Genres: Magazines et fanzines
- Nécessite postext ≥ 1.85.1, postext-pdf ≥ 1.85.1 · testée avec 1.86.0, postext-pdf 1.86.0 le 2026-11-14
- Pages: [1](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p01.webp?v=6e12ff76), [2](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p02.webp?v=6e12ff76), [3](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p03.webp?v=6e12ff76), [4](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p04.webp?v=6e12ff76), [5](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p05.webp?v=6e12ff76), [6](https://postext.dev/cookbook/spot-uv-photo-magazine/en/p06.webp?v=6e12ff76)
- PDF: https://postext.dev/cookbook/spot-uv-photo-magazine/en/spot-uv-photo-magazine.pdf?v=6e12ff76
- Ouvrir dans le Sandbox: https://postext.dev/fr/sandbox#recipe=spot-uv-photo-magazine&lang=en (.postext: https://postext.dev/cookbook/spot-uv-photo-magazine/en/spot-uv-photo-magazine.postext)
- Dernière mise à jour: 2026-11-13
- Autres langues: [en](https://postext.dev/en/cookbook/spot-uv-photo-magazine.md), [es](https://postext.dev/es/cookbook/spot-uv-photo-magazine.md), [ca](https://postext.dev/ca/cookbook/spot-uv-photo-magazine.md), [de](https://postext.dev/de/cookbook/spot-uv-photo-magazine.md), [it](https://postext.dev/it/cookbook/spot-uv-photo-magazine.md), [pt](https://postext.dev/pt/cookbook/spot-uv-photo-magazine.md), [zh](https://postext.dev/zh/cookbook/spot-uv-photo-magazine.md), [ja](https://postext.dev/ja/cookbook/spot-uv-photo-magazine.md), [ar](https://postext.dev/ar/cookbook/spot-uv-photo-magazine.md)

## En bref

Un magazine de photographie avec un fini velouté sur toutes les pages et un fini brillant seulement sur les photos et le titre. Les vernis n'ont pas de couleur ; la vue 3D et une vue d'épreuve montrent où ils se trouvent.

## Ce que vous allez composer

Le numéro 14 de *Long Light*, un magazine de photographie inventé : six pages de 210 × 280 mm, en dos carré collé. Toutes les pages reçoivent un vernis toucher doux, le fini velours qui éteint la feuille et lui ôte son éclat. Sur les cinq photographies et le titre du magazine, l'imprimeur pose un second vernis, brillant, pour que les images accrochent la lumière tandis que la page autour reste calme. Aucun des deux vernis n'a de couleur : la zone de rendu montre les pages telles qu'elles s'impriment, et trois vues de la couverture à côté de Folio montrent les plaques et le reflet. Folio ouvre le magazine sur une table de marbre sous une lumière de studio, où le brillant scintille quand une page tourne.

**Cette recette répond à:**

- Comment poser un vernis toucher doux sur toutes les pages et un vernis sélectif sur les photos ?

## La réponse courte

```js
// script.js, lignes 21–39
// A varnish is a spot ink: its own plate in the PDF, clear on screen. Soft touch goes over
// the whole sheet, the gloss over the pictures and the masthead. Both overprint by default,
// so neither cuts a hole in the colours under it. Each has a hex of its own all the same:
// a print render tells inks apart by their hex.
const varnish = (hex, name, sheen) => ({ hex, model: 'spot',
  spot: { name, cmyk: { c: 0, m: 0, y: 0, k: 0 }, finish: { kind: 'varnish', sheen } } });
const palette = {
  velvet: varnish('#e9e4f0', 'Soft-touch varnish', 'softTouch'),
  gloss: varnish('#e4f0ee', 'Spot UV gloss', 'gloss'),
  // The colours that print: a near-black, a slate for the bands, the paper.
  ink: { hex: '#1d1d22', model: 'cmyk', cmyk: { c: 30, m: 20, y: 10, k: 95 } },
  slate: { hex: '#262b3a', model: 'cmyk', cmyk: { c: 80, m: 65, y: 35, k: 60 } },
  muted: { hex: '#6c6a70', model: 'cmyk', cmyk: { c: 0, m: 5, y: 0, k: 65 } },
  paper: { hex: '#ffffff', model: 'hex' },
};
// The ink table names both varnishes as the order to the printer will.
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false, inks: [
  { name: 'Soft-touch varnish', finish: { kind: 'varnish', sheen: 'softTouch' } },
  { name: 'Spot UV gloss', finish: { kind: 'varnish', sheen: 'gloss' } }] };
```

## Ingrédients

**Enseigne**

- [Encres spéciales](https://postext.dev/fr/docs/special-inks-die-cuts.md#finitions): Un ton direct doté d’une finition : métallisé, dorure à chaud, fluorescent, blanc couvrant ou vernis. Il sort sur une plaque à lui, le canvas peut en montrer le brillant ou une carte des finitions, et Folio l’éclaire.

**Utilise aussi**

- [Tons directs et table des encres](https://postext.dev/fr/docs/configuration-pdf-output.md#tons-directs)
- [PDF en CMJN et en niveaux de gris](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#génération-pdf-configuration)
- [Visionneuse de livre en 3D (Folio)](https://postext.dev/fr/docs/configuration-html-folio-epub.md#un-livre-en-3d-postext-folio)
- [Papier, reliure, bureau et lumière (Folio)](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#visionneuse-folio-configuration)
- [Palette de couleurs sémantique](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#palette-de-couleurs)
- [Couvertures, pages de titre et colophons](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)
- [Styles de titre](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)
- [Ouvertures composées](https://postext.dev/fr/docs/configuration-headings.md#étendue-et-maquette-avancée)
- [Texte, filets et boîtes dans les maquettes de page](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page)
- [Images dans les maquettes de page](https://postext.dev/fr/docs/configuration-headers-footers.md#éléments-image)
- [Titres courants et folios](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page)
- [Export PDF](https://postext.dev/fr/docs/configuration-pdf-output.md#générer-des-pdf)
- [Pages sur un canvas](https://postext.dev/fr/docs/configuration-programmatic-usage.md#rendre-une-page-en-bitmap)
- [Attributs de titre](https://postext.dev/fr/docs/document-format.md#attributs-de-titre)
- [Bandeau de chapitre sur toute la largeur](https://postext.dev/fr/docs/configuration-headings.md#étendue-et-maquette-avancée)
- [Couleur du papier](https://postext.dev/fr/docs/configuration-page-layout.md#page)
- [Polices intégrées au PDF](https://postext.dev/fr/docs/configuration-pdf-output.md#pourquoi-un-fournisseur-de-polices)
- [Types de ressource personnalisés](https://postext.dev/fr/docs/configuration-resources.md#types-de-ressources)
- [Figures et tableaux comme ressources](https://postext.dev/fr/docs/document-format-resources.md#ressources)
- [Titres courants par section](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)
- [Chapitres non numérotés](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)

**La configuration en un coup d’œil**

- [`bodyText`](https://postext.dev/fr/docs/configuration-text.md#texte-courant), [`colorPalette`](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#palette-de-couleurs), [`folio`](https://postext.dev/fr/docs/configuration-html-folio-epub.md#apparence), [`footer`](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page), [`header`](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page), [`headingStyles`](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre), [`headings`](https://postext.dev/fr/docs/configuration-headings.md#titres), [`layout`](https://postext.dev/fr/docs/configuration-page-layout.md#mise-en-page), [`locale`](https://postext.dev/fr/docs/configuration-language.md#césure), [`page`](https://postext.dev/fr/docs/configuration-page-layout.md#page), [`print`](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#production-pour-limpression-configuration), [`resourceTypes`](https://postext.dev/fr/docs/configuration-resources.md#types-de-ressources)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/fr/docs/configuration-programmatic-usage.md#charger-les-polices-avant-la-mise-en-page), [`createFolioFromDocument`](https://postext.dev/fr/docs/configuration-html-folio-epub.md#un-livre-en-3d-postext-folio), [`decompressWoff2`](https://postext.dev/fr/docs/configuration-pdf-output.md#fournisseur-de-polices-dans-le-navigateur-fontsource--woff2), [`registerResourceImage`](https://postext.dev/fr/docs/architecture.md#surface-de-lapi), [`renderPageToCanvas`](https://postext.dev/fr/docs/configuration-programmatic-usage.md#rendre-une-page-en-bitmap), [`renderToPdf`](https://postext.dev/fr/docs/configuration-pdf-output.md#générer-des-pdf)

**Caractères**

- Bodoni Moda (OFL-1.1), Source Serif 4 (OFL-1.1), Source Sans 3 (OFL-1.1)

## Préparation

### 1 · Chaque vernis est un ton direct avec une finition

Le code est dans [la réponse courte](https://postext.dev/fr/cookbook/spot-uv-photo-magazine.md#la-réponse-courte) plus haut. Un vernis est une couleur d'accompagnement dont la finition est `varnish`, avec un aspect : `softTouch` pour le velours, `gloss` pour le vernis UV sélectif ([finitions](https://postext.dev/fr/docs/special-inks-die-cuts.md#finitions)). Le fichier PDF/X-4 place chacun sur une `Separation` à lui, et l'imprimeur reçoit deux plaques de vernis à côté des quatre plaques de quadrichromie. À l'écran, un vernis ne peint rien ; il lui faut quand même un hex à lui, parce qu'un rendu d'impression distingue les encres par leur hex. Un vernis est en surimpression par défaut, donc aucun des deux ne fait de réserve dans les couleurs qu'il recouvre.

### 2 · Le toucher doux sur toutes les pages

```js
// script.js, lignes 57–60
// The page's footer carries it, so every page has it. A varnish goes down last on press, and
// nothing painted after it cuts it away. The cover and the back keep it alone.
const velvet = { kind: 'box', id: 'velvet', style: { backgroundColor: col('velvet') },
  placement: at('bleed', 'top-left', 0, 0, { width: 'fill', height: 'fill' }) };
```

Le toucher doux est un seul bloc dans le vernis, de fond perdu à fond perdu. C'est le pied de page qui le porte, si bien que chaque page le reçoit d'un même endroit. Sur la presse, le vernis passe en dernier, par-dessus tout, et dans le PDF rien de ce que la page peint ensuite ne le réserve : le bloc pourrait aussi bien ouvrir l'en-tête, avant le texte et les folios, qui resteraient dessous sur la plaque. La couverture et la quatrième n'ont pas de folio, et leur pied de page ne porte que le bloc.

### 3 · Le brillant sur les photographies

```js
// script.js, lignes 64–69
// The gloss box comes after the picture, so it lies on top; being a varnish it paints
// nothing on the canvas, and in the PDF it overprints the picture on a plate of its own.
const glossed = (resourceId, placement, focus) => [
  { kind: 'image', id: 'photo', resourceId, fit: 'cover', placement, ...(focus && { focus }) },
  { kind: 'box', id: 'shine', style: { backgroundColor: col('gloss') }, placement },
];
```

Chaque photographie est une image recouverte d'un bloc de même taille dans le brillant. Le bloc vient en second, il se trouve donc au-dessus : sur la plaque, c'est un rectangle qui couvre l'image exactement, comme on dessine une forme de vernis sélectif.

### 4 · Le titre du magazine posé deux fois

```js
// script.js, lignes 73–90
const BAND = 222; // mm from the top of the bleed to the slate band
const masthead = (id, color) => text(id, '{titleText}', { fontFamily: DISPLAY, fontWeight: 700,
  fontSize: pt(84), lineHeight: 0.9, align: 'center', color },
at('page', 'top-left', 0, 12, { width: mm(TRIM_W) }));
const cover = { id: 'cover', numbered: false, toc: false, span: 'page',
  footer: { elements: [velvet] }, advancedDesign: { enabled: true, minHeight: mm(230),
    slot: { elements: [
      ...glossed('saltflat', at('bleed', 'top-left', 0, 0, { width: 'fill',
        height: mm(BAND + 3) }), { x: 0.5, y: 0.62 }),
      { kind: 'box', id: 'band', style: { backgroundColor: col('slate') },
        placement: at('bleed', 'top-left', 0, BAND, { width: 'fill', height: mm(70) }) },
      masthead('title', col('paper')), masthead('title-gloss', col('gloss')),
      text('issue', '{attr.issue}', { ...label(8, col('paper')), align: 'center' },
        at('page', 'top-left', 0, 46, { width: mm(TRIM_W) })),
      text('lines', '{attr.lines}', { fontFamily: SERIF, fontSize: pt(12), lineHeight: 1.35,
        color: col('paper') }, at('page', 'top-left', MARGIN.outer, BAND + 4,
        { width: mm(150) })),
    ] } } };
```

Le titre du magazine, ce sont deux éléments de texte au même endroit : l'un en blanc papier, en réserve dans la photographie, l'autre dans le brillant par-dessus. La version brillante ne peint rien à l'écran et donne à la plaque la forme des lettres : sur la couverture imprimée, le titre brille sur un ciel qui brille aussi.

### 5 · Les vues des finitions et Folio

```js
// script.js, lignes 239–259
// 'flat' paints the inks and leaves the varnish out; 'map' marks the special plates in false
// colour (varnish in cyan) over a faded page; 'sheen' sweeps a light across the page.
const views = document.createElement('section');
views.id = 'finish-views';
views.style.cssText = 'display: flex; gap: 16px; justify-content: center; padding: 16px';
const VIEWS = { flat: t({ en: 'As it prints', es: 'Como se imprime' }),
  map: t({ en: 'The varnish plates', es: 'Las planchas de barniz' }),
  sheen: t({ en: 'Under a raking light', es: 'Con luz rasante' }) };
for (const [finishes, name] of Object.entries(VIEWS)) {
  const [figure, canvas, caption] = ['figure', 'canvas', 'figcaption']
    .map((tag) => document.createElement(tag));
  figure.style.margin = '0';
  canvas.style.width = '260px';
  canvas.setAttribute('role', 'img');
  canvas.setAttribute('aria-label', `${t({ en: 'The cover', es: 'La cubierta' })}: ${name}`);
  renderPageToCanvas(doc.pages[0], doc, canvas, { scale: 520 / doc.pages[0].width, finishes });
  caption.textContent = name;
  figure.append(canvas, caption);
  views.append(figure);
}
document.getElementById('pages').before(views);
```

```js
// script.js, lignes 138–144
const folio = {
  tilt: 26, yaw: -18,
  paper: { type: 'coatedMatte', grammage: 150 },
  binding: { type: 'paperback', cover: 'pages' },
  surface: { type: 'marble' },
  lighting: { environment: 'studio', intensity: 1.15 },
};
```

`renderPageToCanvas` accepte une option `finishes`. `'flat'` est la valeur par défaut et montre la page telle qu'elle s'imprime ; `'map'` estompe la page et marque chaque plaque spéciale en fausses couleurs, le vernis en cyan, le brillant plus clair que le toucher doux ; `'sheen'` fait passer une lumière sur la page. Folio lit le même masque de finitions : le brillant accroche les reflets, le toucher doux les efface.

## La recette complète

Un seul fichier, composé à partir du dossier de la recette avec le texte d’exemple et le kit commun des Recettes déjà inclus ; il construit sa propre page. Pour l’exécuter, placez-le dans un `<script type="module">` d’une page vide ou collez-le dans le panneau JS d’un nouveau pen CodePen (en tant que module). Il importe postext depuis esm.sh : il n’y a rien à installer ni à compiler.

- Dossier de la recette: https://github.com/drnachio/postext/tree/main/cookbook/spot-uv-photo-magazine

### script.js

```js
// ═══ Postext Cookbook · Nº 192 · Spot gloss over a soft-touch magazine ═════════════════
// https://postext.dev/en/cookbook/spot-uv-photo-magazine
// Code: MIT · Text: original (CC BY 4.0) · Photographs: diffusion models
// Fonts: Bodoni Moda, Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.85.1
//
// A photography magazine whose pages are coated in a soft-touch varnish, with a gloss
// varnish laid over the photographs and the masthead only: the spot UV a printer sells as
// the contrast between a velvet page and a shining picture. Varnish puts no colour on the
// page, so the canvas shows the pages as they print and the finish views show the varnish.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createFolioFromDocument } from 'https://esm.sh/postext-folio';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'spot-uv-photo-magazine';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region answer: two varnishes, each a spot ink with a finish
// A varnish is a spot ink: its own plate in the PDF, clear on screen. Soft touch goes over
// the whole sheet, the gloss over the pictures and the masthead. Both overprint by default,
// so neither cuts a hole in the colours under it. Each has a hex of its own all the same:
// a print render tells inks apart by their hex.
const varnish = (hex, name, sheen) => ({ hex, model: 'spot',
  spot: { name, cmyk: { c: 0, m: 0, y: 0, k: 0 }, finish: { kind: 'varnish', sheen } } });
const palette = {
  velvet: varnish('#e9e4f0', 'Soft-touch varnish', 'softTouch'),
  gloss: varnish('#e4f0ee', 'Spot UV gloss', 'gloss'),
  // The colours that print: a near-black, a slate for the bands, the paper.
  ink: { hex: '#1d1d22', model: 'cmyk', cmyk: { c: 30, m: 20, y: 10, k: 95 } },
  slate: { hex: '#262b3a', model: 'cmyk', cmyk: { c: 80, m: 65, y: 35, k: 60 } },
  muted: { hex: '#6c6a70', model: 'cmyk', cmyk: { c: 0, m: 5, y: 0, k: 65 } },
  paper: { hex: '#ffffff', model: 'hex' },
};
// The ink table names both varnishes as the order to the printer will.
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false, inks: [
  { name: 'Soft-touch varnish', finish: { kind: 'varnish', sheen: 'softTouch' } },
  { name: 'Spot UV gloss', finish: { kind: 'varnish', sheen: 'gloss' } }] };
// #endregion
const col = (id) => ({ ...palette[id], paletteId: id });
const colorPalette = [...Object.entries(palette).map(([id, value]) => ({ id, name: id, value })),
  { id: 'main-color', name: 'ink (defaults)', value: palette.ink }];

const [TRIM_W, TRIM_H] = [210, 280];
const MARGIN = { top: 18, bottom: 20, inner: 18, outer: 16 };
const LEAD = 13.6; // pt
const [DISPLAY, SERIF, SANS] = ['Bodoni Moda', 'Source Serif 4', 'Source Sans 3'];
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, align: 'left',
  overflow: 'wrap', placement, ...look });
const label = (size, color) => ({ fontFamily: SANS, fontWeight: 700, fontSize: pt(size),
  letterSpacing: pt(size * 0.16), textTransform: 'uppercase', color });

// #region velvet: soft touch over every page, a box in the varnish to the bleed
// The page's footer carries it, so every page has it. A varnish goes down last on press, and
// nothing painted after it cuts it away. The cover and the back keep it alone.
const velvet = { kind: 'box', id: 'velvet', style: { backgroundColor: col('velvet') },
  placement: at('bleed', 'top-left', 0, 0, { width: 'fill', height: 'fill' }) };
// #endregion

// #region gloss: a photograph with a gloss box laid over it, the same size
// The gloss box comes after the picture, so it lies on top; being a varnish it paints
// nothing on the canvas, and in the PDF it overprints the picture on a plate of its own.
const glossed = (resourceId, placement, focus) => [
  { kind: 'image', id: 'photo', resourceId, fit: 'cover', placement, ...(focus && { focus }) },
  { kind: 'box', id: 'shine', style: { backgroundColor: col('gloss') }, placement },
];
// #endregion

// #region cover: the masthead set twice, in paper white and again in the gloss
const BAND = 222; // mm from the top of the bleed to the slate band
const masthead = (id, color) => text(id, '{titleText}', { fontFamily: DISPLAY, fontWeight: 700,
  fontSize: pt(84), lineHeight: 0.9, align: 'center', color },
at('page', 'top-left', 0, 12, { width: mm(TRIM_W) }));
const cover = { id: 'cover', numbered: false, toc: false, span: 'page',
  footer: { elements: [velvet] }, advancedDesign: { enabled: true, minHeight: mm(230),
    slot: { elements: [
      ...glossed('saltflat', at('bleed', 'top-left', 0, 0, { width: 'fill',
        height: mm(BAND + 3) }), { x: 0.5, y: 0.62 }),
      { kind: 'box', id: 'band', style: { backgroundColor: col('slate') },
        placement: at('bleed', 'top-left', 0, BAND, { width: 'fill', height: mm(70) }) },
      masthead('title', col('paper')), masthead('title-gloss', col('gloss')),
      text('issue', '{attr.issue}', { ...label(8, col('paper')), align: 'center' },
        at('page', 'top-left', 0, 46, { width: mm(TRIM_W) })),
      text('lines', '{attr.lines}', { fontFamily: SERIF, fontSize: pt(12), lineHeight: 1.35,
        color: col('paper') }, at('page', 'top-left', MARGIN.outer, BAND + 4,
        { width: mm(150) })),
    ] } } };
// #endregion

// A story opens on a photograph to the bleed, glossed, the kicker and the title under it.
const story = { id: 'story', numbered: false, span: 'page', advancedDesign: { enabled: true,
  minHeight: mm(150), slot: { elements: [
    ...glossed('{attr.photo}', at('bleed', 'top-left', 0, 0, { width: 'fill', height: mm(160) })),
    text('kicker', '{attr.kicker}', label(7.5, col('muted')),
      at('page', 'top-left', MARGIN.outer, 166)),
    text('title', '{titleText}', { fontFamily: DISPLAY, fontWeight: 700, fontSize: pt(30),
      lineHeight: 1, color: col('ink') }, at('#kicker', 'below', 0, 2,
      { width: mm(170) })),
  ] } } };

// The back: a slate flood, the masthead again in white and gloss, the colophon under it.
const back = { id: 'back', numbered: false, toc: false, span: 'page',
  breakBefore: { enabled: true, parity: 'even' }, footer: { elements: [velvet] },
  advancedDesign: { enabled: true, minHeight: mm(240), slot: { elements: [
    { kind: 'box', id: 'flood', style: { backgroundColor: col('slate') },
      placement: at('bleed', 'top-left', 0, 0, { width: 'fill', height: 'fill' }) },
    { ...masthead('title', col('paper')), placement: at('page', 'top-left', 0, 110,
      { width: mm(TRIM_W) }) },
    { ...masthead('title-gloss', col('gloss')), placement: at('page', 'top-left', 0, 110,
      { width: mm(TRIM_W) }) },
    text('colophon', '{attr.colophon}', { fontFamily: SANS, fontSize: pt(8), lineHeight: 1.45,
      align: 'center', color: col('paper') }, at('page', 'top-left', 40, 150,
      { width: mm(130) })),
  ] } } };

// The editorial: a second dusk inside the margins, glossed, the kicker and the title under it.
const editorial = { id: 'editorial', numbered: false, span: 'page', advancedDesign: {
  enabled: true, minHeight: mm(120), slot: { elements: [
    ...glossed('dusk', at('container', 'top-left', 0, 0, { width: 'fill', height: mm(104) }),
      { x: 0.5, y: 0.6 }),
    text('kicker', '{attr.kicker}', label(7.5, col('muted')), at('container', 'top-left', 0, 109)),
    text('title', '{titleText}', { fontFamily: DISPLAY, fontWeight: 700, fontSize: pt(30),
      lineHeight: 1, color: col('ink') }, at('#kicker', 'below', 0, 2, { width: mm(170) })),
  ] } } };

const footer = { elements: [
  text('folio', '{pageNumber}  ·  {title}', { ...label(6.5, col('muted')), parity: 'even' },
    at('page', 'bottom-left', MARGIN.outer, -11)),
  text('folio-r', '{chapterTitle}  ·  {pageNumber}', { ...label(6.5, col('muted')),
    parity: 'odd', align: 'right' }, at('page', 'bottom-right', -MARGIN.outer, -11)),
  velvet,
] };

// #region folio: a perfect-bound magazine in studio light, where the gloss catches
const folio = {
  tilt: 26, yaw: -18,
  paper: { type: 'coatedMatte', grammage: 150 },
  binding: { type: 'paperback', cover: 'pages' },
  surface: { type: 'marble' },
  lighting: { environment: 'studio', intensity: 1.15 },
};
// #endregion

const config = () => ({
  locale: t({ en: 'en-gb', es: 'es' }),
  colorPalette,
  page: { sizePreset: 'custom', width: mm(TRIM_W), height: mm(TRIM_H), dpi: 150,
    backgroundColor: col('paper'), margins: { top: mm(MARGIN.top), bottom: mm(MARGIN.bottom),
      left: mm(MARGIN.inner), right: mm(MARGIN.outer), mirror: true } },
  layout: { layoutType: 'double', gutterWidth: mm(6) },
  bodyText: { fontFamily: SERIF, fontSize: pt(9.8), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), textAlign: 'justify',
    firstLineIndent: mm(4), indentAfterHeading: false, hyphenation: { enabled: true },
    avoidWidows: true, avoidOrphans: true },
  headings: { fontFamily: SANS, fontWeight: 700, color: col('ink'), levels: [
    { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'any' } }] },
  headingStyles: [cover, editorial, story, back],
  print: PRINT,
  header: { elements: [] }, footer, folio,
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
const markdown = String.raw`---
title: "Long Light"
---

# Long Light {style="cover" issue="Nº 14 · Winter 2026 · Photographs made at the edges of the day" lines="The net mender of Cangas · A forest that keeps its fog · Four hundred kilometres of road and one bend"}

# The hour before {style="editorial" kicker="Editorial"}

Every photograph in this issue was made in the first or the last hour of daylight, when the sun is low enough to throw a shadow longer than the thing that casts it. Photographers call it the golden hour, though half of it is blue. We asked four contributors to go out in it and bring back one picture each, and to tell us what they were doing there.

What came back is a quiet issue. A man mending a net he has mended for fifty years. A forest that holds its fog until ten in the morning. A road that runs straight for so long that the one bend in it has a name. And on the cover, a walker on a salt flat who did not know he was being photographed, and who kept walking until he was a dot against the dusk.

We have printed this issue on a matte paper with a soft-touch coat, and laid a gloss varnish over the photographs alone. Turn the page under a lamp and the pictures catch the light while the page around them stays dark and still. It is the closest a magazine can come to a print on a wall.

# The net mender {style="story" photo="nets" kicker="Portrait · Cangas, Galicia"}

Manuel Lires has mended nets on the same stretch of the quay at Cangas since he was fourteen. He is sixty-six now, and the boats he mends for belong to the grandsons of the men who first paid him. He starts at six, before the light, and works by feel until the sun comes over the hill behind the town and he can see the knots.

The net in the photograph is a trawl, forty metres of orange polyethylene that came back from the bank with a tear the length of a man. He finds the edge of the damage, cuts it square, and knits in new mesh with a wooden needle that his father carved. A good mender, he says, can tell from the tension of the twine whether the net was torn on rock or by a fish.

Our photographer spent three mornings on the quay before Manuel stopped looking up. The picture was made on the third, in the ten minutes when the sun was low enough to light the net from behind and turn it into something that glowed. He did not look at it until we sent him a print. He said the knots were right.

# A forest that keeps its fog {style="story" photo="fog" kicker="Landscape · Irati, Navarre"}

The beech and pine forest of Irati sits in a bowl of the western Pyrenees, and on still autumn mornings it fills with fog like water in a basin. The fog stays until the sun is high enough to reach over the rim, which in November is after ten. Until then the forest is grey and close, and sound does not carry.

Our photographer walked in at seven with a tripod and a flask and waited by a stand of pines where a gap in the canopy faces east. At twenty past nine a beam came through the gap and lay across the fog for four minutes. She made eleven frames and kept one.

The picture is about the waiting, she says. The beam lasted four minutes, but the forest had been getting ready for it all morning.

# The bend {style="story" photo="road" kicker="Travel · Utah"}

For four hundred kilometres the road south of Moab runs nearly straight, and the drivers who know it give names to the few places where it does not. The bend in this photograph is called the Elbow, though it turns by no more than a few degrees. Coming at it from the north at dusk, with the mesas lit red on either side, it is the first thing in an hour that the eye can hold on to.

Our contributor drove the road three times in one week, each time leaving later, until the light fell where he wanted it: across the asphalt, so that the centre line burned yellow and the verges went to shadow. He stood in the middle of the road to make the picture. Nothing came in either direction for twenty minutes.

# Long Light {style="back" colophon="Long Light is published four times a year. Photographs printed on 150 g matte coated paper, soft-touch varnish over every page, spot gloss over the photographs and the masthead. Nº 14, winter 2026."}
`; // content.<lang>.md, inlined by the Cookbook

const photo = (id, [w, h], altText) => ({ id, typeId: 'photo', kind: 'bitmap',
  createdAt: 0, updatedAt: 0, bitmap: { fileId: `${id}.jpg`, format: 'jpeg', width: w,
    height: h }, altText });
const resourceTypes = [{ id: 'photo', name: '', captionPrefix: '', numberingTemplate: '' }];
const resources = [
  photo('saltflat', [800, 1200], t({ en: 'A lone figure in a long coat '
    + 'crossing a cracked salt flat at dusk.', es: 'Una figura sola con abrigo largo cruza un '
    + 'salar agrietado al anochecer.' })),
  photo('nets', [1100, 733], t({ en: 'An old fisherman mending an orange net '
    + 'on a harbour quay.', es: 'Un pescador mayor remienda una red naranja en el muelle.' })),
  photo('fog', [800, 1000], t({ en: 'Pine trunks fading into morning fog.',
    es: 'Troncos de pino que se pierden en la niebla de la mañana.' })),
  photo('road', [1100, 733], t({ en: 'An empty desert road running between '
    + 'red mesas.', es: 'Una carretera vacía en el desierto entre mesetas rojas.' })),
  photo('dusk', [560, 840], t({ en: 'The salt flat again, the sun on the '
    + 'horizon.', es: 'El salar otra vez, con el sol en el horizonte.' })),
];
await Promise.all([loadImage('saltflat.jpg', asset('saltflat-800.jpg')),
  loadImage('nets.jpg', asset('nets-1100.jpg')), loadImage('fog.jpg', asset('fog-800.jpg')),
  loadImage('road.jpg', asset('road-1100.jpg')), loadImage('dusk.jpg', asset('dusk-560.jpg'))]);

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { 'Bodoni Moda': ['700'], 'Source Serif 4': ['400', '400i', '700'],
  'Source Sans 3': ['400', '700'] };

// ─── 4 · Build & show ───────────────────────────────────────────────────────
const doc = await buildDocumentWithFonts({ markdown, resources }, { ...config(), resourceTypes },
  kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Long Light · spot gloss over a soft-touch magazine',
  es: 'Long Light · brillo selectivo sobre una revista en tacto suave' }) });
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes,
  profileBaseUrl: 'https://postext.dev/icc/' }), `${RECIPE}.pdf`);

// #region views: the cover as it prints, as a proof maps the varnish, and in a raking light
// 'flat' paints the inks and leaves the varnish out; 'map' marks the special plates in false
// colour (varnish in cyan) over a faded page; 'sheen' sweeps a light across the page.
const views = document.createElement('section');
views.id = 'finish-views';
views.style.cssText = 'display: flex; gap: 16px; justify-content: center; padding: 16px';
const VIEWS = { flat: t({ en: 'As it prints', es: 'Como se imprime' }),
  map: t({ en: 'The varnish plates', es: 'Las planchas de barniz' }),
  sheen: t({ en: 'Under a raking light', es: 'Con luz rasante' }) };
for (const [finishes, name] of Object.entries(VIEWS)) {
  const [figure, canvas, caption] = ['figure', 'canvas', 'figcaption']
    .map((tag) => document.createElement(tag));
  figure.style.margin = '0';
  canvas.style.width = '260px';
  canvas.setAttribute('role', 'img');
  canvas.setAttribute('aria-label', `${t({ en: 'The cover', es: 'La cubierta' })}: ${name}`);
  renderPageToCanvas(doc.pages[0], doc, canvas, { scale: 520 / doc.pages[0].width, finishes });
  caption.textContent = name;
  figure.append(canvas, caption);
  views.append(figure);
}
document.getElementById('pages').before(views);
// #endregion

// The magazine on a marble table, open on the first story, where the gloss shines.
const stage = document.createElement('section');
stage.id = 'folio';
stage.ariaLabel = t({ en: 'The magazine in 3D', es: 'La revista en 3D' });
stage.style.cssText = 'height: min(78vh, 720px); margin: 0 auto; max-width: 1280px';
views.before(stage);
createFolioFromDocument(stage, doc, { at: 2,
  appearance: { textureBaseUrl: 'https://postext.dev/folio/textures' } });

// ─── Kit ── helpers shared by every Cookbook recipe · postext.dev/cookbook ─────

// ─── Kit · core v1 ── the same in every recipe · postext.dev/cookbook
function mm(value) { return { value, unit: 'mm' }; }
function pt(value) { return { value, unit: 'pt' }; }
function em(value) { return { value, unit: 'em' }; }
/** The sample language's string: t({ en: 'Figure', es: 'Figura' }). */
function t(strings) { return strings[LANG] ?? Object.values(strings)[0]; }
/** A file in this recipe's assets folder, served from the Postext repo by jsDelivr. */
function asset(file) { return `https://cdn.jsdelivr.net/gh/drnachio/postext@main/cookbook/${RECIPE}/assets/${file}`; }

// ─── Kit · fonts v3 ── the same in every recipe · postext.dev/cookbook
// Postext loads the faces a config asks for before layout and asks the kit
// for Fontsource's files, the ones the PDF embeds too.

/** buildDocumentWithFonts' options: the resolver, and FONTS' faces loaded
 *  with the config's. FONTS = { 'Family Name': ['400', '400i', '700'] }. */
function kitFonts(FONTS = {}) {
  const faces = Object.entries(FONTS).flatMap(([family, specs]) => specs.map((spec) =>
    ({ family, weight: parseInt(spec, 10), style: spec.endsWith('i') ? 'italic' : 'normal' })));
  return { resolve: fontsourceResolver, faces };
}

/** A face's files with their ranges: latin, then latin-ext and greek when
 *  `text` needs them (kitSubsetsFor). Null for a face Fontsource lacks. */
async function fontsourceResolver(family, weight, style, { text = '' } = {}) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  if (meta && !(await fontsourceWeights(family, style)).includes(weight)) return null;
  kitStatus('Loading fonts…');
  const at = await fontsourceAt(id);
  return ['latin', ...kitSubsetsFor(text, meta)].map((subset) => ({
    source: `${at}files/${id}-${subset}-${weight}-${style}.woff2`,
    unicodeRange: kitRanges()[subset],
  }));
}

/** Each file's unicode-range (a function: the kit runs after the pen's code). */
function kitRanges() {
  return {
    latin: 'U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,'
      + 'U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD',
    'latin-ext': 'U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,'
      + 'U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF',
    greek: 'U+0370-03FF',
  };
}

/** For the cjk, arabic and comics blocks: loads `faces` (as FONTS) for the
 *  sample `text`; `optional` skips a face Fontsource lacks. Files are added in
 *  the order asked, the last winning a shared character. Resolves to the count. */
async function loadFonts(faces, text = '', { optional = false } = {}) {
  kitStatus('Loading fonts…');
  const ranges = kitRanges();
  const jobs = [];
  for (const [family, specs] of Object.entries(faces)) {
    const id = fontsourceId(family);
    const todo = [...new Set(specs)].map((spec) => [parseInt(spec, 10), spec.endsWith('i') ? 'italic' : 'normal'])
      .filter(([weight, style]) => !hasFace(family, weight, style)); // before any await
    const at = fontsourceAt(id);
    const meta = optional || /[^\0-ÿ]/u.test(text) ? await fontsourceMeta(family) : null;
    const subsets = ['latin', ...kitSubsetsFor(text, meta)];
    for (const [weight, style] of todo) {
      if (optional && !(meta && (await fontsourceWeights(family, style)).includes(weight))) continue;
      for (const subset of subsets) {
        const url = `${await at}files/${id}-${subset}-${weight}-${style}.woff2`;
        const face = new FontFace(family, `url(${url}) format('woff2')`,
          { weight: String(weight), style, unicodeRange: ranges[subset] });
        jobs.push(face.load().catch(() => {
          if (subset === 'latin' && !optional) throw new Error(`Fontsource has no ${family} ${weight} ${style}`);
        }));
      }
    }
  }
  const ready = await Promise.all(jobs).catch((error) => { kitFail(error); throw error; });
  return ready.filter((face) => face && document.fonts.add(face)).length;
}

/** A loaded FontFace covers this face (fonts.check() says yes to any family). */
function hasFace(family, weight, style) {
  for (const face of document.fonts) {
    if (face.status !== 'loaded' || face.style !== style) continue;
    if (face.family.replace(/^["']|["']$/g, '') !== family) continue;
    const [low, high = low] = face.weight.split(' ').map(Number);
    if (weight >= low && weight <= high) return true;
  }
  return false;
}

/** The files beyond latin `text` needs that `meta`'s family ships. */
function kitSubsetsFor(text, meta) {
  return [[/[Ā-˿ᴀ-ᶿḀ-ỿ†ℓⱠ-Ɀ꜠-ꟿ]/u, 'latin-ext'], [/[Ͱ-Ͽ]/u, 'greek']]
    .filter(([re, x]) => re.test(text) && meta?.subsets?.includes(x)).map(([, x]) => x);
}

/** Fontsource's id for a family: 'Source Serif 4' → 'source-serif-4'. */
function fontsourceId(family) { return family.toLowerCase().replace(/\s+/g, '-'); }

/** A package's folder at the one version @5 names now (#766). */
function fontsourceAt(id, u = `https://cdn.jsdelivr.net/npm/@fontsource/${id}@`) {
  return (fontsourceAt.c ??= {})[id] ??= fetch(u + '5/package.json').then((r) => r.json())
    .then((p) => p.version || 5, () => 5).then((v) => `${u}${v}/`);
}

/** The family's Fontsource metadata (weights, styles, subsets), or null. */
function fontsourceMeta(family, id = fontsourceId(family)) {
  return (fontsourceMeta.c ??= {})[id] ??= fetch(`https://api.fontsource.org/v1/fonts/${id}`)
    .then((res) => (res.ok ? res.json() : null), () => null);
}

/** The weights the package ships in `style`: the API pairs none (no Libre
 *  Caslon 700 italic file), so italics are read from latin-italic.css. */
function fontsourceWeights(family, style, id = fontsourceId(family)) {
  return (fontsourceWeights.c ??= {})[id + style] ??= fontsourceMeta(family).then(async (m) => {
    if (!m?.styles.includes(style)) return m ? [] : [400, 700];
    const css = style === 'italic' ? await fetch(`${await fontsourceAt(id)}latin-italic.css`).then((r) => (r.ok ? r.text() : ''), () => '') : '';
    const w = [...css.matchAll(/weight: (\d+)/g)].map((x) => +x[1]);
    return w.length ? w : m.weights;
  });
}

// ─── Kit · viewer v2 ── the same in every recipe · postext.dev/cookbook
/** The pages as spreads on a dark desk, page 1 alone, then verso | recto,
 *  each painted when it scrolls near. Other options go to renderPageToCanvas. */
function showPages(docs, { title, width = 460, ...render } = {}) {
  const root = viewer(title);
  const pages = [docs].flat().flatMap((doc) =>
    doc.pages.map((page) => ({ doc, page, n: (doc.pageIndexOffset ?? 0) + page.index })));
  const spreads = [];
  let verso = null;
  for (const p of pages) {
    if (p.n % 2 === 1) { if (verso) spreads.push([verso, null]); verso = p; }
    else { spreads.push([verso, p]); verso = null; }
  }
  if (verso) spreads.push([verso, null]);
  const density = Math.min(window.devicePixelRatio || 1, 2);
  showPages.painter?.disconnect();
  const painter = new IntersectionObserver((entries) => {
    for (const { isIntersecting, target } of entries) {
      if (!isIntersecting) continue;
      painter.unobserve(target);
      const { doc, page } = target.postext;
      renderPageToCanvas(page, doc, target, { ...render, scale: (width * density) / page.width });
    }
  }, { rootMargin: '800px' });
  showPages.painter = painter;
  root.replaceChildren(...spreads.map((pair) => {
    const spread = document.createElement('div');
    spread.className = 'pt-spread';
    for (const p of pair) {
      const figure = document.createElement('figure');
      if (p) {
        const label = p.page.pageLabel || String(p.n + 1);
        const canvas = document.createElement('canvas');
        canvas.postext = p;
        canvas.style.aspectRatio = `${p.page.width} / ${p.page.height}`;
        canvas.setAttribute('role', 'img');
        canvas.setAttribute('aria-label', `Page ${label}`);
        const folio = document.createElement('figcaption');
        folio.textContent = label;
        figure.append(canvas, folio);
        painter.observe(canvas);
      } else figure.className = 'pt-blank';
      spread.append(figure);
    }
    return spread;
  }));
  kitStatus(`${pages.length} ${pages.length === 1 ? 'page' : 'pages'}`);
  document.documentElement.dataset.postext = 'ready';
  return pages.length;
}

/** The desk, the bar and the error reporting, created once. */
function viewer(title) {
  if (!document.getElementById('pt-kit')) {
    document.head.insertAdjacentHTML('beforeend', `<style id="pt-kit">
      :root { color-scheme: dark; }
      body { margin: 0; background: #0e1014; color: #b9bcc4; font: 13px/1.45 system-ui, sans-serif; }
      #pt-bar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; align-items: center;
        gap: 6px 16px; padding: 10px 16px; background: rgb(14 16 20 / .92); backdrop-filter: blur(6px);
        border-bottom: 1px solid #23262d; }
      #pt-bar strong { color: #f4f1ea; font-weight: 600; }
      #pt-actions { display: flex; gap: 12px; margin-left: auto; }
      #pt-actions a, #pt-actions button { color: #d8a21a; font: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
      #pages { display: grid; justify-items: center; gap: 48px; padding: 32px 16px 72px; }
      .pt-spread { display: flex; }
      .pt-spread figure { margin: 0; width: min(460px, 44vw); }
      .pt-spread canvas { display: block; width: 100%; background: #fff;
        box-shadow: 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figure:first-child canvas { box-shadow: inset -14px 0 14px -14px rgb(0 0 0 / .18), 0 1px 2px rgb(0 0 0 / .5), 0 22px 44px -16px rgb(0 0 0 / .8); }
      .pt-spread figcaption { margin-top: 10px; text-align: center; font: 600 10px/1 system-ui, sans-serif;
        letter-spacing: .18em; text-transform: uppercase; color: #6c7079; }
      .pt-blank { visibility: hidden; }
      @media (max-width: 760px) {
        .pt-spread { flex-direction: column; gap: 32px; }
        .pt-spread figure { width: min(460px, 92vw); }
        .pt-blank { display: none; }
      }
    </style>`);
    document.body.insertAdjacentHTML('afterbegin',
      '<header id="pt-bar"><strong id="pt-title"></strong><span id="pt-status" role="status"></span><span id="pt-actions"></span></header>');
    document.getElementById('pt-title').textContent = document.title || 'Postext';
    addEventListener('error', (event) => kitFail(event.error ?? event.message));
    addEventListener('unhandledrejection', (event) => kitFail(event.reason));
  }
  if (title) document.getElementById('pt-title').textContent = title;
  return document.getElementById('pages')
    ?? document.body.appendChild(Object.assign(document.createElement('main'), { id: 'pages' }));
}

function kitStatus(text) {
  viewer();
  document.getElementById('pt-status').textContent = text;
}

function kitFail(error) {
  document.documentElement.dataset.postext = 'error';
  kitStatus(`Error: ${error?.message ?? error}`);
}

// ─── Kit · pdf v3 ── the same in every recipe that exports a PDF
/** The Fontsource files the screen used, as TrueType, with their range and
 *  place: the nearest weight the family ships in that style, upright with no italic;
 *  latin, then what its letters need (kitSubsetsFor). */
async function fontsourceProvider(family, weight, style, request) {
  const id = fontsourceId(family);
  const meta = await fontsourceMeta(family);
  const s = style === 'italic' && meta && !meta.styles.includes('italic') ? 'normal' : style;
  const shipped = meta ? await fontsourceWeights(family, s) : [];
  const weights = shipped.length ? shipped : [400, 700];
  const w = weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a));
  const text = String.fromCodePoint(...(request?.codePoints ?? []));
  const files = await Promise.all(['latin', ...kitSubsetsFor(text, meta)].map(async (subset, order) => {
    const res = await fetch(`${await fontsourceAt(id)}files/${id}-${subset}-${w}-${s}.woff2`);
    if (!res.ok) throw new Error(`Fontsource has no ${family} ${w} ${s} ${subset}`);
    return Object.assign(await decompressWoff2(new Uint8Array(await res.arrayBuffer())),
      { unicodeRange: kitRanges()[subset], order });
  }));
  return files.length === 1 ? files[0] : files;
}

/** A "Build the PDF" button; then "Open the PDF" (a new tab: CodePen's frame
 *  shows no PDFs) and a download link. */
function offerPdf(makePdf, filename) {
  viewer();
  const button = Object.assign(document.createElement('button'), { type: 'button', textContent: 'Build the PDF' });
  button.dataset.postextPdf = filename;
  button.addEventListener('click', async () => {
    button.disabled = true;
    button.textContent = 'Building the PDF…';
    try {
      const bytes = await makePdf();
      const url = URL.createObjectURL(new Blob([bytes], { type: 'application/pdf' }));
      const size = `${Math.max(1, Math.round(bytes.length / 1024))} KB`;
      button.replaceWith(
        Object.assign(document.createElement('a'), { href: url, target: '_blank', rel: 'noopener', textContent: 'Open the PDF ↗' }),
        Object.assign(document.createElement('a'), { href: url, download: filename, textContent: `Download ${filename} · ${size}` }));
    } catch (error) {
      button.disabled = false;
      button.textContent = 'Build the PDF';
      kitFail(error);
    }
  });
  document.getElementById('pt-actions').append(button);
}

// ─── Kit · images v3 ── recipes with pictures · postext.dev/cookbook
/** Registers a photo or PNG for the canvas and keeps its bytes for the PDF.
 *  fetch → ImageBitmap never taints the canvas (a plain cross-origin <img> would). */
async function loadImage(fileId, url) {
  const res = await fetch(url);
  if (!res.ok) throw new Error(`Image not found (${res.status}): ${url}`);
  const bytes = new Uint8Array(await res.arrayBuffer());
  registerResourceImage(fileId, await createImageBitmap(new Blob([bytes])));
  (loadImage.bytes ??= new Map()).set(fileId, bytes);
}

/** Registers SVG markup as a vector image, its fonts inside (inlineSvgFonts, ≥ 1.25).
 *  `options` go to registerResourceImage: { singleInk: true } tints it on the canvas. */
async function loadSvg(fileId, svg, options) {
  if (typeof inlineSvgFonts === 'function') svg = await inlineSvgFonts(svg, svgFaces);
  const img = new Image();
  img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;
  await img.decode();
  registerResourceImage(fileId, img, options);
  (loadImage.bytes ??= new Map()).set(fileId, new TextEncoder().encode(svg));
}

/** A face's Fontsource files: nearest weight; latin + what the SVG sets. */
async function svgFaces(family, weight, style, { codePoints = [] } = {}) {
  const [id, m] = [fontsourceId(family), await fontsourceMeta(family)];
  const w = m?.weights.reduce((a, b) => (Math.abs(b - weight) < Math.abs(a - weight) ? b : a)) ?? weight;
  const s = m?.styles.includes(style) === false ? 'normal' : style;
  return Promise.all(['latin', ...kitSubsetsFor(String.fromCodePoint(...codePoints), m)].map(async (x) => new Uint8Array(
    await (await fetch(`${await fontsourceAt(id)}files/${id}-${x}-${w}-${s}.woff2`)).arrayBuffer())));
}

/** renderToPdf({ resourceBytes: imageBytes }) */
function imageBytes(fileId) { return loadImage.bytes?.get(fileId); }

/** renderToHtml({ resourceImageUrl: imageUrl }) */
function imageUrl(fileId) {
  const bytes = imageBytes(fileId);
  if (!bytes) return undefined;
  imageUrl.urls ??= new Map();
  if (!imageUrl.urls.has(fileId)) {
    const type = /\.svg$/i.test(fileId) ? 'image/svg+xml' : /\.png$/i.test(fileId) ? 'image/png' : 'image/jpeg';
    imageUrl.urls.set(fileId, URL.createObjectURL(new Blob([bytes], { type })));
  }
  return imageUrl.urls.get(fileId);
}

// ─── /Kit ───────────────────────────────────────────────────────────────────────
```

## Variantes

### Du mat à la place du toucher doux

Un simple vernis mat coûte moins cher et donne le même contraste, un peu moins profond.

```diff
-  velvet: varnish('#e9e4f0', 'Soft-touch varnish', 'softTouch'),
+  velvet: varnish('#e9e4f0', 'Matte varnish', 'matte'),
```

### Du brillant sur la lettre seulement

Laissez les photographies mates et posez le brillant sur le titre du magazine et les titres seuls : composez les titres deux fois, comme le titre du magazine, et retirez les blocs posés sur les images.

## Erreurs fréquentes

- Un vernis qui a l'hex d'une autre couleur s'imprime comme cette couleur. Donnez à chaque vernis un hex que rien d'autre n'utilise.
- Un vernis général arrêté au format laisse une bande nue au bord quand la feuille est coupée un peu de travers. Menez-le jusqu'au fond perdu, comme le bloc d'ici.
- Le toucher doux se vend souvent comme un pelliculage plutôt que comme un vernis. Demandez à l'imprimeur quel nom de plaque il veut, et indiquez-le avec `pdfName` dans la table des encres.

## Crédits

- Recette: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Images: A walker on a salt flat at dusk, on the cover: Generated With Diffusion Models, original
- Images: A fisherman mending a net: Generated With Diffusion Models, original
- Images: Pines in morning fog: Generated With Diffusion Models, original
- Images: A desert road between mesas: Generated With Diffusion Models, original
- Images: The salt flat at sunset, on the back cover: Generated With Diffusion Models, original
- Caractères: Bodoni Moda (OFL-1.1), Source Serif 4 (OFL-1.1), Source Sans 3 (OFL-1.1)
- Code: MIT · Contenu d’exemple: CC-BY-4.0

## Recettes liées

- [Nº 188 · Dorure à chaud sur une couverture bleu nuit](https://postext.dev/fr/cookbook/gold-foil-poetry-cover.md): La dorure comme ton direct avec une finition : sa propre plaque dans le PDF, l’éclat dans Folio, et une carte bleue et un vélin crème sans encre. · Niveau 3 (Avancé) · Poésie
- [Nº 190 · Un fanzine en noir et rose fluo](https://postext.dev/fr/cookbook/fluorescent-pink-zine.md): Un travail sur deux plaques, noir et un rose fluorescent : photos en duotone, un noir en surimpression et un rose qui brille dans Folio. · Niveau 3 (Avancé) · Magazines et fanzines
- [Nº 102 · Un zine agrafé avec une feuille de couverture en carte](https://postext.dev/fr/cookbook/saddle-stitched-card-cover.md): Deux blocs :::paper mettent une carte saumon en feuille extérieure d’un zine de huit pages, que postext-folio montre agrafé autour de pages en papier journal. · Niveau 2 (Intermédiaire) · Magazines et fanzines
