# Partieller Glanzlack auf einem Soft-Touch-Magazin

> Zwei Lacke als Sonderfarben: Soft-Touch auf jeder Seite, Glanzlack über den Fotos und dem Titelschriftzug, zu sehen in Folio und den Veredelungsansichten.

- HTML-Fassung: https://postext.dev/de/cookbook/spot-uv-photo-magazine
- Rezept Nº 192 · Ausgabe und Integration · Stufe 3 (Fortgeschritten) · Ausgaben: Canvas, PDF
- Gattungen: Magazine und Zines
- Benötigt postext ≥ 1.85.1, postext-pdf ≥ 1.85.1 · getestet mit 1.86.0, postext-pdf 1.86.0 am 2026-11-14
- Seiten: [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
- In der Sandbox öffnen: https://postext.dev/de/sandbox#recipe=spot-uv-photo-magazine&lang=en (.postext: https://postext.dev/cookbook/spot-uv-photo-magazine/en/spot-uv-photo-magazine.postext)
- Zuletzt aktualisiert: 2026-11-13
- Andere Sprachen: [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), [fr](https://postext.dev/fr/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)

## Kurz gesagt

Ein Fotomagazin mit einer samtigen Beschichtung auf jeder Seite und einer glänzenden nur auf den Fotos und dem Titel. Die Lacke haben keine Farbe; die 3D-Ansicht und eine Proof-Ansicht zeigen, wo sie liegen.

## Was Sie setzen

Heft 14 von *Long Light*, einem erfundenen Fotomagazin: sechs Seiten in 210 × 280 mm, klebegebunden. Jede Seite trägt einen Soft-Touch-Lack, die samtige Veredelung, die den Bogen dämpft und ihm den Glanz nimmt. Über die fünf Fotos und den Titelschriftzug legt die Druckerei einen zweiten Lack, einen Glanzlack, damit die Bilder das Licht fangen, während die Seite um sie herum ruhig bleibt. Keiner der beiden Lacke hat eine Farbe: Die Leinwand zeigt die Seiten so, wie sie gedruckt werden, und drei Ansichten des Titelblatts neben Folio zeigen die Platten und den Glanz. Folio legt das Magazin aufgeschlagen auf einen Marmortisch im Studiolicht, wo der Glanz beim Umblättern aufblitzt.

**Dieses Rezept beantwortet:**

- Wie lege ich Soft-Touch-Lack auf jede Seite und partiellen Glanzlack nur auf die Fotos?

## Die kurze Antwort

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

## Zutaten

**Zeigt**

- [Spezialfarben](https://postext.dev/de/docs/special-inks-die-cuts.md#veredelungen): Eine Sonderfarbe mit einer Veredelung: Metallic, Heißfolie, Leuchtfarbe, Deckweiß oder Lack. Sie druckt auf einer eigenen Platte, das Canvas kann ihren Glanz oder eine Veredelungskarte zeigen, und Folio beleuchtet sie.

**Verwendet außerdem**

- [Sonderfarben und Druckfarbentabelle](https://postext.dev/de/docs/configuration-pdf-output.md#sonderfarben)
- [PDFs in CMYK und Graustufen](https://postext.dev/de/docs/configuration-fonts-colors-viewers.md#pdf-erzeugung-konfiguration)
- [3D-Buchbetrachter (Folio)](https://postext.dev/de/docs/configuration-html-folio-epub.md#ein-3d-buch-postext-folio)
- [Papier, Bindung, Tisch und Licht (Folio)](https://postext.dev/de/docs/configuration-fonts-colors-viewers.md#folio-betrachter-konfiguration)
- [Semantische Farbpalette](https://postext.dev/de/docs/configuration-fonts-colors-viewers.md#farbpalette)
- [Umschläge, Titelseiten und Impressum](https://postext.dev/de/docs/configuration-styles.md#überschriftenstile)
- [Überschriftenformate](https://postext.dev/de/docs/configuration-styles.md#überschriftenstile)
- [Gestaltete Auftakte](https://postext.dev/de/docs/configuration-headings.md#seitenbreite-und-erweiterte-gestaltung)
- [Text, Linien und Kästen in Seitengestaltungen](https://postext.dev/de/docs/configuration-headers-footers.md#kopf--und-fußzeilen)
- [Bilder in Seitengestaltungen](https://postext.dev/de/docs/configuration-headers-footers.md#bildelemente)
- [Kolumnentitel und Seitenzahlen](https://postext.dev/de/docs/configuration-headers-footers.md#kopf--und-fußzeilen)
- [PDF-Export](https://postext.dev/de/docs/configuration-pdf-output.md#pdfs-erzeugen)
- [Seiten auf einem Canvas](https://postext.dev/de/docs/configuration-programmatic-usage.md#eine-seite-als-bitmap-rendern)
- [Überschriftenattribute](https://postext.dev/de/docs/document-format.md#attribute-von-überschriften)
- [Kapitelband über die ganze Breite](https://postext.dev/de/docs/configuration-headings.md#seitenbreite-und-erweiterte-gestaltung)
- [Papierfarbe](https://postext.dev/de/docs/configuration-page-layout.md#seite)
- [Im PDF eingebettete Schriften](https://postext.dev/de/docs/configuration-pdf-output.md#warum-ein-font-provider)
- [Eigene Ressourcentypen](https://postext.dev/de/docs/configuration-resources.md#ressourcentypen)
- [Abbildungen und Tabellen als Ressourcen](https://postext.dev/de/docs/document-format-resources.md#ressourcen)
- [Kolumnentitel je Abschnitt](https://postext.dev/de/docs/configuration-styles.md#überschriftenstile)
- [Kapitel ohne Nummer](https://postext.dev/de/docs/configuration-styles.md#überschriftenstile)

**Die Konfiguration auf einen Blick**

- [`bodyText`](https://postext.dev/de/docs/configuration-text.md#fließtext), [`colorPalette`](https://postext.dev/de/docs/configuration-fonts-colors-viewers.md#farbpalette), [`folio`](https://postext.dev/de/docs/configuration-html-folio-epub.md#erscheinungsbild), [`footer`](https://postext.dev/de/docs/configuration-headers-footers.md#kopf--und-fußzeilen), [`header`](https://postext.dev/de/docs/configuration-headers-footers.md#kopf--und-fußzeilen), [`headingStyles`](https://postext.dev/de/docs/configuration-styles.md#überschriftenstile), [`headings`](https://postext.dev/de/docs/configuration-headings.md#überschriften), [`layout`](https://postext.dev/de/docs/configuration-page-layout.md#layout), [`locale`](https://postext.dev/de/docs/configuration-language.md#silbentrennung), [`page`](https://postext.dev/de/docs/configuration-page-layout.md#seite), [`print`](https://postext.dev/de/docs/configuration-fonts-colors-viewers.md#druckvorstufe-konfiguration), [`resourceTypes`](https://postext.dev/de/docs/configuration-resources.md#ressourcentypen)

**APIs**

- [`buildDocumentWithFonts`](https://postext.dev/de/docs/configuration-programmatic-usage.md#schriften-vor-dem-layout-laden), [`createFolioFromDocument`](https://postext.dev/de/docs/configuration-html-folio-epub.md#ein-3d-buch-postext-folio), [`decompressWoff2`](https://postext.dev/de/docs/configuration-pdf-output.md#font-provider-im-browser-fontsource--woff2), [`registerResourceImage`](https://postext.dev/de/docs/architecture.md#api-oberfläche), [`renderPageToCanvas`](https://postext.dev/de/docs/configuration-programmatic-usage.md#eine-seite-als-bitmap-rendern), [`renderToPdf`](https://postext.dev/de/docs/configuration-pdf-output.md#pdfs-erzeugen)

**Schriften**

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

## Zubereitung

### 1 · Jeder Lack ist eine Sonderfarbe mit Veredelung

Der Code steht oben in [der kurzen Antwort](https://postext.dev/de/cookbook/spot-uv-photo-magazine.md#die-kurze-antwort). Ein Lack ist eine Sonderfarbe mit der Veredelung `varnish` und einem Schimmer: `softTouch` für das Samtige, `gloss` für den partiellen UV-Lack ([Veredelungen](https://postext.dev/de/docs/special-inks-die-cuts.md#veredelungen)). Die PDF/X-4-Datei legt jeden auf eine eigene `Separation`, sodass die Druckerei zwei Lackplatten neben den vier Prozessplatten bekommt. Auf dem Bildschirm malt ein Lack nichts; er braucht trotzdem ein eigenes Hex, weil ein Druck-Render die Farben an ihrem Hex unterscheidet. Ein Lack druckt standardmäßig über, also spart keiner der beiden die Farben darunter aus.

### 2 · Soft-Touch auf jeder Seite

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

Der Soft-Touch ist ein einzelner Kasten im Lack, von Anschnitt zu Anschnitt. Die Fußzeile trägt ihn, sodass jede Seite ihn von derselben Stelle bekommt. In der Maschine kommt der Lack zuletzt, über alles, und im PDF spart nichts, was die Seite danach malt, ihn aus: Der Kasten könnte ebenso gut die Kopfzeile eröffnen, vor dem Text und den Seitenzahlen, die auf der Platte unter ihm lägen. Titelblatt und Rückseite haben keine Seitenzahlen, ihre Fußzeile trägt nur den Kasten.

### 3 · Glanz über den Fotos

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

Jedes Foto ist ein Bild, über das ein gleich großer Kasten im Glanzlack gelegt wird. Der Kasten kommt als Zweites und liegt deshalb oben: Auf der Platte ist er ein Rechteck, das das Bild genau deckt, und so zeichnet man eine Platte für partiellen UV-Lack.

### 4 · Der Titelschriftzug zweimal gesetzt

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

Der Titelschriftzug besteht aus zwei Textelementen an derselben Stelle: eines in Papierweiß, das aus dem Foto ausgespart wird, und eines im Glanzlack darüber. Die Glanzfassung malt auf dem Bildschirm nichts und gibt der Platte die Form der Buchstaben, sodass auf dem gedruckten Titel der Schriftzug über dem glänzenden Himmel glänzt.

### 5 · Die Veredelungsansichten und Folio

```js
// script.js, Zeilen 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, Zeilen 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` nimmt eine Option `finishes`. `'flat'` ist der Standard und zeigt die Seite, wie sie gedruckt wird; `'map'` blendet die Seite ab und markiert jede Sonderplatte in Falschfarbe, den Lack in Cyan, den Glanz heller als den Soft-Touch; `'sheen'` lässt ein Licht über die Seite wandern. Folio liest dieselbe Veredelungsmaske: Glanz fängt die Lichter, Soft-Touch nimmt sie weg.

## Das ganze Rezept

Eine Datei, aus dem Ordner des Rezepts zusammengesetzt, mit dem Beispieltext und dem gemeinsamen Baukasten der Rezepte bereits eingebettet; sie baut ihre eigene Seite auf. Zum Ausführen setzen Sie sie in ein `<script type="module">` auf einer leeren Seite oder fügen sie in das JS-Feld eines neuen CodePen-Pens ein (als Modul). Sie importiert postext von esm.sh, es gibt also nichts zu installieren oder zu bauen.

- Quellordner: 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 ───────────────────────────────────────────────────────────────────────
```

## Varianten

### Matt statt Soft-Touch

Ein einfacher Mattlack kostet weniger und zeigt denselben Kontrast, etwas weniger tief.

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

### Glanz nur auf der Schrift

Lassen Sie die Fotos matt und legen Sie den Glanz nur über den Titelschriftzug und die Überschriften: Setzen Sie die Überschriften zweimal, wie den Schriftzug, und entfernen Sie die Kästen über den Bildern.

## Häufige Fehler

- Ein Lack mit dem Hex einer anderen Farbe wird als diese Farbe gedruckt. Geben Sie jedem Lack ein Hex, das sonst nichts verwendet.
- Ein vollflächiger Lack, der nur bis zum Endformat reicht, lässt am Rand einen unlackierten Streifen, wenn der Bogen etwas schief geschnitten wird. Führen Sie ihn bis in den Anschnitt, wie den Kasten hier.
- Soft-Touch wird oft als Kaschierung statt als Lack verkauft. Fragen Sie die Druckerei, welchen Plattennamen sie möchte, und setzen Sie ihn mit `pdfName` in der Farbtabelle.

## Nachweise

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

## Verwandte Rezepte

- [Nº 188 · Goldprägung auf einem tiefblauen Umschlag](https://postext.dev/de/cookbook/gold-foil-poetry-cover.md): Heißfolie als Sonderfarbe mit Veredelung: eine eigene Platte im PDF, Glanz in Folio, dazu blauer Karton und cremefarbenes Papier ohne Druckfarbe. · Stufe 3 (Fortgeschritten) · Lyrik
- [Nº 190 · Ein Fanzine in Schwarz und Neonpink](https://postext.dev/de/cookbook/fluorescent-pink-zine.md): Ein Auftrag mit zwei Platten, Schwarz und ein fluoreszierendes Pink: Fotos als Duplex, ein überdruckendes Schwarz und ein Pink, das in Folio leuchtet. · Stufe 3 (Fortgeschritten) · Magazine und Zines
- [Nº 102 · Ein geheftetes Zine mit Umschlagbogen aus Karton](https://postext.dev/de/cookbook/saddle-stitched-card-cover.md): Zwei Container :::paper legen lachsfarbenen Karton auf den Außenbogen eines achtseitigen Zines; postext-folio zeigt es um Zeitungspapier geheftet. · Stufe 2 (Mittel) · Magazine und Zines
