# La portada d’un diari grec a tres columnes

> Una portada en grec: capçalera en Didot, titular en versals sense tonos, una caplletra de tres línies amb entrada en majúscules i breus al peu.

- Versió HTML: https://postext.dev/ca/cookbook/greek-daily-front-page
- Recepta Núm. 204 · Pàgina i retícula · Nivell 2 (Intermedi) · Sortides: Canvas, PDF
- Gèneres: Diaris i butlletins
- Requereix postext ≥ 1.99.1, postext-pdf ≥ 1.99.1 · provada amb 1.99.1, postext-pdf 1.99.1 el 2026-11-29
- Pàgines: [1](https://postext.dev/cookbook/greek-daily-front-page/es/p01.webp?v=b6d187c9)
- PDF: https://postext.dev/cookbook/greek-daily-front-page/es/greek-daily-front-page.pdf?v=b6d187c9
- Obre al Sandbox: https://postext.dev/ca/sandbox#recipe=greek-daily-front-page&lang=es (.postext: https://postext.dev/cookbook/greek-daily-front-page/es/greek-daily-front-page.postext)
- Última actualització: 2026-11-29
- Altres idiomes: [en](https://postext.dev/en/cookbook/greek-daily-front-page.md), [es](https://postext.dev/es/cookbook/greek-daily-front-page.md), [de](https://postext.dev/de/cookbook/greek-daily-front-page.md), [el](https://postext.dev/el/cookbook/greek-daily-front-page.md), [fr](https://postext.dev/fr/cookbook/greek-daily-front-page.md), [it](https://postext.dev/it/cookbook/greek-daily-front-page.md), [pt](https://postext.dev/pt/cookbook/greek-daily-front-page.md), [zh](https://postext.dev/zh/cookbook/greek-daily-front-page.md), [ja](https://postext.dev/ja/cookbook/greek-daily-front-page.md), [ar](https://postext.dev/ar/cookbook/greek-daily-front-page.md)

## En poques paraules

La portada d’un diari local grec imaginari: el nom del diari a dalt, un gran titular en majúscules, la notícia principal en tres columnes que comença amb una lletra gran, un mapa petit, horaris de vaixells i breus a baix.

## Què compondràs

La portada d’*Ο Φάρος* («El Far»), un diari imaginari d’una ciutat portuària imaginària, en format compacte de 246 × 328 mm. La capçalera va en GFS Didot entre dues orelles; la notícia principal corre sota un titular de dues línies en versals estretes i una entradeta, i després per tres columnes de Noto Serif amb corondell, des d’una caplletra de tres línies. Un mapa de la badia, d’una columna, ocupa la columna central. Una segona notícia amb una taula de sortides de vaixells i una franja de breus, en tres columnes pròpies, tanquen la pàgina. Tot el text és original en grec; el peu d’impremta segueix la llengua de l’edició.

**Aquesta recepta respon a:**

- Com componc la portada d’un diari grec amb el titular en majúscules i una caplletra?
- Com afegeixo a una obertura una línia d'autor, una entradeta o un primer paràgraf amb caplletra?
- Com poso el títol de capítol a tota l'amplada mentre el text continua a dues columnes a sota?
- Com aconsegueixo una bona justificació i partició de mots en textos en castellà, francès o alemany?

## La resposta curta

```js
// script.js, línies 39–51
// locale 'el' hyphenates the narrow columns with the monotonic patterns and makes every
// capital setting drop the tonos: the lead headline is written «Ο φάρος του Αγίου Νικολάου
// ανάβει ξανά» in the Markdown and printed ΑΝΑΒΕΙ ΞΑΝΑ, never ΑΝΆΒΕΙ.
const LOCALE = 'el';
const layout = { layoutType: 'multiple', columnCount: 3, gutterWidth: mm(5),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
const headline = { id: 'lead', fontSize: pt(30), lineHeight: pt(34), fontWeight: 800,
  textTransform: 'uppercase', letterSpacing: em(0.01), marginBottom: pt(6) };
// :::paragraphs{style="lede"} opens the story: a drop cap three lines deep and its first
// four words in capitals, which drop the tonos the same way (ΜΕ ΜΙΑ ΓΙΟΡΤΗ).
const lede = { id: 'lede', firstLineIndent: pt(0),
  dropCap: { lines: 3, fontFamily: NAME, color: col('aegean'), gap: mm(1.2),
    leadIn: { words: 4, uppercase: true } } };
```

## Ingredients

**Ensenya**

- [Caplletres en paràgrafs de text](https://postext.dev/ca/docs/configuration-text.md#caplletres): dropCap en un nivell de títol, un estil de títol o un estil de paràgraf obre un paràgraf del text amb la primera lletra en gran al costat de les primeres línies, que s'escurcen i es componen amb el text; una inicial elevada, unes cometes d'obertura penjades o amb la lletra, una entrada en versaletes.
- [Tres o més columnes](https://postext.dev/ca/docs/configuration-page-layout.md#tipus-de-disposició): layoutType 'multiple' divideix el text en columnCount columnes iguals, de 3 a 8, per a diaris i revistes; els filets, l'equilibri, les notes al peu i els flotants a tota l'amplada funcionen en totes.
- [Partició de mots i llengua del document](https://postext.dev/ca/docs/justification.md#llengües-compatibles): Partició de mots amb patrons de TeX en nou llengües, el grec entre elles, segons el locale del document, que fixa també els textos de continuació de les taules i la llengua del PDF etiquetat.

**També fa servir**

- [Filet de columna](https://postext.dev/ca/docs/configuration-page-layout.md#filet-de-columna)
- [Requadres a tota l'amplada](https://postext.dev/ca/docs/configuration-callouts.md#el-contenidor-callout)
- [Columnes en un requadre o al text](https://postext.dev/ca/docs/document-format-directives.md#columns)
- [Requadres flotants](https://postext.dev/ca/docs/configuration-callouts.md#el-contenidor-callout)
- [Requadres](https://postext.dev/ca/docs/configuration-callouts.md#estils-de-requadre)
- [Estils de títol](https://postext.dev/ca/docs/configuration-styles.md#estils-dencapçalament)
- [Atributs de títol](https://postext.dev/ca/docs/document-format.md#atributs-dencapçalament)
- [Obertures dissenyades](https://postext.dev/ca/docs/configuration-headings.md#extensió-i-disseny-avançat)
- [Textos, filets i caixes als dissenys de pàgina](https://postext.dev/ca/docs/configuration-headers-footers.md#capçaleres-i-peus)
- [Tipus de recurs propis](https://postext.dev/ca/docs/configuration-resources.md#tipus-de-recurs)
- [Taules a partir de dades](https://postext.dev/ca/docs/document-format-resources.md#inserció-en-bloc-opcional-collocació-en-línia-explícita)
- [Estil dels peus](https://postext.dev/ca/docs/configuration-resources.md#estil-dels-peus-de-recurs)
- [Estils de paràgraf](https://postext.dev/ca/docs/configuration-styles.md#estils-de-paràgraf)
- [Exportació a PDF](https://postext.dev/ca/docs/configuration-pdf-output.md#generació-de-pdf)
- [Figures just aquí](https://postext.dev/ca/docs/document-format-resources.md#inserció-en-bloc-opcional-collocació-en-línia-explícita)
- [Banda de capítol d'amplada completa](https://postext.dev/ca/docs/configuration-headings.md#extensió-i-disseny-avançat)
- [Color del paper](https://postext.dev/ca/docs/configuration-page-layout.md#pàgina)
- [Fonts incrustades al PDF](https://postext.dev/ca/docs/configuration-pdf-output.md#per-què-un-proveïdor-de-fonts)
- [Figures i taules com a recursos](https://postext.dev/ca/docs/document-format-resources.md#recursos)
- [Capçaleres per secció](https://postext.dev/ca/docs/configuration-styles.md#estils-dencapçalament)

**La configuració d'un cop d'ull**

- [`bodyText`](https://postext.dev/ca/docs/configuration-text.md#text-de-cos), [`calloutStyles`](https://postext.dev/ca/docs/configuration-callouts.md#estils-de-requadre), [`captionStyle`](https://postext.dev/ca/docs/configuration-resources.md#estil-dels-peus-de-recurs), [`colorPalette`](https://postext.dev/ca/docs/configuration-fonts-colors-viewers.md#paleta-de-colors), [`footer`](https://postext.dev/ca/docs/configuration-headers-footers.md#capçaleres-i-peus), [`header`](https://postext.dev/ca/docs/configuration-headers-footers.md#capçaleres-i-peus), [`headingStyles`](https://postext.dev/ca/docs/configuration-styles.md#estils-dencapçalament), [`headings`](https://postext.dev/ca/docs/configuration-headings.md#encapçalaments), [`layout`](https://postext.dev/ca/docs/configuration-page-layout.md#disposició), [`locale`](https://postext.dev/ca/docs/configuration-language.md#partició-de-mots), [`page`](https://postext.dev/ca/docs/configuration-page-layout.md#pàgina), [`paragraphStyles`](https://postext.dev/ca/docs/configuration-styles.md#estils-de-paràgraf), [`resourceTypes`](https://postext.dev/ca/docs/configuration-resources.md#tipus-de-recurs), [`tableStyle`](https://postext.dev/ca/docs/configuration-resources.md#estil-de-taules)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/ca/docs/configuration-programmatic-usage.md#carregar-les-fonts-abans-de-compondre), [`decompressWoff2`](https://postext.dev/ca/docs/configuration-pdf-output.md#proveïdor-de-fonts-al-navegador-fontsource--woff2), [`registerResourceImage`](https://postext.dev/ca/docs/architecture.md#superfície-dapi), [`renderPageToCanvas`](https://postext.dev/ca/docs/configuration-programmatic-usage.md#renderitzar-una-pàgina-en-un-mapa-de-bits), [`renderToPdf`](https://postext.dev/ca/docs/configuration-pdf-output.md#generació-de-pdf)

**Tipus de lletra**

- GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)

## Elaboració

### 1 · Tres columnes de grec

El codi és [la resposta curta](https://postext.dev/ca/cookbook/greek-daily-front-page.md#la-resposta-curta) de dalt. `layoutType: 'multiple'` amb `columnCount: 3` munta tres columnes amb un filet fi entre elles ([maquetació de pàgina](https://postext.dev/ca/docs/configuration-page-layout.md)). `locale: 'el'` les parteix amb els patrons monotònics, cosa que compta en una columna de 69 mm on un mot grec ocupa sovint un terç de la línia. Espais de 0,8 a 1,6 vegades el normal i fins a 14 ‰ de tracking deixen una sola línia de la pàgina per sobre d’1,6.

### 2 · Un titular en versals, escrit en minúscula

El titular s’escriu «Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια» i el seu estil fixa `textTransform: 'uppercase'`. En un document grec les majúscules perden el tonos, i la pàgina imprimeix ΑΝΑΒΕΙ ΞΑΝΑ i ΥΣΤΕΡΑ, com s’escriuen els titulars grecs. L’avanttítol, les orelles i el títol dels breus duen la mateixa transformació.

```js
// script.js, línies 55–61
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...sans(9, 700, 'aegean', { letterSpacing: pt(1.6),
    textTransform: 'uppercase' }), gap: mm(1.5) }, // the kicker, from the fence's title
  marginTop: pt(LEAD), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(17), textAlign: 'left',
    firstLineIndent: pt(0) } };
```

El titular i l’entradeta van en una caixa `banner` amb `span: 'page'` i sense marc ([caixes](https://postext.dev/ca/docs/configuration-callouts.md)): les columnes de sota comencen a la mateixa altura, i la segona notícia repeteix el recurs.

### 3 · La caplletra i la seva entrada

L’estil de paràgraf `lede` dona al primer paràgraf del grup una caplletra de tres línies en GFS Didot, i `leadIn` posa els quatre mots següents en majúscules: ΜΕ ΜΙΑ ΓΙΟΡΤΗ ΠΟΥ. També perden els accents ([caplletres](https://postext.dev/ca/docs/configuration-text.md)). La notícia obre amb Μ; en una que obri amb majúscula accentuada (Έ, Ό), mira la caplletra a la pàgina, perquè els llibres grecs componen les inicials sense accent.

### 4 · La capçalera

```js
// script.js, línies 65–81
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
  content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 6)
    : at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(52) } }));
const caps = { letterSpacing: pt(1.4), textTransform: 'uppercase' };
const nameplate = { enabled: true, minHeight: mm(38), slot: { elements: [
  text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(60), lineHeight: 1.1,
    color: col('aegean'), align: 'center', ...caps, letterSpacing: pt(4) },
  { ...at('container', 'top', 0, 1), size: { width: 'fill' } }),
  ...ear('start', 'left', [['k', '{attr.issue}', sans(8, 700, 'aegean', caps)],
    ['d', '{publishDate}', sans(9, 400)]]),
  ...ear('end', 'right', [['k', '{attr.city}', sans(8, 700, 'aegean', caps)],
    ['p', '{attr.price}', sans(9, 400)]]),
  { kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 32), size: { width: 'fill' } } },
  { kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
    placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };
```

El títol del diari, «Ο Φάρος» al frontmatter, es compon en versals Didot espaiades: ΦΑΡΟΣ. Les orelles llegeixen els atributs de l’encapçalament, `issue`, `city` i `price`, i el `publishDate` del frontmatter.

## La recepta completa

Un sol fitxer, compost a partir de la carpeta de la recepta amb el text d'exemple i el kit comú del Receptari ja inclosos; construeix la seva pròpia pàgina. Per executar-lo, posa'l en un `<script type="module">` d'una pàgina buida o enganxa'l al tauler JS d'un pen nou de CodePen (com a mòdul). Importa postext des d'esm.sh, així que no cal instal·lar ni compilar res.

- Carpeta de la recepta: https://github.com/drnachio/postext/tree/main/cookbook/greek-daily-front-page

### script.js

```js
// ═══ Postext Cookbook · Nº 204 · A Greek daily's front page in three columns ═══════════
// https://postext.dev/en/cookbook/greek-daily-front-page
// Code: MIT · Text: original Greek news copy (CC BY 4.0) · Map: drawn in code (CC BY 4.0)
// Fonts: GFS Didot, Fira Sans Condensed, Noto Serif (SIL OFL 1.1) · Needs postext ≥ 1.99.1
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'es'; // @lang: the language of the imprint's last line; the paper is Greek
const RECIPE = 'greek-daily-front-page';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, black ink and the paper's Aegean blue
const palette = {
  ink: '#141518', // text and the heavy rules
  aegean: '#1d4f91', // the accent: the nameplate, kickers, the ferry lines
  foam: '#e4e9f0', // the In brief strip, the map's sea
  land: '#efe9dc', // the map's land
  rule: '#9a9890', // hairlines: the column rules, the imprint's rule
  muted: '#5a5852', // bylines, captions' notes, the imprint
  paper: '#f9f7f1', // newsprint
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [NAME, HEAD, TEXT] = ['GFS Didot', 'Fira Sans Condensed', 'Noto Serif']; // all with Greek
const TRIM = { width: 246, height: 328 }; // mm: a 3 : 4 compact
const SIDE = 12; // mm: newspaper margins, narrow and not mirrored
const LEAD = 13.5; // pt: the body leading, 1.5 × a 9 pt Noto Serif
const sans = (size, weight, colour = 'ink', extra = {}) => ({ fontFamily: HEAD, fontSize: pt(size),
  fontWeight: weight, color: col(colour), ...extra });
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
  ...look, placement });

// #region answer: Greek in three columns, the headline in capitals, the story under a drop cap
// locale 'el' hyphenates the narrow columns with the monotonic patterns and makes every
// capital setting drop the tonos: the lead headline is written «Ο φάρος του Αγίου Νικολάου
// ανάβει ξανά» in the Markdown and printed ΑΝΑΒΕΙ ΞΑΝΑ, never ΑΝΆΒΕΙ.
const LOCALE = 'el';
const layout = { layoutType: 'multiple', columnCount: 3, gutterWidth: mm(5),
  columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
const headline = { id: 'lead', fontSize: pt(30), lineHeight: pt(34), fontWeight: 800,
  textTransform: 'uppercase', letterSpacing: em(0.01), marginBottom: pt(6) };
// :::paragraphs{style="lede"} opens the story: a drop cap three lines deep and its first
// four words in capitals, which drop the tonos the same way (ΜΕ ΜΙΑ ΓΙΟΡΤΗ).
const lede = { id: 'lede', firstLineIndent: pt(0),
  dropCap: { lines: 3, fontFamily: NAME, color: col('aegean'), gap: mm(1.2),
    leadIn: { words: 4, uppercase: true } } };
// #endregion

// #region banner: headlines over the columns are page-span boxes without a frame
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
  padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
  titleStyle: { ...sans(9, 700, 'aegean', { letterSpacing: pt(1.6),
    textTransform: 'uppercase' }), gap: mm(1.5) }, // the kicker, from the fence's title
  marginTop: pt(LEAD), marginBottom: pt(LEAD / 2),
  body: { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(17), textAlign: 'left',
    firstLineIndent: pt(0) } };
// #endregion

// #region nameplate: the paper's name in Didot between two ears
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
  content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 6)
    : at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(52) } }));
const caps = { letterSpacing: pt(1.4), textTransform: 'uppercase' };
const nameplate = { enabled: true, minHeight: mm(38), slot: { elements: [
  text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(60), lineHeight: 1.1,
    color: col('aegean'), align: 'center', ...caps, letterSpacing: pt(4) },
  { ...at('container', 'top', 0, 1), size: { width: 'fill' } }),
  ...ear('start', 'left', [['k', '{attr.issue}', sans(8, 700, 'aegean', caps)],
    ['d', '{publishDate}', sans(9, 400)]]),
  ...ear('end', 'right', [['k', '{attr.city}', sans(8, 700, 'aegean', caps)],
    ['p', '{attr.price}', sans(9, 400)]]),
  { kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
    placement: { ...at('container', 'top-left', 0, 32), size: { width: 'fill' } } },
  { kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
    placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };
// #endregion

const config = () => ({
  locale: LOCALE, // written out, never LANG: the paper is Greek in every edition
  colorPalette, resourceTypes, layout,
  page: { width: mm(TRIM.width), height: mm(TRIM.height), dpi: 150,
    backgroundColor: col('paper'), margins: { top: mm(12), bottom: mm(14), left: mm(SIDE),
      right: mm(SIDE) } },
  bodyText: { fontFamily: TEXT, fontSize: pt(9), lineHeight: pt(LEAD), color: col('ink'),
    boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
    textAlign: 'justify', firstLineIndent: em(1), indentAfterHeading: false,
    // Columns of 69 mm hold about seven Greek words: wide spaces are let go first, then a
    // little tracking.
    hyphenateAcrossColumns: false, minWordSpacing: 0.8, maxWordSpacing: 1.6,
    maxJustifyTracking: 14 },
  headings: { fontFamily: HEAD, fontWeight: 700, color: col('ink'), marginBottom: pt(0),
    levels: [
      { level: 1, span: 'page' },
      { level: 2, fontSize: pt(16), lineHeight: pt(20), marginTop: pt(LEAD / 2) },
      { level: 3, fontSize: pt(10.5), lineHeight: pt(LEAD), marginTop: pt(LEAD / 2) },
    ] },
  headingStyles: [
    { id: 'front', advancedDesign: nameplate, header: { elements: [] } },
    headline,
    { id: 'wide', fontSize: pt(20), lineHeight: pt(24), marginBottom: pt(2) },
  ],
  calloutStyles: [banner,
    { ...banner, id: 'briefs', background: col('foam'), backgroundEnabled: true,
      padding: { top: mm(3), right: mm(4), bottom: mm(3.5), left: mm(4) }, columnGap: mm(6),
      marginTop: pt(LEAD), titleStyle: { ...sans(10, 800, 'aegean', caps), gap: mm(2) },
      body: { fontFamily: TEXT, fontSize: pt(8.5), lineHeight: pt(12.5), textAlign: 'left',
        firstLineIndent: pt(0) } }],
  paragraphStyles: [
    { id: 'byline', ...sans(8.5, 400, 'muted'), firstLineIndent: pt(0), textAlign: 'left' },
    lede,
    { id: 'imprint', ...sans(7.5, 400, 'muted'), lineHeight: pt(10), firstLineIndent: pt(0),
      textAlign: 'left', marginTop: pt(LEAD / 2), hyphenation: { enabled: false } },
  ],
  tableStyle: { rules: 'horizontal', borderColor: col('rule'), borderWidth: pt(0.5),
    headerBackground: col('aegean'), headerColor: col('paper'), headerFontFamily: HEAD,
    headerFontSize: pt(8.5), bodyFontFamily: HEAD, bodyFontSize: pt(9), bodyColor: col('ink'),
    cellPadding: mm(1.2) },
  captionStyle: { ...sans(8.5, 400), gap: mm(1.5),
    note: { fontSize: pt(7.5), color: col('muted') } },
  header: { elements: [] }, footer: { elements: [] },
});

// ─── 2 · Content ────────────────────────────────────────────────────────────
// The front page (content.text.<lang>.md), then the imprint in the edition's language.
const markdown = [String.raw`---
title: "Ο Φάρος"
publishDate: "Πέμπτη 1 Οκτωβρίου 2026"
---

# Ο Φάρος {style="front" issue="Έτος 38 · Αρ. φύλλου 11.204" city="Άγιος Νικόλαος" price="Τιμή: 1,50 €"}

:::callout{type="banner" title="Πόλη"}
## Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια {style="lead"}

**Πάνω από τρεις χιλιάδες κάτοικοι ανέβηκαν χθες το βράδυ στο ακρωτήρι για να δουν το πρώτο φως. Ο δήμος θα ανοίγει τον πύργο στους επισκέπτες κάθε Σαββατοκύριακο.**
:::

:::paragraphs{style="byline"}
Γράφει η **Ελένη Μαυρίδη**
:::

:::paragraphs{style="lede"}
Με μια γιορτή που κράτησε ως τα μεσάνυχτα, η πόλη είδε χθες ξανά το φως του φάρου της να γυρίζει πάνω από τον κόλπο. Στις οχτώ και δέκα ακριβώς, ο τελευταίος φαροφύλακας της πόλης, ο ογδοντάχρονος Μιχάλης Σταυρόπουλος, γύρισε τον διακόπτη και ο φακός άρχισε να στρίβει, ενώ οι καμπάνες του Αγίου Νικολάου χτυπούσαν και τα καΐκια στο λιμάνι σφύριζαν.
:::

Ο φάρος χτίστηκε το 1889 και έσβησε το 1986, όταν η ναυσιπλοΐα πέρασε στα ηλεκτρονικά συστήματα και ο πύργος έμεινε χωρίς φύλακα. Οι αρμύρες έφαγαν τα σίδερα της σκάλας, ο φακός κατέβηκε σε μια αποθήκη του λιμεναρχείου και τα παράθυρα σφραγίστηκαν με τσιμεντόλιθους.

Η αποκατάσταση κράτησε τρία χρόνια και κόστισε 1,2 εκατομμύρια ευρώ, από τα οποία τα μισά ήρθαν από ευρωπαϊκό πρόγραμμα. Οι μάστορες ξήλωσαν και ξανάστησαν τη σκάλα σκαλί σκαλί, με λάμες σφυρήλατου σιδήρου στα σχέδια του 1889, και ένας Γάλλος τεχνίτης καθάρισε και ξαναζύγισε τον παλιό φακό Fresnel.

### Ο φύλακας και τα κλειδιά

«Ήρθα εδώ το 1962, είκοσι δύο χρονών», είπε ο κ. Σταυρόπουλος στους δημοσιογράφους, κρατώντας τα παλιά κλειδιά του πύργου. «Κάθε βράδυ ανέβαινα εκατόν δεκαέξι σκαλιά. Όταν τον έσβησαν, νόμιζα πως δεν θα τον ξανάβλεπα αναμμένο». Ο δήμαρχος τού παρέδωσε τιμητικά ένα αντίγραφό τους.

::resource{id="kolpos"}

Το φως δεν θα οδηγεί πια τα πλοία, που ταξιδεύουν με δορυφορικά συστήματα, όμως το λιμεναρχείο το κατέγραψε ξανά στους χάρτες ως βοηθητικό σήμα. Θα ανάβει κάθε βράδυ με το σούρουπο και θα σβήνει την αυγή, με δύο αναλαμπές κάθε δεκαπέντε δευτερόλεπτα, όπως παλιά.

### Επισκέψεις στον πύργο

Από το ερχόμενο Σάββατο ο πύργος θα δέχεται επισκέπτες κάθε Σαββατοκύριακο, από τις δέκα το πρωί ως τη δύση του ήλιου. Η είσοδος θα κοστίζει τρία ευρώ, ενώ για τους μαθητές και τους κατοίκους του δήμου θα είναι δωρεάν. Στο ισόγειο, στο παλιό σπίτι του φύλακα, ετοιμάζεται μικρό μουσείο με τα ημερολόγια της υπηρεσίας και φωτογραφίες από το αρχείο του λιμεναρχείου.

:::callout{type="banner" title="Λιμάνι"}
## Δύο νέα δρομολόγια για τη Μικρή Ροδιά {style="wide"}
:::

:::paragraphs{style="byline"}
Γράφει ο **Νίκος Αλεξίου**
:::

Από τη Δευτέρα το καραβάκι για τη Μικρή Ροδιά θα κάνει δύο δρομολόγια την ημέρα αντί για ένα, ως το τέλος Οκτωβρίου. Η απόφαση πάρθηκε ύστερα από αίτημα του συλλόγου του νησιού, γιατί τα παιδιά που φοιτούν στο λύκειο της πόλης έμεναν ως το απόγευμα στην αποβάθρα. Το εισιτήριο μένει στα τέσσερα ευρώ.

::resource{id="dromologia"}

:::callout{type="briefs" span="page" placement="bottom" title="Σύντομα"}
:::columns{count=3 breaks="2,3"}
**Η βιβλιοθήκη ανοίγει τα βράδια.** Η δημοτική βιβλιοθήκη θα μένει ανοιχτή ως τις δέκα το βράδυ τις καθημερινές, όσο κρατούν οι εξετάσεις.

**Αρχίζει η σαρδέλα.** Η περίοδος της σαρδέλας ανοίγει στις 15 Οκτωβρίου, μια εβδομάδα νωρίτερα από κάθε χρόνο.

**Κλειστή η παραλιακή.** Η παραλιακή κλείνει την Κυριακή από τις επτά ως τις έντεκα το πρωί, για τον αγώνα δρόμου της πόλης.
:::
:::
`, String.raw`:::paragraphs{style="imprint"}
Un diario imaginario de una ciudad imaginaria, escrito en griego para el Recetario de Postext. Compuesto en GFS Didot, Fira Sans Condensed y Noto Serif (SIL OFL). Texto y mapa originales, con licencia CC BY 4.0.
:::
`].join('\n\n');

// #region art: the bay, the lighthouse on its cape and the two ferry lines
function baySvg() { // 69 × 52 mm, 1 unit = 1 mm: one column wide
  const [W, H] = [69, 52];
  const land = 'M0 0H69V14C60 16 55 12 50 15S44 24 38 22S30 14 24 17S18 30 12 28S4 22 0 24Z';
  const island = 'M44 40C47 37 53 37 56 40S54 46 50 46S41 43 44 40Z';
  const line = (d) => `<path d="${d}" fill="none" stroke="${palette.aegean}" stroke-width="0.8" `
    + 'stroke-dasharray="2 1.4"/>';
  const beam = `<path d="M12 28L-4 52H22Z" fill="${palette.aegean}" fill-opacity="0.12"/>`;
  return `<svg xmlns="http://www.w3.org/2000/svg" width="${W * 10}" height="${H * 10}" `
    + `viewBox="0 0 ${W} ${H}"><rect width="${W}" height="${H}" fill="${palette.foam}"/>${beam}`
    + `<path d="${land}" fill="${palette.land}" stroke="${palette.rule}" stroke-width="0.3"/>`
    + `<path d="${island}" fill="${palette.land}" stroke="${palette.rule}" stroke-width="0.3"/>`
    + line('M38 22C40 30 44 34 48 38') + line('M38 22C34 34 30 44 28 52')
    + `<circle cx="38" cy="21.5" r="1.4" fill="${palette.ink}"/>`
    + `<circle cx="12" cy="28" r="1.8" fill="${palette.paper}" stroke="${palette.ink}" `
    + 'stroke-width="0.7"/></svg>';
}
// #endregion
// Newspapers do not number their pictures: a type with no caption label and no counter.
const unnumbered = (id, name, captionStyle) => ({ id, name, shortLabel: name, captionPrefix: '',
  numberingTemplate: '', resetOn: 'never', counterFormat: 'decimal', captionStyle });
const resourceTypes = [unnumbered('picture', 'Χάρτης'),
  unnumbered('panel', 'Πίνακας', { position: 'above' })]; // tables titled above
// The day's sailings from the harbour, one row a ship.
const SAILINGS = [['07:30', 'Πειραιάς', 'Αγία Θεοδώρα'], ['09:15', 'Νησί Ροδιάς', 'Μικρή Ροδιά'],
  ['13:40', 'Νησί Ροδιάς', 'Μικρή Ροδιά'], ['17:00', 'Πειραιάς', 'Αγία Θεοδώρα']];
const cell = (content, extra = {}) => ({ content, ...extra });
const sailings = { headerRowCount: 1, rows: [
  ['Ώρα', 'Προορισμός', 'Πλοίο'].map((head) => cell(head, { isHeader: true })),
  ...SAILINGS.map((row) => row.map((value) => cell(value))),
] };
const resources = [
  { id: 'kolpos', typeId: 'picture', kind: 'svg', createdAt: 0, updatedAt: 0,
    svg: { fileId: 'bay.svg', width: 690, height: 520 }, placement: { position: 'here' },
    caption: '**Ο κόλπος του Αγίου Νικολάου.** Ο φάρος στο ακρωτήρι και οι δύο γραμμές των '
      + 'πλοίων από το λιμάνι.',
    altText: 'Χάρτης: ακτή στο πάνω μέρος, ένα ακρωτήρι αριστερά με τον φάρο, το λιμάνι στη '
      + 'μέση και δύο διακεκομμένες γραμμές πλοίων, η μία προς ένα νησάκι και η άλλη προς '
      + 'το ανοιχτό πέλαγος.' },
  { id: 'dromologia', typeId: 'panel', kind: 'table', createdAt: 0, updatedAt: 0,
    table: { model: sailings }, placement: { position: 'here' },
    caption: '**Δρομολόγια** από το λιμάνι, Πέμπτη 1 Οκτωβρίου' },
];

// ─── 3 · Fonts ──────────────────────────────────────────────────────────────
const FONTS = { // every face the page uses, loaded before the build
  'GFS Didot': ['400'], // NAME: the nameplate and the drop cap
  'Fira Sans Condensed': ['400', '700', '800'], // HEAD: headlines, kickers, bylines, table
  'Noto Serif': ['400', '700'], // TEXT: the stories and the standfirsts; bold emphasis
};

// ─── 4 · Build & show ───────────────────────────────────────────────────────
await loadSvg('bay.svg', baySvg());
const doc = await buildDocumentWithFonts({ markdown, resources }, config(), kitFonts(FONTS));
showPages(doc, { title: 'Ο Φάρος' });
offerPdf(() => renderToPdf(doc, { fontProvider: fontsourceProvider, resourceBytes: imageBytes }),
  `${RECIPE}.pdf`);

// ─── 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 ───────────────────────────────────────────────────────────────────────
```

## Errors freqüents

- Una caixa que demana caplletra es compon sense: el primer paràgraf d’una notícia ha de ser al flux, després de la caixa, no a dins.
- Els breus són una caixa amb `placement="bottom"`: si la pàgina es passa una línia, tota la franja salta a la pàgina següent. Retalla text fins que hi càpiga.
- Les orelles fan 52 mm. Una línia de número més llarga es parteix, i la segona línia corre sota la primera lletra de la capçalera; mesura les orelles amb el buit que deixa el nom.

## Crèdits

- Recepta: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Tipus de lletra: GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)
- Codi: MIT · Contingut d'exemple: CC-BY-4.0

## Relacionades

- [Núm. 108 · Una pàgina de diari àrab a dues columnes](https://postext.dev/ca/cookbook/arabic-newspaper-two-columns.md): Un diari àrab amb locale 'ar': la primera columna és la dreta, els titulars ocupen les dues i els breus van en tres columnes de dreta a esquerra. · Nivell 2 (Intermedi) · Diaris i butlletins
- [Núm. 201 · Una novel·la grega amb partició monotònica](https://postext.dev/ca/cookbook/monotonic-greek-novel.md): El primer capítol de «Η τιμή και το χρήμα» de Theotokis en un llibre de 13,5 × 20,5 cm: patrons del grec monotònic, cometes «» i versals sense accent. · Nivell 2 (Intermedi) · Narrativa, teatre i prosa literària
- [Núm. 203 · Un capítol d’un llibre de matemàtiques grec](https://postext.dev/ca/cookbook/greek-maths-textbook.md): Tres pàgines sobre el teorema de Pitàgores per a alumnes grecs: seccions 3.1 a 3.3 en versals sense tonos, rètols Εικόνα i Πίνακας i fórmules de MathJax. · Nivell 3 (Avançat) · Llibres de text
