# La portada de un diario griego a tres columnas

> Una portada en griego: cabecera en Didot, titular en versales sin tonos, una capitular de tres líneas con entrada en mayúsculas y breves al pie.

- Versión HTML: https://postext.dev/es/cookbook/greek-daily-front-page
- Receta N.º 204 · Página y retícula · Nivel 2 (Intermedio) · Salidas: Canvas, PDF
- Géneros: Periódicos y boletines
- Requiere postext ≥ 1.99.1, postext-pdf ≥ 1.99.1 · probada con 1.99.1, postext-pdf 1.99.1 el 2026-11-29
- Páginas: [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
- Abrir en el Sandbox: https://postext.dev/es/sandbox#recipe=greek-daily-front-page&lang=es (.postext: https://postext.dev/cookbook/greek-daily-front-page/es/greek-daily-front-page.postext)
- Última actualización: 2026-11-29
- Otros idiomas: [en](https://postext.dev/en/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), [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 pocas palabras

La portada de un periódico local griego imaginario: el nombre del diario arriba, un gran titular en mayúsculas, la noticia principal en tres columnas que empieza con una letra grande, un mapa pequeño, horarios de barcos y breves abajo.

## Lo que vas a componer

La portada de *Ο Φάρος* («El Faro»), un diario imaginario de una ciudad portuaria imaginaria, en formato compacto de 246 × 328 mm. La cabecera va en GFS Didot entre dos orejas; la noticia principal corre bajo un titular de dos líneas en versales estrechas y una entradilla, y después por tres columnas de Noto Serif con corondel, desde una capitular de tres líneas. Un mapa de la bahía, de una columna, ocupa la columna central. Una segunda noticia con una tabla de salidas de barcos y una franja de breves, en tres columnas propias, cierran la página. Todo el texto es original en griego; el pie de imprenta sigue la lengua de la edición.

**Esta receta responde a:**

- ¿Cómo compongo la portada de un diario griego con el titular en mayúsculas y una capitular?
- ¿Cómo añado a una apertura una línea de autor, una entradilla o un primer párrafo con capitular?
- ¿Cómo pongo el título de capítulo a todo el ancho mientras el texto sigue a dos columnas debajo?
- ¿Cómo consigo una buena justificación y separación silábica en textos en español, francés o alemán?

## La respuesta corta

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

## Ingredientes

**Enseña**

- [Capitulares en párrafos de texto](https://postext.dev/es/docs/configuration-text.md#letras-capitulares): dropCap en un nivel de título, un estilo de título o un estilo de párrafo abre un párrafo del texto con su primera letra en grande junto a sus primeras líneas, que se acortan y se componen con el texto; una inicial elevada, una comilla de apertura colgada o junto a la letra, una entrada en versalitas.
- [Tres o más columnas](https://postext.dev/es/docs/configuration-page-layout.md#tipos-de-disposición): layoutType 'multiple' divide el texto en columnCount columnas iguales, de 3 a 8, para periódicos y revistas; los filetes, el equilibrado, las notas al pie y los flotantes a todo el ancho funcionan en todas ellas.
- [Separación silábica e idioma del documento](https://postext.dev/es/docs/justification.md#idiomas-admitidos): Separación silábica con patrones de TeX en nueve idiomas, el griego entre ellos, según el locale del documento, que fija también los textos de continuación de las tablas y el idioma del PDF etiquetado.

**También usa**

- [Filete de columna](https://postext.dev/es/docs/configuration-page-layout.md#filete-de-columna)
- [Recuadros a todo el ancho](https://postext.dev/es/docs/configuration-callouts.md#el-contenedor-callout)
- [Columnas en un recuadro o en el texto](https://postext.dev/es/docs/document-format-directives.md#columns)
- [Recuadros flotantes](https://postext.dev/es/docs/configuration-callouts.md#el-contenedor-callout)
- [Recuadros](https://postext.dev/es/docs/configuration-callouts.md#estilos-de-recuadro)
- [Estilos de título](https://postext.dev/es/docs/configuration-styles.md#estilos-de-encabezado)
- [Atributos de título](https://postext.dev/es/docs/document-format.md#atributos-de-encabezado)
- [Aperturas diseñadas](https://postext.dev/es/docs/configuration-headings.md#apertura-a-toda-página-y-diseño-avanzado)
- [Textos, filetes y cajas en los diseños de página](https://postext.dev/es/docs/configuration-headers-footers.md#cabeceras-y-pies)
- [Tipos de recurso propios](https://postext.dev/es/docs/configuration-resources.md#tipos-de-recurso)
- [Tablas a partir de datos](https://postext.dev/es/docs/document-format-resources.md#inserción-en-bloque-opcional-colocación-en-línea-explícita)
- [Estilo de los pies](https://postext.dev/es/docs/configuration-resources.md#estilo-de-pies-de-recurso)
- [Estilos de párrafo](https://postext.dev/es/docs/configuration-styles.md#estilos-de-párrafo)
- [Exportación a PDF](https://postext.dev/es/docs/configuration-pdf-output.md#generación-de-pdf)
- [Figuras justo aquí](https://postext.dev/es/docs/document-format-resources.md#inserción-en-bloque-opcional-colocación-en-línea-explícita)
- [Banda de capítulo a todo el ancho](https://postext.dev/es/docs/configuration-headings.md#apertura-a-toda-página-y-diseño-avanzado)
- [Color del papel](https://postext.dev/es/docs/configuration-page-layout.md#página)
- [Fuentes incrustadas en el PDF](https://postext.dev/es/docs/configuration-pdf-output.md#por-qué-un-proveedor-de-fuentes)
- [Figuras y tablas como recursos](https://postext.dev/es/docs/document-format-resources.md#recursos)
- [Cabeceras por sección](https://postext.dev/es/docs/configuration-styles.md#estilos-de-encabezado)

**La configuración de un vistazo**

- [`bodyText`](https://postext.dev/es/docs/configuration-text.md#texto-base), [`calloutStyles`](https://postext.dev/es/docs/configuration-callouts.md#estilos-de-recuadro), [`captionStyle`](https://postext.dev/es/docs/configuration-resources.md#estilo-de-pies-de-recurso), [`colorPalette`](https://postext.dev/es/docs/configuration-fonts-colors-viewers.md#paleta-de-colores), [`footer`](https://postext.dev/es/docs/configuration-headers-footers.md#cabeceras-y-pies), [`header`](https://postext.dev/es/docs/configuration-headers-footers.md#cabeceras-y-pies), [`headingStyles`](https://postext.dev/es/docs/configuration-styles.md#estilos-de-encabezado), [`headings`](https://postext.dev/es/docs/configuration-headings.md#encabezados), [`layout`](https://postext.dev/es/docs/configuration-page-layout.md#disposición), [`locale`](https://postext.dev/es/docs/configuration-language.md#separación-silábica), [`page`](https://postext.dev/es/docs/configuration-page-layout.md#página), [`paragraphStyles`](https://postext.dev/es/docs/configuration-styles.md#estilos-de-párrafo), [`resourceTypes`](https://postext.dev/es/docs/configuration-resources.md#tipos-de-recurso), [`tableStyle`](https://postext.dev/es/docs/configuration-resources.md#estilo-de-tablas)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/es/docs/configuration-programmatic-usage.md#cargar-las-fuentes-antes-de-componer), [`decompressWoff2`](https://postext.dev/es/docs/configuration-pdf-output.md#proveedor-de-fuentes-en-el-navegador-fontsource--woff2), [`registerResourceImage`](https://postext.dev/es/docs/architecture.md#api-pública), [`renderPageToCanvas`](https://postext.dev/es/docs/configuration-programmatic-usage.md#renderizar-una-página-como-mapa-de-bits), [`renderToPdf`](https://postext.dev/es/docs/configuration-pdf-output.md#generación-de-pdf)

**Tipografías**

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

## Elaboración

### 1 · Tres columnas de griego

El código es [la respuesta corta](https://postext.dev/es/cookbook/greek-daily-front-page.md#la-respuesta-corta) de arriba. `layoutType: 'multiple'` con `columnCount: 3` monta tres columnas con un filete fino entre ellas ([maquetación de página](https://postext.dev/es/docs/configuration-page-layout.md)). `locale: 'el'` las parte con los patrones monotónicos, algo que cuenta en una columna de 69 mm donde una palabra griega ocupa a menudo un tercio de la línea. Espacios de 0,8 a 1,6 veces el normal y hasta 14 ‰ de tracking dejan una sola línea de la página por encima de 1,6.

### 2 · Un titular en versales, escrito en minúscula

El titular se escribe «Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια» y su estilo fija `textTransform: 'uppercase'`. En un documento griego las mayúsculas pierden el tonos, así que la página imprime ΑΝΑΒΕΙ ΞΑΝΑ y ΥΣΤΕΡΑ, como se escriben los titulares griegos. El antetítulo, las orejas y el título de los breves llevan la misma transformación.

```js
// script.js, líneas 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 y su entradilla van en una caja `banner` con `span: 'page'` y sin marco ([cajas](https://postext.dev/es/docs/configuration-callouts.md)): las columnas de debajo empiezan a la misma altura, y la segunda noticia repite el recurso.

### 3 · La capitular y su entrada

El estilo de párrafo `lede` da al primer párrafo de su grupo una capitular de tres líneas en GFS Didot, y `leadIn` pone las cuatro palabras siguientes en mayúsculas: ΜΕ ΜΙΑ ΓΙΟΡΤΗ ΠΟΥ. También pierden los acentos ([capitulares](https://postext.dev/es/docs/configuration-text.md)). La noticia abre con Μ; en una que abra con mayúscula acentuada (Έ, Ό), mira la capitular en la página, porque los libros griegos componen sus iniciales sin acento.

### 4 · La cabecera

```js
// script.js, líneas 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ítulo del diario, «Ο Φάρος» en el frontmatter, se compone en versales Didot espaciadas: ΦΑΡΟΣ. Las orejas leen los atributos del encabezado, `issue`, `city` y `price`, y el `publishDate` del frontmatter.

## La receta completa

Un solo archivo, compuesto a partir de la carpeta de la receta con el texto de ejemplo y el kit común del Recetario ya incluidos; construye su propia página. Para ejecutarlo, ponlo en un `<script type="module">` de una página vacía o pégalo en el panel JS de un pen nuevo de CodePen (como módulo). Importa postext desde esm.sh, así que no hay nada que instalar ni compilar.

- Carpeta de la receta: 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 ───────────────────────────────────────────────────────────────────────
```

## Errores frecuentes

- Una caja que pide capitular se compone sin ella: el primer párrafo de una noticia debe estar en el flujo, después de la caja, no dentro.
- Los breves son una caja con `placement="bottom"`: si la página se pasa una línea, toda la franja salta a la página siguiente. Recorta texto hasta que quepa.
- Las orejas miden 52 mm. Una línea de número más larga se parte, y su segunda línea corre bajo la primera letra de la cabecera; mide las orejas con el hueco que deja el nombre.

## Créditos

- Receta: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Tipografías: GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)
- Código: MIT · Contenido de ejemplo: CC-BY-4.0

## Relacionadas

- [N.º 108 · Una página de periódico árabe a dos columnas](https://postext.dev/es/cookbook/arabic-newspaper-two-columns.md): Un diario árabe con locale 'ar': la primera columna es la derecha, los titulares ocupan las dos y los breves van en tres columnas de derecha a izquierda. · Nivel 2 (Intermedio) · Periódicos y boletines
- [N.º 201 · Una novela griega con partición monotónica](https://postext.dev/es/cookbook/monotonic-greek-novel.md): El primer capítulo de «Η τιμή και το χρήμα» de Theotokis en un libro de 13,5 × 20,5 cm: patrones del griego monotónico, comillas «» y versales sin tilde. · Nivel 2 (Intermedio) · Narrativa, teatro y prosa literaria
- [N.º 203 · Un capítulo de un libro de matemáticas griego](https://postext.dev/es/cookbook/greek-maths-textbook.md): Tres páginas sobre el teorema de Pitágoras para alumnos griegos: secciones 3.1 a 3.3 en versales sin tonos, rótulos Εικόνα y Πίνακας y fórmulas de MathJax. · Nivel 3 (Avanzado) · Libros de texto
