# Lucido serigrafico su una rivista soft touch

> Due vernici come tinte piatte: soft touch su ogni pagina e lucida sulle foto e sulla testata, viste in Folio e nelle viste delle finiture.

- Versione HTML: https://postext.dev/it/cookbook/spot-uv-photo-magazine
- Ricetta Nº 192 · Output e integrazione · Livello 3 (Avanzato) · Output: Canvas, PDF
- Generi: Riviste e fanzine
- Richiede postext ≥ 1.85.1, postext-pdf ≥ 1.85.1 · provata con 1.86.0, postext-pdf 1.86.0 il 2026-11-14
- Pagine: [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
- Apri nella Sandbox: https://postext.dev/it/sandbox#recipe=spot-uv-photo-magazine&lang=en (.postext: https://postext.dev/cookbook/spot-uv-photo-magazine/en/spot-uv-photo-magazine.postext)
- Ultimo aggiornamento: 2026-11-13
- Altre lingue: [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), [fr](https://postext.dev/fr/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)

## In breve

Una rivista di fotografia con un rivestimento vellutato su ogni pagina e uno lucido solo sulle foto e sul titolo. Le vernici non hanno colore; la vista 3D e una vista di prova mostrano dove si trovano.

## Che cosa comporrai

Il numero 14 di *Long Light*, una rivista di fotografia inventata: sei pagine da 210 × 280 mm, in brossura fresata. Ogni pagina ha una vernice soft touch, la finitura vellutata che spegne il foglio e gli toglie la lucentezza. Sulle cinque fotografie e sulla testata lo stampatore stende una seconda vernice, lucida, così le immagini prendono la luce mentre la pagina intorno resta ferma. Nessuna delle due vernici ha un colore: la tela mostra le pagine come vengono stampate, e tre viste della copertina accanto a Folio mostrano le lastre e il riflesso. Folio apre la rivista su un tavolo di marmo in luce da studio, dove il lucido brilla quando si gira un foglio.

**Questa ricetta risponde a:**

- Come metto una vernice soft touch su ogni pagina e una lucida serigrafica solo sulle foto?

## La risposta breve

```js
// script.js, righe 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' } }] };
```

## Ingredienti

**Insegna**

- [Inchiostri speciali](https://postext.dev/it/docs/special-inks-die-cuts.md#finiture): Un colore spot con una finitura: metallizzato, lamina a caldo, fluorescente, bianco coprente o vernice. Stampa su una lastra propria, il canvas ne mostra la lucentezza o una mappa delle finiture e Folio la illumina.

**Usa anche**

- [Tinte piatte e tabella degli inchiostri](https://postext.dev/it/docs/configuration-pdf-output.md#tinte-piatte)
- [PDF in CMYK e in scala di grigi](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#generazione-del-pdf-configurazione)
- [Visualizzatore di libri in 3D (Folio)](https://postext.dev/it/docs/configuration-html-folio-epub.md#un-libro-in-3d-postext-folio)
- [Carta, rilegatura, scrivania e luce (Folio)](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#visualizzatore-folio-configurazione)
- [Tavolozza di colori semantica](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#tavolozza-dei-colori)
- [Copertine, frontespizi e colophon](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)
- [Stili di titolo](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)
- [Aperture progettate](https://postext.dev/it/docs/configuration-headings.md#estensione-e-grafica-avanzata)
- [Testo, filetti e riquadri nei progetti di pagina](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina)
- [Immagini nei progetti di pagina](https://postext.dev/it/docs/configuration-headers-footers.md#elementi-immagine)
- [Testatine e folio](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina)
- [Esportazione in PDF](https://postext.dev/it/docs/configuration-pdf-output.md#generare-pdf)
- [Pagine su un canvas](https://postext.dev/it/docs/configuration-programmatic-usage.md#rasterizzare-una-pagina)
- [Attributi dei titoli](https://postext.dev/it/docs/document-format.md#attributi-dei-titoli)
- [Fascia di capitolo a tutta larghezza](https://postext.dev/it/docs/configuration-headings.md#estensione-e-grafica-avanzata)
- [Colore della carta](https://postext.dev/it/docs/configuration-page-layout.md#pagina)
- [Font incorporati nel PDF](https://postext.dev/it/docs/configuration-pdf-output.md#perché-un-provider-di-font)
- [Tipi di risorsa personalizzati](https://postext.dev/it/docs/configuration-resources.md#tipi-di-risorsa)
- [Figure e tabelle come risorse](https://postext.dev/it/docs/document-format-resources.md#risorse)
- [Testatine per sezione](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)
- [Capitoli non numerati](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)

**La configurazione in breve**

- [`bodyText`](https://postext.dev/it/docs/configuration-text.md#testo-corrente), [`colorPalette`](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#tavolozza-dei-colori), [`folio`](https://postext.dev/it/docs/configuration-html-folio-epub.md#aspetto), [`footer`](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina), [`header`](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina), [`headingStyles`](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli), [`headings`](https://postext.dev/it/docs/configuration-headings.md#titoli), [`layout`](https://postext.dev/it/docs/configuration-page-layout.md#impaginazione), [`locale`](https://postext.dev/it/docs/configuration-language.md#sillabazione), [`page`](https://postext.dev/it/docs/configuration-page-layout.md#pagina), [`print`](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#produzione-di-stampa-configurazione), [`resourceTypes`](https://postext.dev/it/docs/configuration-resources.md#tipi-di-risorsa)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/it/docs/configuration-programmatic-usage.md#caricare-i-font-prima-dellimpaginazione), [`createFolioFromDocument`](https://postext.dev/it/docs/configuration-html-folio-epub.md#un-libro-in-3d-postext-folio), [`decompressWoff2`](https://postext.dev/it/docs/configuration-pdf-output.md#provider-di-font-per-il-browser-fontsource--woff2), [`registerResourceImage`](https://postext.dev/it/docs/architecture.md#superficie-dellapi), [`renderPageToCanvas`](https://postext.dev/it/docs/configuration-programmatic-usage.md#rasterizzare-una-pagina), [`renderToPdf`](https://postext.dev/it/docs/configuration-pdf-output.md#generare-pdf)

**Caratteri**

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

## Preparazione

### 1 · Ogni vernice è una tinta piatta con una finitura

Il codice è [la risposta breve](https://postext.dev/it/cookbook/spot-uv-photo-magazine.md#la-risposta-breve) qui sopra. Una vernice è un colore piatto con la finitura `varnish` e una brillantezza: `softTouch` per il vellutato, `gloss` per la UV serigrafica ([finiture](https://postext.dev/it/docs/special-inks-die-cuts.md#finiture)). Il file PDF/X-4 mette ciascuna su una `Separation` propria, così lo stampatore riceve due lastre di vernice accanto alle quattro di quadricromia. A schermo una vernice non dipinge nulla; le serve comunque un hex proprio, perché un render di stampa distingue gli inchiostri dal loro hex. Una vernice è in sovrastampa per impostazione predefinita, quindi nessuna delle due fa risparmio nei colori che ha sotto.

### 2 · Soft touch su ogni pagina

```js
// script.js, righe 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' }) };
```

Il soft touch è un solo riquadro nella vernice, da abbondanza ad abbondanza. Lo porta il piè di pagina, così ogni pagina lo riceve da un solo punto. In macchina la vernice va per ultima, sopra tutto, e nel PDF niente di ciò che la pagina dipinge dopo la risparmia: il riquadro potrebbe anche aprire l'intestazione, prima del testo e dei numeri di pagina, che resterebbero sotto di esso sulla lastra. La copertina e la quarta non hanno numeri di pagina, e il loro piè di pagina porta solo il riquadro.

### 3 · Lucido sulle fotografie

```js
// script.js, righe 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 },
];
```

Ogni fotografia è un'immagine con sopra un riquadro nella vernice lucida, della stessa misura. Il riquadro viene dopo, quindi sta sopra: sulla lastra è un rettangolo che copre l'immagine esattamente, ed è così che si disegna una lastra di UV serigrafica.

### 4 · La testata composta due volte

```js
// script.js, righe 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) })),
    ] } } };
```

La testata è fatta di due elementi di testo nello stesso punto: uno in bianco carta, che si risparmia nella fotografia, e uno nella vernice lucida sopra. La versione lucida non dipinge nulla a schermo e dà alla lastra la forma delle lettere, così sulla copertina stampata il titolo brilla sopra un cielo che brilla anche lui.

### 5 · Le viste delle finiture e Folio

```js
// script.js, righe 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, righe 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` accetta un'opzione `finishes`. `'flat'` è il valore predefinito e mostra la pagina come viene stampata; `'map'` sbiadisce la pagina e segna ogni lastra speciale in falsi colori, la vernice in ciano, il lucido più chiaro del soft touch; `'sheen'` fa passare una luce sulla pagina. Folio legge la stessa maschera delle finiture: il lucido prende i riflessi, il soft touch li toglie.

## La ricetta completa

Un unico file, composto a partire dalla cartella della ricetta con il testo di esempio e il kit comune del Ricettario già inclusi; costruisce la propria pagina. Per eseguirlo, mettilo in uno `<script type="module">` di una pagina vuota, oppure incollalo nel pannello JS di un nuovo pen di CodePen (come modulo). Importa postext da esm.sh: non c’è niente da installare né da compilare.

- Cartella della ricetta: 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 ───────────────────────────────────────────────────────────────────────
```

## Varianti

### Opaco al posto del soft touch

Una semplice vernice opaca costa meno e dà lo stesso contrasto, un po' meno profondo.

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

### Lucido solo sulla scritta

Lascia le foto opache e stendi il lucido solo sulla testata e sui titoli: componi i titoli due volte, come la testata, e togli i riquadri sopra le immagini.

## Errori frequenti

- Una vernice con l'hex di un altro colore viene stampata come quel colore. Dai a ogni vernice un hex che nient'altro usa.
- Una vernice generale fermata al rifilo lascia una striscia scoperta sul bordo quando il foglio viene tagliato un po' storto. Portala fino all'abbondanza, come il riquadro qui.
- Il soft touch si vende spesso come plastificazione e non come vernice. Chiedi allo stampatore quale nome di lastra vuole e impostalo con `pdfName` nella tabella degli inchiostri.

## Crediti

- Ricetta: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Immagini: A walker on a salt flat at dusk, on the cover: Generated With Diffusion Models, originale
- Immagini: A fisherman mending a net: Generated With Diffusion Models, originale
- Immagini: Pines in morning fog: Generated With Diffusion Models, originale
- Immagini: A desert road between mesas: Generated With Diffusion Models, originale
- Immagini: The salt flat at sunset, on the back cover: Generated With Diffusion Models, originale
- Caratteri: Bodoni Moda (OFL-1.1), Source Serif 4 (OFL-1.1), Source Sans 3 (OFL-1.1)
- Codice: MIT · Contenuto di esempio: CC-BY-4.0

## Ricette correlate

- [Nº 188 · Oro a caldo su una copertina blu notte](https://postext.dev/it/cookbook/gold-foil-poetry-cover.md): La lamina d’oro come tinta piatta con una finitura: una lastra propria nel PDF, la lucentezza in Folio, e cartoncino blu e carta crema senza inchiostro. · Livello 3 (Avanzato) · Poesia
- [Nº 190 · Una fanzine in nero e rosa fluo](https://postext.dev/it/cookbook/fluorescent-pink-zine.md): Un lavoro a due lastre, nero e un rosa fluorescente: foto in bicromia, un nero che sovrastampa e un rosa che brilla in Folio. · Livello 3 (Avanzato) · Riviste e fanzine
- [Nº 102 · Una fanzine spillata con copertina in cartoncino](https://postext.dev/it/cookbook/saddle-stitched-card-cover.md): Due blocchi :::paper mettono un cartoncino salmone sul foglio esterno di una fanzine di otto pagine, e postext-folio la mostra spillata su carta da giornale. · Livello 2 (Intermedio) · Riviste e fanzine
