# La prima pagina di un quotidiano greco a tre colonne

> Una prima pagina in greco: testata in Didot, titolo in maiuscolo senza tonos, un capolettera di tre righe con attacco in maiuscolo e brevi al piede.

- Versione HTML: https://postext.dev/it/cookbook/greek-daily-front-page
- Ricetta Nº 204 · Pagina e griglia · Livello 2 (Intermedio) · Output: Canvas, PDF
- Generi: Giornali e newsletter
- Richiede postext ≥ 1.99.1, postext-pdf ≥ 1.99.1 · provata con 1.99.1, postext-pdf 1.99.1 il 2026-11-29
- Pagine: [1](https://postext.dev/cookbook/greek-daily-front-page/en/p01.webp?v=a90d97d9)
- PDF: https://postext.dev/cookbook/greek-daily-front-page/en/greek-daily-front-page.pdf?v=a90d97d9
- Apri nella Sandbox: https://postext.dev/it/sandbox#recipe=greek-daily-front-page&lang=en (.postext: https://postext.dev/cookbook/greek-daily-front-page/en/greek-daily-front-page.postext)
- Ultimo aggiornamento: 2026-11-29
- Altre lingue: [en](https://postext.dev/en/cookbook/greek-daily-front-page.md), [es](https://postext.dev/es/cookbook/greek-daily-front-page.md), [ca](https://postext.dev/ca/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), [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)

## In breve

La prima pagina di un immaginario giornale locale greco: il nome in alto, un grande titolo in maiuscolo, l’articolo principale su tre colonne con una lettera grande all’inizio, una cartina, gli orari dei traghetti e le brevi.

## Che cosa comporrai

La prima pagina di *Ο Φάρος* («Il Faro»), un quotidiano immaginario di una città portuale immaginaria, in formato compatto di 246 × 328 mm. La testata è in GFS Didot fra due manchette; l’articolo principale corre sotto un titolo di due righe in maiuscolo stretto e un sommario, poi su tre colonne di Noto Serif con filetti, a partire da un capolettera di tre righe. Una cartina della baia, larga una colonna, occupa la colonna centrale. Un secondo articolo con una tabella delle partenze e una fascia di brevi, su tre colonne proprie, chiudono la pagina. Tutto il testo è originale in greco; il colophon segue la lingua dell’edizione.

**Questa ricetta risponde a:**

- Come compongo la prima pagina di un quotidiano greco con il titolo in maiuscolo e un capolettera?
- Come aggiungo a un’apertura una riga d’autore, un sommario o un attacco con capolettera?
- Come compongo il titolo di un capitolo a tutta larghezza mentre il testo scorre sotto su due colonne?
- Come ottengo una buona giustificazione e sillabazione per testi in spagnolo, francese o tedesco?

## La risposta breve

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

## Ingredienti

**Insegna**

- [Capilettera nei paragrafi del testo corrente](https://postext.dev/it/docs/configuration-text.md#capilettera): dropCap su un livello di titolo, uno stile di titolo o uno stile di paragrafo apre un paragrafo del testo corrente con la prima lettera in grande accanto alle prime righe, che si accorciano e si compongono con il testo; un’iniziale sporgente, una virgoletta d’apertura appesa o composta con la lettera, un attacco in maiuscoletto.
- [Tre o più colonne](https://postext.dev/it/docs/configuration-page-layout.md#tipi-di-impaginazione): layoutType 'multiple' divide il testo corrente in columnCount colonne uguali, da 3 a 8, per quotidiani e riviste; filetti, bilanciamento, note a piè di pagina ed elementi flottanti a tutta larghezza funzionano su tutte.
- [Sillabazione e lingua del documento](https://postext.dev/it/docs/justification.md#lingue-supportate): Sillabazione dai pattern di TeX in nove lingue, tra cui il greco, scelta dal locale del documento, che imposta anche le diciture di continuazione delle tabelle e la lingua del PDF con tag.

**Usa anche**

- [Filetto tra le colonne](https://postext.dev/it/docs/configuration-page-layout.md#filetto-tra-le-colonne)
- [Riquadri a tutta larghezza](https://postext.dev/it/docs/configuration-callouts.md#il-contenitore-callout)
- [Colonne in un riquadro o nel testo](https://postext.dev/it/docs/document-format-directives.md#columns)
- [Riquadri flottanti](https://postext.dev/it/docs/configuration-callouts.md#il-contenitore-callout)
- [Riquadri](https://postext.dev/it/docs/configuration-callouts.md#stili-dei-riquadri)
- [Stili di titolo](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)
- [Attributi dei titoli](https://postext.dev/it/docs/document-format.md#attributi-dei-titoli)
- [Aperture progettate](https://postext.dev/it/docs/configuration-headings.md#estensione-e-grafica-avanzata)
- [Testo, filetti e riquadri nei progetti di pagina](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina)
- [Tipi di risorsa personalizzati](https://postext.dev/it/docs/configuration-resources.md#tipi-di-risorsa)
- [Tabelle dai dati](https://postext.dev/it/docs/document-format-resources.md#inserimento-di-blocco-facoltativo-collocazione-in-linea-esplicita)
- [Stile delle didascalie](https://postext.dev/it/docs/configuration-resources.md#stile-delle-didascalie)
- [Stili di paragrafo](https://postext.dev/it/docs/configuration-styles.md#stili-di-paragrafo)
- [Esportazione in PDF](https://postext.dev/it/docs/configuration-pdf-output.md#generare-pdf)
- [Figure proprio qui](https://postext.dev/it/docs/document-format-resources.md#inserimento-di-blocco-facoltativo-collocazione-in-linea-esplicita)
- [Fascia di capitolo a tutta larghezza](https://postext.dev/it/docs/configuration-headings.md#estensione-e-grafica-avanzata)
- [Colore della carta](https://postext.dev/it/docs/configuration-page-layout.md#pagina)
- [Font incorporati nel PDF](https://postext.dev/it/docs/configuration-pdf-output.md#perché-un-provider-di-font)
- [Figure e tabelle come risorse](https://postext.dev/it/docs/document-format-resources.md#risorse)
- [Testatine per sezione](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli)

**La configurazione in breve**

- [`bodyText`](https://postext.dev/it/docs/configuration-text.md#testo-corrente), [`calloutStyles`](https://postext.dev/it/docs/configuration-callouts.md#stili-dei-riquadri), [`captionStyle`](https://postext.dev/it/docs/configuration-resources.md#stile-delle-didascalie), [`colorPalette`](https://postext.dev/it/docs/configuration-fonts-colors-viewers.md#tavolozza-dei-colori), [`footer`](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina), [`header`](https://postext.dev/it/docs/configuration-headers-footers.md#intestazioni-e-piè-di-pagina), [`headingStyles`](https://postext.dev/it/docs/configuration-styles.md#stili-dei-titoli), [`headings`](https://postext.dev/it/docs/configuration-headings.md#titoli), [`layout`](https://postext.dev/it/docs/configuration-page-layout.md#impaginazione), [`locale`](https://postext.dev/it/docs/configuration-language.md#sillabazione), [`page`](https://postext.dev/it/docs/configuration-page-layout.md#pagina), [`paragraphStyles`](https://postext.dev/it/docs/configuration-styles.md#stili-di-paragrafo), [`resourceTypes`](https://postext.dev/it/docs/configuration-resources.md#tipi-di-risorsa), [`tableStyle`](https://postext.dev/it/docs/configuration-resources.md#stile-delle-tabelle)

**API**

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

**Caratteri**

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

## Preparazione

### 1 · Tre colonne di greco

Il codice è [la risposta breve](https://postext.dev/it/cookbook/greek-daily-front-page.md#la-risposta-breve) qui sopra. `layoutType: 'multiple'` con `columnCount: 3` imposta tre colonne con un filetto sottile in mezzo ([impaginazione](https://postext.dev/it/docs/configuration-page-layout.md)). `locale: 'el'` le sillaba con gli schemi monotonici, cosa che conta in una colonna di 69 mm dove una parola greca occupa spesso un terzo della riga. Spazi da 0,8 a 1,6 volte il normale e fino al 14 ‰ di spaziatura lasciano una sola riga della pagina oltre 1,6.

### 2 · Un titolo in maiuscolo, scritto in minuscolo

Il titolo si scrive «Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια» e il suo stile fissa `textTransform: 'uppercase'`. In un documento greco le maiuscole perdono il tonos, così la pagina stampa ΑΝΑΒΕΙ ΞΑΝΑ e ΥΣΤΕΡΑ, come si scrivono i titoli greci. L’occhiello, le manchette e il titolo delle brevi prendono la stessa trasformazione.

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

Il titolo e il suo sommario stanno in un riquadro `banner` con `span: 'page'` e senza cornice ([riquadri](https://postext.dev/it/docs/configuration-callouts.md)): le colonne sotto partono alla stessa altezza, e il secondo articolo ripete l’espediente.

### 3 · Il capolettera e il suo attacco

Lo stile di paragrafo `lede` dà al primo paragrafo del suo gruppo un capolettera di tre righe in GFS Didot, e `leadIn` mette le quattro parole seguenti in maiuscolo: ΜΕ ΜΙΑ ΓΙΟΡΤΗ ΠΟΥ. Anche loro perdono gli accenti ([capilettera](https://postext.dev/it/docs/configuration-text.md)). L’articolo si apre con Μ; in uno che si apra con una maiuscola accentata (Έ, Ό), guarda il capolettera sulla pagina, perché i libri greci compongono le iniziali senza accento.

### 4 · La testata

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

Il titolo del giornale, «Ο Φάρος» nel frontmatter, è composto in maiuscole Didot spaziate: ΦΑΡΟΣ. Le manchette leggono gli attributi del titolo, `issue`, `city` e `price`, e il `publishDate` del frontmatter.

## La ricetta completa

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

- Cartella della ricetta: https://github.com/drnachio/postext/tree/main/cookbook/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 = 'en'; // @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"}
An imaginary daily from an imaginary town, written in Greek for the Postext Cookbook. Set in GFS Didot, Fira Sans Condensed and Noto Serif (SIL OFL). Text and map are original and licensed 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 ───────────────────────────────────────────────────────────────────────
```

## Errori frequenti

- Un riquadro che chiede un capolettera viene composto senza: il primo paragrafo di un articolo deve stare nel flusso, dopo il riquadro, non dentro.
- Le brevi sono un riquadro con `placement="bottom"`: se la pagina sfora di una riga, l’intera fascia passa alla pagina seguente. Taglia il testo finché ci sta.
- Le manchette sono larghe 52 mm. Una riga di numero più lunga va a capo, e la sua seconda riga corre sotto la prima lettera della testata; misura le manchette sullo spazio che lascia il nome.

## Crediti

- Ricetta: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Caratteri: GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)
- Codice: MIT · Contenuto di esempio: CC-BY-4.0

## Ricette correlate

- [Nº 108 · Una pagina di quotidiano arabo a due colonne](https://postext.dev/it/cookbook/arabic-newspaper-two-columns.md): Un quotidiano arabo con locale 'ar': la prima colonna è quella di destra, i titoli coprono le due colonne e la fascia In breve compone tre colonne da destra. · Livello 2 (Intermedio) · Giornali e newsletter
- [Nº 201 · Un romanzo greco con sillabazione monotonica](https://postext.dev/it/cookbook/monotonic-greek-novel.md): Il primo capitolo di «Η τιμή και το χρήμα» di Theotokis in un libro di 13,5 × 20,5 cm: schemi del greco monotonico, virgolette «» e maiuscole senza accento. · Livello 2 (Intermedio) · Narrativa, teatro e prosa letteraria
- [Nº 203 · Un capitolo di un libro di matematica greco](https://postext.dev/it/cookbook/greek-maths-textbook.md): Tre pagine sul teorema di Pitagora per alunni greci: sezioni da 3.1 a 3.3 in maiuscolo senza tonos, etichette Εικόνα e Πίνακας e formule MathJax. · Livello 3 (Avanzato) · Libri di testo
