# Un menù da panetteria in bianco su kraft

> Il bianco coprente come tinta piatta su kraft: testo bianco sul cartoncino bruno, un fondo bianco sotto testo bruno e bianco risparmiato in un riquadro verde.

- Versione HTML: https://postext.dev/it/cookbook/white-ink-kraft-menu
- Ricetta Nº 191 · Output e integrazione · Livello 3 (Avanzato) · Output: Canvas, PDF
- Generi: Fogli singoli ed effimeri
- Richiede postext ≥ 1.85.1, postext-pdf ≥ 1.85.1 · provata con 1.85.1, postext-pdf 1.85.1 il 2026-11-13
- Pagine: [1](https://postext.dev/cookbook/white-ink-kraft-menu/en/p01.webp?v=137c1047), [2](https://postext.dev/cookbook/white-ink-kraft-menu/en/p02.webp?v=137c1047), [3](https://postext.dev/cookbook/white-ink-kraft-menu/en/p03.webp?v=137c1047), [4](https://postext.dev/cookbook/white-ink-kraft-menu/en/p04.webp?v=137c1047)
- PDF: https://postext.dev/cookbook/white-ink-kraft-menu/en/white-ink-kraft-menu.pdf?v=137c1047
- Apri nella Sandbox: https://postext.dev/it/sandbox#recipe=white-ink-kraft-menu&lang=en (.postext: https://postext.dev/cookbook/white-ink-kraft-menu/en/white-ink-kraft-menu.postext)
- Ultimo aggiornamento: 2026-11-13
- Altre lingue: [en](https://postext.dev/en/cookbook/white-ink-kraft-menu.md), [es](https://postext.dev/es/cookbook/white-ink-kraft-menu.md), [ca](https://postext.dev/ca/cookbook/white-ink-kraft-menu.md), [de](https://postext.dev/de/cookbook/white-ink-kraft-menu.md), [fr](https://postext.dev/fr/cookbook/white-ink-kraft-menu.md), [pt](https://postext.dev/pt/cookbook/white-ink-kraft-menu.md), [zh](https://postext.dev/zh/cookbook/white-ink-kraft-menu.md), [ja](https://postext.dev/ja/cookbook/white-ink-kraft-menu.md), [ar](https://postext.dev/ar/cookbook/white-ink-kraft-menu.md)

## In breve

Il menù di una panetteria stampato su cartoncino kraft marrone. Il nome e i titoli sono in inchiostro bianco, che il tipografo aggiunge come inchiostro in più. Il file di stampa tiene il bianco su una lastra a parte.

## Che cosa comporrai

Il menù di Horno Alto, una panetteria di paese inventata: un cartoncino kraft A5 piegato una volta, quattro pagine. Il kraft non contiene bianco, quindi ogni bianco del menù è un inchiostro che aggiunge il tipografo: il nome e i titoli delle sezioni direttamente sul bruno, i passe-partout su cui poggiano le tre tempere e il cartoncino con gli orari. I prezzi stanno su un tabulatore con linea di puntini, in un bruno scuro in quadricromia. Nella pagina del caffè un riquadro verde porta l'infornata del giorno in testo bianco ritagliato nel verde. Folio apre il menù su un bancone di rovere, alla luce del giorno.

**Questa ricetta risponde a:**

- Come stampo il bianco su carta kraft, come testo e sotto i colori?

## La risposta breve

```js
// script.js, righe 20–35
// The paper is a colour that prints no ink: the screen and Folio paint kraft, and no plate
// gets a dot of it. Because it is not white, the preflight knows the white ink shows on it.
// The white is a spot ink with the white finish: its own plate, laid down before the others.
const kraft = { hex: '#c19a6b', model: 'cmyk', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
const WHITE = { name: 'Opaque White', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
// A white ink overprints by default: laid under the colours, it must not cut holes in them.
const white = { hex: '#f7f4ee', model: 'spot', spot: { ...WHITE, finish: { kind: 'white' } } };
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra52', convertImages: false,
  inks: [{ name: 'Opaque White', aliases: ['White'], finish: { kind: 'white' } }] };

// White type on a green panel must knock the green out.
// White printed under the green is hidden by it. For white type on a colour, the type must cut
// its shape out of the colour, so this white says overprint: false. Its hex differs by one
// step from the other white, since the PDF tells colours apart by hex; both print on one plate.
const whiteOut = { hex: '#f6f3ed', model: 'spot',
  spot: { ...WHITE, finish: { kind: 'white' }, overprint: false } };
```

## 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.
- [Tinte piatte e tabella degli inchiostri](https://postext.dev/it/docs/configuration-pdf-output.md#tinte-piatte): Un colore con modello 'spot' si stampa su una lastra sua, alla sua percentuale. La tabella degli inchiostri chiama la lastra come la conosce lo stampatore e vi riunisce gli altri nomi che la tavolozza, gli SVG e i file importati danno allo stesso inchiostro.

**Usa anche**

- [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)
- [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)
- [Stili di paragrafo](https://postext.dev/it/docs/configuration-styles.md#stili-di-paragrafo)
- [Tabulazioni e riempitivi](https://postext.dev/it/docs/configuration-text.md#tabulatori)
- [Riquadri](https://postext.dev/it/docs/configuration-callouts.md#stili-dei-riquadri)
- [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)
- [Aperture progettate](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), [`calloutStyles`](https://postext.dev/it/docs/configuration-callouts.md#stili-dei-riquadri), [`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), [`paragraphStyles`](https://postext.dev/it/docs/configuration-styles.md#stili-di-paragrafo), [`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), `preflightDocument`, [`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**

- Alfa Slab One (OFL-1.1), Lora (OFL-1.1)

## Preparazione

### 1 · La carta è kraft, il bianco è un inchiostro

Il codice è [la risposta breve](https://postext.dev/it/cookbook/white-ink-kraft-menu.md#la-risposta-breve) qui sopra. La carta è un colore della palette definito in CMYK allo 0 %: lo schermo e Folio dipingono il kraft, e nessuna lastra lo stampa. Il bianco è una tinta piatta con la finitura bianca ([finiture](https://postext.dev/it/docs/special-inks-die-cuts.md#finiture)), chiamata `Opaque White` nella tabella degli inchiostri, come verrà detto al tipografo. Il file PDF/X-4 lo mette su una `Separation` propria, accanto alle quattro lastre di quadricromia. Il suo hex a schermo è un passo sotto `#ffffff`, così la maschera delle finiture distingue l'inchiostro da un foglio bianco.

### 2 · Il bianco direttamente sul bruno

```js
// script.js, righe 63–70
// The mount is a box in the white, the painting a picture over it. The white goes down first
// on press and runs on under the whole painting, so its light tones print on white.
const mount = (x, y, w, h, extra) => [
  { kind: 'box', id: 'mount', style: { backgroundColor: col('white') },
    placement: at('page', 'top-left', x, y, { width: mm(w), height: mm(h) }) },
  { kind: 'image', id: 'photo', resourceId: '{attr.photo}', fit: 'cover', ...extra,
    placement: at('page', 'top-left', x + 4, y + 4, { width: mm(w - 8), height: mm(h - 8) }) },
];
```

Il nome, i titoli delle sezioni e quelli delle pagine interne sono testo nel bianco, composto in Alfa Slab One. Un inchiostro bianco copre meno del nero: il bruno traspare in un tratto sottile, quindi un'egiziana nera da 12 pt in su si legge dove un tondo leggero diventerebbe beige. I passe-partout sono riquadri nello stesso bianco, 4 mm più grandi di ogni dipinto su ogni lato. Il bianco prosegue sotto tutto il dipinto, non solo intorno: i suoi toni chiari si stampano sul bianco e non sul bruno.

### 3 · Il colore sopra il bianco

Gli orari stanno su un cartoncino di inchiostro bianco, nel bruno scuro del testo del menù. Un inchiostro bianco sovrastampa per impostazione predefinita, e anche il bruno è impostato in sovrastampa (`overprint: true` sul colore della palette), così in macchina il bruno si posa sul bianco invece di ritagliarci dentro le sue lettere.

### 4 · Il bianco sopra il colore: risparmiarlo

```js
// script.js, righe 114–126
const calloutStyles = [
  { id: 'bake', background: col('green'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('whiteOut'),
      boldColor: col('whiteOut'), italicColor: col('whiteOut'), textAlign: 'left',
      firstLineIndent: pt(0) } },
  // The hours: brown type on a card of white ink, the colour printed over the white.
  { id: 'hours', background: col('white'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
      boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0),
      tabStops: [{ position: 'end', align: 'end' }] } },
];
```

La macchina stende prima il bianco e poi i colori sopra, quindi un testo bianco sul riquadro verde sparirebbe sotto il verde. Il testo del riquadro prende un secondo bianco sulla stessa lastra, con `overprint: false`: il testo ritaglia la sua forma nel verde e il bianco la riempie. I due bianchi differiscono di un passo di hex perché il PDF distingue i colori dal loro hex.

### 5 · I prezzi su un tabulatore

```js
// script.js, righe 106–110
const dish = { id: 'dish', name: 'Dish', textAlign: 'left',
  tabStops: [{ position: 'end', align: 'end', leader: '. ' }],
  spaceBetween: pt(LEAD / 3), marginTop: pt(LEAD / 2) };
// The story on the back: half a line between paragraphs.
const story = { id: 'story', name: 'Story', spaceBetween: pt(LEAD / 2) };
```

Ogni sezione è un gruppo `:::paragraphs` nello stile dei piatti; `:tab` prima del prezzo lo manda in fondo alla giustezza, con una linea di puntini fino a lui, come nel [menù del bistrot](https://postext.dev/it/cookbook/bistro-menu.md).

### 6 · Che cosa dice il controllo

```js
// script.js, righe 274–282
// A white ink on white paper prints nothing you can see, and the preflight warns of it
// (whiteInkOnWhite). On kraft it does not fire; the findings left say which special ink the
// job carries and that the press lays the white first.
const findings = preflightDocument(doc);
const report = document.createElement('p');
report.textContent = `Preflight: ${findings.map((f) => f.kind === 'inkPressOrder'
  ? `inkPressOrder (first: ${f.first.join(', ')})` : `${f.kind}${f.ink ? ` (${f.ink})` : ''}`)
  .join('; ') || 'no findings'}`;
document.querySelector(`[data-postext-pdf="${RECIPE}.pdf"]`).after(report);
```

`preflightDocument` avvisa con `whiteInkOnWhite` quando un inchiostro bianco finisce su una pagina con carta bianca o non impostata, dove non mostra nulla. Sul kraft tace, e la riga sotto il pulsante di download elenca ciò che resta: il bianco come inchiostro speciale (`spotInkFinish`) e l'ordine di stampa che lo stende per primo (`inkPressOrder`).

### 7 · Folio mostra il menù su un bancone

```js
// script.js, righe 130–136
const folio = {
  tilt: 20, yaw: -12,
  paper: { type: 'cardStock', grammage: 250, texture: 'felt', shade: kraft },
  binding: { type: 'folded', cover: 'pages' },
  surface: { type: 'oak' },
  lighting: { environment: 'daylight', intensity: 1.1 },
};
```

Folio dipinge il bianco in modo che copra il tono della carta, come fa l'inchiostro, e il cartoncino con texture feltrata fa leggere il bruno come kraft.

## 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/white-ink-kraft-menu

### script.js

```js
// ═══ Postext Cookbook · Nº 191 · A bakery menu in white ink on kraft ═════════════════════
// https://postext.dev/en/cookbook/white-ink-kraft-menu
// Code: MIT · Text: original (CC BY 4.0) · Paintings: diffusion models
// Fonts: Alfa Slab One, Lora (SIL OFL 1.1) · Needs postext ≥ 1.85.1
//
// The menu of a bakery, a folded card of brown kraft. Kraft takes no white from the paper, so
// the name and the course heads print in an opaque white ink, and the paintings sit on white
// mounts that the same ink lays under them; the menu text is a dark brown in process colour.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, preflightDocument,
} 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 = 'white-ink-kraft-menu';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region answer: kraft as the paper, and an opaque white as a spot ink
// The paper is a colour that prints no ink: the screen and Folio paint kraft, and no plate
// gets a dot of it. Because it is not white, the preflight knows the white ink shows on it.
// The white is a spot ink with the white finish: its own plate, laid down before the others.
const kraft = { hex: '#c19a6b', model: 'cmyk', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
const WHITE = { name: 'Opaque White', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
// A white ink overprints by default: laid under the colours, it must not cut holes in them.
const white = { hex: '#f7f4ee', model: 'spot', spot: { ...WHITE, finish: { kind: 'white' } } };
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra52', convertImages: false,
  inks: [{ name: 'Opaque White', aliases: ['White'], finish: { kind: 'white' } }] };

// White type on a green panel must knock the green out.
// White printed under the green is hidden by it. For white type on a colour, the type must cut
// its shape out of the colour, so this white says overprint: false. Its hex differs by one
// step from the other white, since the PDF tells colours apart by hex; both print on one plate.
const whiteOut = { hex: '#f6f3ed', model: 'spot',
  spot: { ...WHITE, finish: { kind: 'white' }, overprint: false } };
// #endregion

const palette = {
  kraft, white, whiteOut,
  // The brown overprints: on the white card it lands on the white instead of cutting it away.
  ink: { hex: '#3b2a1c', model: 'cmyk', cmyk: { c: 0, m: 45, y: 75, k: 82 }, overprint: true },
  green: { hex: '#2f5a43', model: 'cmyk', cmyk: { c: 80, m: 25, y: 75, k: 40 } }, // the panel
};
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] = [148, 210]; // A5, an A4 card folded once
const MARGIN = 13;
const MEASURE = TRIM_W - 2 * MARGIN;
const [BODY, LEAD] = [9.6, 13.2]; // pt
const [DISPLAY, SERIF] = ['Alfa Slab One', 'Lora'];
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: SERIF, fontWeight: 700, fontSize: pt(size),
  letterSpacing: pt(size * 0.14), textTransform: 'uppercase', color });
const bare = { numbered: false, toc: false, span: 'page', header: { elements: [] },
  footer: { elements: [] } };

// #region mount: a painting on a white mount, 4 mm of white round it
// The mount is a box in the white, the painting a picture over it. The white goes down first
// on press and runs on under the whole painting, so its light tones print on white.
const mount = (x, y, w, h, extra) => [
  { kind: 'box', id: 'mount', style: { backgroundColor: col('white') },
    placement: at('page', 'top-left', x, y, { width: mm(w), height: mm(h) }) },
  { kind: 'image', id: 'photo', resourceId: '{attr.photo}', fit: 'cover', ...extra,
    placement: at('page', 'top-left', x + 4, y + 4, { width: mm(w - 8), height: mm(h - 8) }) },
];
// #endregion

// The cover: the name in white straight on the kraft, the loaf on its mount.
const cover = { ...bare, id: 'cover', advancedDesign: { enabled: true, minHeight: mm(170),
  slot: { elements: [
    text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(50), lineHeight: 0.9,
      textTransform: 'uppercase', align: 'center', color: col('white') },
    at('page', 'top-left', MARGIN, 22, { width: mm(MEASURE) })),
    text('since', '{attr.since}', { ...label(8, col('ink')), align: 'center' },
      at('#title', 'below', 0, 3, { width: mm(MEASURE) })),
    ...mount(26, 64, 96, 96),
    text('address', '{attr.address}', { fontFamily: SERIF, italic: true,
      fontSize: pt(10), lineHeight: 1.35, color: col('ink'), align: 'center' },
    at('page', 'top-left', MARGIN, 172, { width: mm(MEASURE) })),
  ] } } };

// The inside pages open on a painting across the measure, the kicker and the title in white.
const opener = (id, height) => ({ ...bare, id, advancedDesign: { enabled: true,
  minHeight: mm(height + 20), slot: { elements: [
    ...mount(MARGIN, 14, MEASURE, height),
    text('kicker', '{attr.kicker}', label(7.5, col('ink')),
      at('page', 'top-left', MARGIN, 18 + height)),
    text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(24), lineHeight: 1,
      textTransform: 'uppercase', color: col('white') },
    at('#kicker', 'below', 0, 1.5, { width: mm(MEASURE) })),
  ] } } });

// The back: the bakery's story in brown, the hours on a white card.
const back = { ...bare, id: 'back', advancedDesign: { enabled: true, minHeight: mm(14),
  slot: { elements: [
    text('title', '{titleText}', { fontFamily: DISPLAY, fontSize: pt(24), lineHeight: 1,
      textTransform: 'uppercase', color: col('white') }, at('container', 'top-left')),
  ] } } };

// #region dishes: a dish and its price on a tab stop, dotted to the right margin
const dish = { id: 'dish', name: 'Dish', textAlign: 'left',
  tabStops: [{ position: 'end', align: 'end', leader: '. ' }],
  spaceBetween: pt(LEAD / 3), marginTop: pt(LEAD / 2) };
// The story on the back: half a line between paragraphs.
const story = { id: 'story', name: 'Story', spaceBetween: pt(LEAD / 2) };
// #endregion

// #region panel: the day's bake on green, its type knocked out in white
const calloutStyles = [
  { id: 'bake', background: col('green'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('whiteOut'),
      boldColor: col('whiteOut'), italicColor: col('whiteOut'), textAlign: 'left',
      firstLineIndent: pt(0) } },
  // The hours: brown type on a card of white ink, the colour printed over the white.
  { id: 'hours', background: col('white'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
      boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0),
      tabStops: [{ position: 'end', align: 'end' }] } },
];
// #endregion

// #region folio: a folded kraft card on an oak counter, in daylight
const folio = {
  tilt: 20, yaw: -12,
  paper: { type: 'cardStock', grammage: 250, texture: 'felt', shade: kraft },
  binding: { type: 'folded', cover: 'pages' },
  surface: { type: 'oak' },
  lighting: { environment: 'daylight', intensity: 1.1 },
};
// #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('kraft'), margins: { top: mm(14), bottom: mm(14), left: mm(MARGIN),
      right: mm(MARGIN) } },
  layout: { layoutType: 'single' },
  bodyText: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0),
    hyphenation: { enabled: false }, avoidWidows: true, avoidOrphans: true },
  headings: { fontFamily: DISPLAY, fontWeight: 400, color: col('white'), levels: [
    { level: 1, span: 'page', breakBefore: { enabled: true, parity: 'any' } },
    { level: 2, fontSize: pt(12), lineHeight: pt(LEAD), letterSpacing: pt(1.2),
      textTransform: 'uppercase', marginTop: pt(LEAD), marginBottom: pt(0) }] },
  headingStyles: [cover, opener('wide', 54), opener('square', 56), back],
  paragraphStyles: [dish, story], calloutStyles,
  print: PRINT,
  header: { elements: [] }, footer: { elements: [] }, folio,
});

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

# Horno Alto {style="cover" photo="loaf" since="Bakery and café · since 1987" address="Calle del Pozo 14 · Tuesday to Sunday, seven to seven"}

# From the oven {style="wide" photo="pastries" kicker="Bread and pastries"}

## Bread

:::paragraphs{style="dish"}
**Country sourdough**, 800 g, wheat and rye :tab **4.80**\
*Three days from starter to crust, baked at five each morning*

**Seeded rye**, 600 g, sunflower, flax and pumpkin :tab **4.20**\
*Dense and dark, best sliced thin and kept a week*

**Olive oil loaf**, 500 g :tab **3.60**\
*The one we make the toast with*

**Bread of the day**, ask at the counter :tab **3.90**
:::

## Pastries

:::paragraphs{style="dish"}
**Butter croissant** :tab **1.80**\
*Laminated over two days with Asturian butter*

**Cinnamon roll**, sugar glaze :tab **2.40**

**Almond cake**, a slice :tab **3.20**\
*Ground almonds, lemon zest, no flour*

**Cheese and quince twist** :tab **2.60**
:::

# At the counter {style="square" photo="coffee" kicker="Coffee and breakfast"}

## Coffee

:::paragraphs{style="dish"}
**Espresso** :tab **1.40**

**Cortado**, a splash of milk :tab **1.60**

**Café con leche**, large cup :tab **2.10**

**Hot chocolate**, thick, for dipping :tab **2.80**
:::

## Breakfast

:::paragraphs{style="dish"}
**Toast with tomato and olive oil** :tab **3.20**

**Toast with butter and apricot jam** :tab **3.00**

**Croissant and coffee** :tab **3.00**
:::

:::callout{type="bake"}
**Today’s bake.** Pumpkin and walnut loaf, from eleven until it runs out. Ask for a slice warm with butter.
:::

# Since 1987 {style="back"}

:::paragraphs{style="story"}
The oven in the back room was built by Rosa Alto’s father the year the bakery opened, from brick and the clay of the river below the village. It still bakes every loaf. Rosa runs the bakery now with her son Pablo, who came back from three years in a bakery in Lyon with a croissant he would not stop talking about.

We bake with flour from two mills in the province, butter from Asturias and eggs from the farm on the Sigüenza road. What is not sold by seven goes to the shelter on Calle Mayor.
:::

:::callout{type="hours"}
**Tuesday to Friday** :tab 7.00 – 19.00\
**Saturday and Sunday** :tab 8.00 – 19.00\
**Monday** :tab closed
:::

:::paragraphs{style="story"}
*Calle del Pozo 14 · 949 214 387 · We cut whole loaves on request.*
:::
`; // content.<lang>.md, inlined by the Cookbook

const painting = (id, [w, h], altText) => ({ id, typeId: 'painting', kind: 'bitmap',
  createdAt: 0, updatedAt: 0, bitmap: { fileId: `${id}.jpg`, format: 'jpeg', width: w,
    height: h }, altText });
const resourceTypes = [{ id: 'painting', name: '', captionPrefix: '', numberingTemplate: '' }];
const resources = [
  painting('loaf', [700, 683], t({ en: 'A round sourdough loaf with a floured, cross-cut crust, '
    + 'painted in gouache.', es: 'Una hogaza redonda de masa madre con la corteza enharinada '
    + 'y cortada en cruz, pintada al gouache.' })),
  painting('pastries', [900, 396], t({ en: 'A croissant, a glazed cinnamon roll and a slice of '
    + 'almond cake.', es: 'Un cruasán, una caracola de canela glaseada y una porción de tarta '
    + 'de almendra.' })),
  painting('coffee', [600, 600], t({ en: 'A white cup of milky coffee on a saucer, a spoon '
    + 'beside it.', es: 'Una taza blanca de café con leche en su plato, con la cucharilla.' })),
];
await Promise.all([loadImage('loaf.jpg', asset('loaf-700.jpg')),
  loadImage('pastries.jpg', asset('pastries-900.jpg')),
  loadImage('coffee.jpg', asset('coffee-600.jpg'))]);

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { 'Alfa Slab One': ['400'], Lora: ['400', '400i', '700'] };

// ─── 4 · Build & show ───────────────────────────────────────────────────────
const doc = await buildDocumentWithFonts({ markdown, resources }, { ...config(), resourceTypes },
  kitFonts(FONTS));
showPages(doc, { title: t({ en: 'Horno Alto · a bakery menu in white ink on kraft',
  es: 'Horno Alto · una carta de panadería en tinta blanca sobre kraft' }) });
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes,
  profileBaseUrl: 'https://postext.dev/icc/' }), `${RECIPE}.pdf`);

// #region preflight: what the press check says of the white
// A white ink on white paper prints nothing you can see, and the preflight warns of it
// (whiteInkOnWhite). On kraft it does not fire; the findings left say which special ink the
// job carries and that the press lays the white first.
const findings = preflightDocument(doc);
const report = document.createElement('p');
report.textContent = `Preflight: ${findings.map((f) => f.kind === 'inkPressOrder'
  ? `inkPressOrder (first: ${f.first.join(', ')})` : `${f.kind}${f.ink ? ` (${f.ink})` : ''}`)
  .join('; ') || 'no findings'}`;
document.querySelector(`[data-postext-pdf="${RECIPE}.pdf"]`).after(report);
// #endregion

// The card in the hand, open on the inside, so the white reads against the brown.
const stage = document.createElement('section');
stage.id = 'folio';
stage.ariaLabel = t({ en: 'The menu in 3D', es: 'La carta en 3D' });
stage.style.cssText = 'height: min(78vh, 720px); margin: 0 auto; max-width: 1280px';
document.getElementById('pages').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

### Una copertina di quaderno

Sostituisci il menù con un titolo e un motivo di filetti bianchi sul davanti: la carta, l'inchiostro e la tabella degli inchiostri restano come sono.

### Due passate di bianco

Il tipografo può stendere il bianco due volte per un bianco più pieno su un kraft scuro. Chiedilo nell'ordine; il file resta lo stesso, con una sola lastra di bianco.

## Errori frequenti

- Un inchiostro bianco su una pagina con carta bianca o non impostata non stampa nulla di visibile. Imposta `page.backgroundColor` sul supporto, in CMYK allo 0 %, e il controllo smette di avvisare.
- Un'immagine stampata direttamente sul kraft, senza bianco sotto, lascia vedere il bruno in tutti i toni chiari. Metti un riquadro del bianco sotto ogni immagine che deve conservare i suoi colori, come fanno qui i passe-partout.
- Il testo bianco sopra un colore non deve sovrastampare. Con l'impostazione predefinita si stampa sotto il colore e sparisce.

## Crediti

- Ricetta: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Immagini: A sourdough loaf, on the cover: Generated With Diffusion Models, originale
- Immagini: Three pastries: Generated With Diffusion Models, originale
- Immagini: A cup of coffee: Generated With Diffusion Models, originale
- Caratteri: Alfa Slab One (OFL-1.1), Lora (OFL-1.1)
- Codice: MIT · Contenuto di esempio: CC-BY-4.0

## Ricette correlate

- [Nº 052 · Menu da bistrot: i prezzi su una tabulazione](https://postext.dev/it/cookbook/bistro-menu.md): Un menu da bistrot fronte e retro: prezzi allineati a destra su un tabulatore, vini in una tabella senza bordi e un filetto ottone ai lati di ogni portata. · Livello 2 (Intermedio) · Fogli singoli ed effimeri
- [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º 195 · Un libro tunnel profondo venti fogli](https://postext.dev/it/cookbook/forest-tunnel-book.md): Diciannove finestre rotonde fustellate con dieCuts, ognuna più piccola della precedente: dalla copertina si vede attraverso venti piani fino a un cervo. · Livello 3 (Avanzato) · Fogli singoli ed effimeri
