# ソフトタッチの写真誌に部分グロスニス

> 2種類のニスを特色として扱います。全ページにソフトタッチ、写真と題字にはグロスを重ね、Folioと加工ビューで、どこにどのニスがかかるかを確かめます。

- HTML版: https://postext.dev/ja/cookbook/spot-uv-photo-magazine
- レシピ No. 192 · 出力と組み込み · 難易度 3 (上級) · 出力: Canvas, PDF
- ジャンル: 雑誌とジン
- 必要なもの postext ≥ 1.85.1, postext-pdf ≥ 1.85.1 · テスト環境 1.86.0, postext-pdf 1.86.0 ／テスト日 2026-11-14
- ページ: [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
- Sandboxで開く: https://postext.dev/ja/sandbox#recipe=spot-uv-photo-magazine&lang=en (.postext: https://postext.dev/cookbook/spot-uv-photo-magazine/en/spot-uv-photo-magazine.postext)
- 最終更新: 2026-11-13
- 他の言語: [en](https://postext.dev/en/cookbook/spot-uv-photo-magazine.md), [es](https://postext.dev/es/cookbook/spot-uv-photo-magazine.md), [ca](https://postext.dev/ca/cookbook/spot-uv-photo-magazine.md), [de](https://postext.dev/de/cookbook/spot-uv-photo-magazine.md), [fr](https://postext.dev/fr/cookbook/spot-uv-photo-magazine.md), [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), [ar](https://postext.dev/ar/cookbook/spot-uv-photo-magazine.md)

## かんたんな説明

全ページにビロードのような手ざわりのコーティング、写真と題字だけにつやのあるコーティングをかけた写真誌です。ニスには色がないので画面では普通のページに見え、3Dビューと校正用のビューでどこにかかっているかがわかります。

## できあがり

架空の写真誌『*Long Light*』の第14号です。210 × 280 mmの6ページで、無線綴じ。全ページにソフトタッチニスをかけます。紙のつやを消してしっとりと沈ませる、ビロードのような加工です。5枚の写真と題字の上には印刷所が2つ目のニス、グロスを重ね、まわりのページが静かなまま写真だけが光を拾うようにします。どちらのニスにも色はありません。キャンバスには刷り上がりどおりのページが表示され、Folioの横に並ぶ表紙の3つのビューで版とつやがわかります。Folioはスタジオの照明の下、大理石のテーブルに雑誌を開いて置き、ページをめくるとグロスがきらりと光ります。

**このレシピが答える問い:**

- 全ページにソフトタッチニス、写真だけに部分グロスニスをかけるには？

## 手短な答え

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

## 材料

**学べること**

- [特殊インキ](https://postext.dev/ja/docs/special-inks-die-cuts.md#加工): 加工の種類を持つ特色です。メタリック、箔押し、蛍光、不透明白、ニスがあります。専用の版に出力され、キャンバスでは光沢や加工マップを表示でき、Folioでは光が当たります。

**ほかに使うもの**

- [特色とインキ表](https://postext.dev/ja/docs/configuration-pdf-output.md#特色)
- [CMYKとグレースケールのPDF](https://postext.dev/ja/docs/configuration-fonts-colors-viewers.md#pdf生成設定)
- [3Dの本のビューアー（Folio）](https://postext.dev/ja/docs/configuration-html-folio-epub.md#3dの本postext-folio)
- [用紙、綴じ、机、照明（Folio）](https://postext.dev/ja/docs/configuration-fonts-colors-viewers.md#folioビューアー設定)
- [セマンティックカラーパレット](https://postext.dev/ja/docs/configuration-fonts-colors-viewers.md#カラーパレット)
- [表紙、扉、奥付](https://postext.dev/ja/docs/configuration-styles.md#見出しスタイル)
- [見出しスタイル](https://postext.dev/ja/docs/configuration-styles.md#見出しスタイル)
- [デザインした章扉](https://postext.dev/ja/docs/configuration-headings.md#幅と詳細デザイン)
- [ページデザインのテキスト・罫・ボックス](https://postext.dev/ja/docs/configuration-headers-footers.md#柱とノンブル)
- [ページデザインの画像](https://postext.dev/ja/docs/configuration-headers-footers.md#画像要素)
- [柱とノンブル](https://postext.dev/ja/docs/configuration-headers-footers.md#柱とノンブル)
- [PDFの書き出し](https://postext.dev/ja/docs/configuration-pdf-output.md#pdfの生成)
- [キャンバス上のページ](https://postext.dev/ja/docs/configuration-programmatic-usage.md#ページをビットマップに描画する)
- [見出しの属性](https://postext.dev/ja/docs/document-format.md#見出しの属性)
- [段抜きの章見出し帯](https://postext.dev/ja/docs/configuration-headings.md#幅と詳細デザイン)
- [用紙の色](https://postext.dev/ja/docs/configuration-page-layout.md#ページ)
- [PDFに埋め込むフォント](https://postext.dev/ja/docs/configuration-pdf-output.md#なぜフォントプロバイダーが必要か)
- [独自のリソースの種類](https://postext.dev/ja/docs/configuration-resources.md#リソースの種類)
- [リソースとしての図と表](https://postext.dev/ja/docs/document-format-resources.md#リソース)
- [節ごとの柱](https://postext.dev/ja/docs/configuration-styles.md#見出しスタイル)
- [番号のない章](https://postext.dev/ja/docs/configuration-styles.md#見出しスタイル)

**設定の一覧**

- [`bodyText`](https://postext.dev/ja/docs/configuration-text.md#本文), [`colorPalette`](https://postext.dev/ja/docs/configuration-fonts-colors-viewers.md#カラーパレット), [`folio`](https://postext.dev/ja/docs/configuration-html-folio-epub.md#外観), [`footer`](https://postext.dev/ja/docs/configuration-headers-footers.md#柱とノンブル), [`header`](https://postext.dev/ja/docs/configuration-headers-footers.md#柱とノンブル), [`headingStyles`](https://postext.dev/ja/docs/configuration-styles.md#見出しスタイル), [`headings`](https://postext.dev/ja/docs/configuration-headings.md#見出し), [`layout`](https://postext.dev/ja/docs/configuration-page-layout.md#レイアウト), [`locale`](https://postext.dev/ja/docs/configuration-language.md#ハイフネーション), [`page`](https://postext.dev/ja/docs/configuration-page-layout.md#ページ), [`print`](https://postext.dev/ja/docs/configuration-fonts-colors-viewers.md#印刷出力設定), [`resourceTypes`](https://postext.dev/ja/docs/configuration-resources.md#リソースの種類)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/ja/docs/configuration-programmatic-usage.md#レイアウトの前にフォントを読み込む), [`createFolioFromDocument`](https://postext.dev/ja/docs/configuration-html-folio-epub.md#3dの本postext-folio), [`decompressWoff2`](https://postext.dev/ja/docs/configuration-pdf-output.md#ブラウザー向けフォントプロバイダーfontsource--woff2), [`registerResourceImage`](https://postext.dev/ja/docs/architecture.md#apiの概要), [`renderPageToCanvas`](https://postext.dev/ja/docs/configuration-programmatic-usage.md#ページをビットマップに描画する), [`renderToPdf`](https://postext.dev/ja/docs/configuration-pdf-output.md#pdfの生成)

**書体**

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

## 作り方

### 1 · ニスはどれも加工つきの特色

コードは上の[手短な答え](https://postext.dev/ja/cookbook/spot-uv-photo-magazine.md#手短な答え)にあります。ニスとは加工が`varnish`の特色で、つやの種類を持ちます。ビロードには`softTouch`、部分UVには`gloss`です（[加工](https://postext.dev/ja/docs/special-inks-die-cuts.md#加工)）。PDF/X-4のファイルはそれぞれを専用の`Separation`に置くので、印刷所には4枚のプロセス版の隣に2枚のニス版が届きます。画面ではニスは何も描きませんが、それでも専用のhexが必要です。印刷用のレンダリングはインキをhexで見分けるからです。ニスは初期設定でオーバープリントになるので、どちらも下の色を抜きません。

### 2 · 全ページにソフトタッチ

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

ソフトタッチは、ニスで塗った裁ち落としから裁ち落としまでのボックス1つです。フッターに持たせるので、どのページにも同じ場所から入ります。印刷機ではニスは最後に、すべての上に刷られ、PDFでもページが後から描いたものがニスを抜くことはありません。ボックスをヘッダーの先頭に置いて本文やノンブルより前に描いても、それらは版の上でニスの下に収まります。表紙と裏表紙にはノンブルがなく、フッターはボックスだけを持ちます。

### 3 · 写真にグロス

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

写真はどれも画像で、その上に同じ大きさのグロスのボックスを重ねます。ボックスは後に置くので上に来ます。版の上では写真をぴったり覆う長方形になり、部分UVの版はこうして作ります。

### 4 · 題字を2回組む

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

題字は同じ位置にある2つのテキスト要素です。ひとつは紙白で写真から白抜きにし、もうひとつはその上にグロスで重ねます。グロスのほうは画面に何も描かず、版に文字の形を渡すだけです。刷り上がった表紙では、光る空の上で題字が光ります。

### 5 · 加工ビューとFolio

```js
// script.js, 行 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, 行 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`は`finishes`オプションを受け取ります。`'flat'`が初期値で、刷り上がりどおりのページを表示します。`'map'`はページを薄くし、特殊な版をそれぞれ疑似カラーで示します。ニスはシアンで、グロスはソフトタッチより明るく出ます。`'sheen'`はページの上に光を走らせます。Folioも同じ加工マスクを読みます。グロスはハイライトを拾い、ソフトタッチはそれを消します。

## レシピの全体

レシピのフォルダーから合成した1つのファイルで、サンプルのテキストとレシピ集の共通キットを埋め込んであり、自分でページを組み立てます。動かすには、空のページの`<script type="module">`に入れるか、新しいCodePenのpenのJSパネルに貼り付けます（モジュールとして）。esm.shからpostextを読み込むので、インストールもビルドも要りません。

- レシピのフォルダー: 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 ───────────────────────────────────────────────────────────────────────
```

## アレンジ

### ソフトタッチの代わりにマット

普通のマットニスは安く済み、同じコントラストが少し浅く出ます。

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

### 文字だけにグロス

写真はマットのままにして、グロスは題字と見出しだけにかけます。見出しも題字と同じように2回組み、写真の上のボックスは外します。

## よくあるつまずき

- ニスにほかの色と同じhexを付けると、その色として刷られます。ニスにはそれぞれ、ほかで使っていないhexを付けます。
- 全面のニスを仕上がりの線までで止めると、紙が少しずれて断裁されたときに縁にニスのない帯が残ります。ここのボックスのように裁ち落としまで伸ばします。
- ソフトタッチはニスではなくラミネート（PP貼り）として扱われることがよくあります。印刷所にどの版名がよいかを聞き、インキ表の`pdfName`で指定します。

## クレジット

- レシピ: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- 画像: A walker on a salt flat at dusk, on the cover: Generated With Diffusion Models, オリジナル
- 画像: A fisherman mending a net: Generated With Diffusion Models, オリジナル
- 画像: Pines in morning fog: Generated With Diffusion Models, オリジナル
- 画像: A desert road between mesas: Generated With Diffusion Models, オリジナル
- 画像: The salt flat at sunset, on the back cover: Generated With Diffusion Models, オリジナル
- 書体: Bodoni Moda (OFL-1.1), Source Serif 4 (OFL-1.1), Source Sans 3 (OFL-1.1)
- コード: MIT · サンプルの内容: CC-BY-4.0

## 関連レシピ

- [No. 188 · 濃紺の表紙に金の箔押し](https://postext.dev/ja/cookbook/gold-foil-poetry-cover.md): 金箔を加工付きの特色にします。PDFでは専用の版になり、Folioでは光り、紺の厚紙とクリームの紙はインキを刷りません。 · 難易度 3 (上級) · 詩歌
- [No. 190 · 黒と蛍光ピンクで刷る音楽ジン](https://postext.dev/ja/cookbook/fluorescent-pink-zine.md): 黒と蛍光ピンクの2版で刷る仕事です。写真はトーンカーブでダブルトーンにし、黒はオーバープリント、ピンクはFolioで紙より明るく光ります。 · 難易度 3 (上級) · 雑誌とジン
- [No. 102 · 厚紙の表紙を付けた中綴じのジン](https://postext.dev/ja/cookbook/saddle-stitched-card-cover.md): 2つの:::paperブロックで8ページのジンの外側の紙をサーモン色の厚紙にし、postext-folioが更紙の本文を中綴じにした姿で見せます。 · 難易度 2 (中級) · 雑誌とジン
