# La une d’un quotidien grec sur trois colonnes

> Une une en grec : titre du journal en Didot, manchette en capitales sans tonos, une lettrine de trois lignes avec attaque en capitales, brèves en pied.

- Version HTML: https://postext.dev/fr/cookbook/greek-daily-front-page
- Recette Nº 204 · Page et grille · Niveau 2 (Intermédiaire) · Sorties: Canvas, PDF
- Genres: Journaux et lettres d’information
- Nécessite postext ≥ 1.99.1, postext-pdf ≥ 1.99.1 · testée avec 1.99.1, postext-pdf 1.99.1 le 2026-11-29
- Pages: [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
- Ouvrir dans le Sandbox: https://postext.dev/fr/sandbox#recipe=greek-daily-front-page&lang=en (.postext: https://postext.dev/cookbook/greek-daily-front-page/en/greek-daily-front-page.postext)
- Dernière mise à jour: 2026-11-29
- Autres langues: [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), [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 bref

La une d’un journal local grec imaginaire : le nom en haut, une grande manchette en capitales, l’article principal sur trois colonnes qui commence par une grande lettre, une carte, des horaires de bateaux et des brèves.

## Ce que vous allez composer

La une d’*Ο Φάρος* (« Le Phare »), un quotidien imaginaire d’une ville portuaire imaginaire, au format compact de 246 × 328 mm. Le titre du journal est en GFS Didot entre deux oreilles ; l’article principal court sous une manchette de deux lignes en capitales étroites et un chapô, puis sur trois colonnes de Noto Serif séparées de filets, à partir d’une lettrine de trois lignes. Une carte de la baie, large d’une colonne, occupe la colonne centrale. Un second article avec un tableau des départs de bateaux et une bande de brèves, sur trois colonnes à elle, ferment la page. Tout le texte est original et grec ; l’ours suit la langue de l’édition.

**Cette recette répond à:**

- Comment composer la une d’un quotidien grec avec une manchette en capitales et une lettrine ?
- Comment ajouter à une ouverture une ligne d’auteur, un chapeau ou une attaque avec lettrine ?
- Comment composer un titre de chapitre sur toute la largeur de la page, avec le texte en deux colonnes en dessous ?
- Comment obtenir une bonne justification et une bonne césure pour un texte en espagnol, en français ou en allemand ?

## La réponse courte

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

## Ingrédients

**Enseigne**

- [Lettrines dans les paragraphes](https://postext.dev/fr/docs/configuration-text.md#lettrines): dropCap sur un niveau de titre, un style de titre ou un style de paragraphe ouvre un paragraphe du texte courant avec sa première lettre composée en grand à côté de ses premières lignes, qui sont raccourcies et composées avec le texte ; une initiale montante, un guillemet ouvrant suspendu ou composé avec la lettre, une attaque en petites capitales.
- [Trois colonnes ou plus](https://postext.dev/fr/docs/configuration-page-layout.md#types-de-mise-en-page): layoutType 'multiple' découpe le texte courant en columnCount colonnes égales, de 3 à 8, pour les journaux et les magazines ; les filets, l’équilibrage, les notes de bas de page et les flottants sur toute la largeur fonctionnent sur toutes les colonnes.
- [Césure et langue du document](https://postext.dev/fr/docs/justification.md#langues-prises-en-charge): Une césure fondée sur les motifs TeX dans neuf langues, dont le grec, choisie par la locale du document, qui fixe aussi les mentions de suite des tableaux et la langue du PDF balisé.

**Utilise aussi**

- [Filet de colonne](https://postext.dev/fr/docs/configuration-page-layout.md#filet-entre-colonnes)
- [Encadrés sur toute la largeur](https://postext.dev/fr/docs/configuration-callouts.md#le-conteneur-callout)
- [Colonnes dans un encadré ou dans le texte](https://postext.dev/fr/docs/document-format-directives.md#columns)
- [Encadrés flottants](https://postext.dev/fr/docs/configuration-callouts.md#le-conteneur-callout)
- [Encadrés](https://postext.dev/fr/docs/configuration-callouts.md#styles-dencadré)
- [Styles de titre](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)
- [Attributs de titre](https://postext.dev/fr/docs/document-format.md#attributs-de-titre)
- [Ouvertures composées](https://postext.dev/fr/docs/configuration-headings.md#étendue-et-maquette-avancée)
- [Texte, filets et boîtes dans les maquettes de page](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page)
- [Types de ressource personnalisés](https://postext.dev/fr/docs/configuration-resources.md#types-de-ressources)
- [Tableaux à partir de données](https://postext.dev/fr/docs/document-format-resources.md#insertion-en-bloc-facultative-placement-explicite-dans-le-texte)
- [Style des légendes](https://postext.dev/fr/docs/configuration-resources.md#style-de-légende)
- [Styles de paragraphe](https://postext.dev/fr/docs/configuration-styles.md#styles-de-paragraphe)
- [Export PDF](https://postext.dev/fr/docs/configuration-pdf-output.md#générer-des-pdf)
- [Des figures exactement ici](https://postext.dev/fr/docs/document-format-resources.md#insertion-en-bloc-facultative-placement-explicite-dans-le-texte)
- [Bandeau de chapitre sur toute la largeur](https://postext.dev/fr/docs/configuration-headings.md#étendue-et-maquette-avancée)
- [Couleur du papier](https://postext.dev/fr/docs/configuration-page-layout.md#page)
- [Polices intégrées au PDF](https://postext.dev/fr/docs/configuration-pdf-output.md#pourquoi-un-fournisseur-de-polices)
- [Figures et tableaux comme ressources](https://postext.dev/fr/docs/document-format-resources.md#ressources)
- [Titres courants par section](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre)

**La configuration en un coup d’œil**

- [`bodyText`](https://postext.dev/fr/docs/configuration-text.md#texte-courant), [`calloutStyles`](https://postext.dev/fr/docs/configuration-callouts.md#styles-dencadré), [`captionStyle`](https://postext.dev/fr/docs/configuration-resources.md#style-de-légende), [`colorPalette`](https://postext.dev/fr/docs/configuration-fonts-colors-viewers.md#palette-de-couleurs), [`footer`](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page), [`header`](https://postext.dev/fr/docs/configuration-headers-footers.md#en-têtes-et-pieds-de-page), [`headingStyles`](https://postext.dev/fr/docs/configuration-styles.md#styles-de-titre), [`headings`](https://postext.dev/fr/docs/configuration-headings.md#titres), [`layout`](https://postext.dev/fr/docs/configuration-page-layout.md#mise-en-page), [`locale`](https://postext.dev/fr/docs/configuration-language.md#césure), [`page`](https://postext.dev/fr/docs/configuration-page-layout.md#page), [`paragraphStyles`](https://postext.dev/fr/docs/configuration-styles.md#styles-de-paragraphe), [`resourceTypes`](https://postext.dev/fr/docs/configuration-resources.md#types-de-ressources), [`tableStyle`](https://postext.dev/fr/docs/configuration-resources.md#style-de-tableau)

**API**

- [`buildDocumentWithFonts`](https://postext.dev/fr/docs/configuration-programmatic-usage.md#charger-les-polices-avant-la-mise-en-page), [`decompressWoff2`](https://postext.dev/fr/docs/configuration-pdf-output.md#fournisseur-de-polices-dans-le-navigateur-fontsource--woff2), [`registerResourceImage`](https://postext.dev/fr/docs/architecture.md#surface-de-lapi), [`renderPageToCanvas`](https://postext.dev/fr/docs/configuration-programmatic-usage.md#rendre-une-page-en-bitmap), [`renderToPdf`](https://postext.dev/fr/docs/configuration-pdf-output.md#générer-des-pdf)

**Caractères**

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

## Préparation

### 1 · Trois colonnes de grec

Le code est [la réponse courte](https://postext.dev/fr/cookbook/greek-daily-front-page.md#la-réponse-courte) ci-dessus. `layoutType: 'multiple'` avec `columnCount: 3` installe trois colonnes avec un filet fin entre elles ([mise en page](https://postext.dev/fr/docs/configuration-page-layout.md)). `locale: 'el'` les coupe selon les motifs monotoniques, ce qui compte dans une colonne de 69 mm où un mot grec prend souvent le tiers de la ligne. Des espaces de 0,8 à 1,6 fois la normale et jusqu’à 14 ‰ d’approche ne laissent qu’une ligne de la page au-delà de 1,6.

### 2 · Une manchette en capitales, écrite en minuscules

La manchette s’écrit « Ο φάρος του Αγίου Νικολάου ανάβει ξανά ύστερα από σαράντα χρόνια » et son style fixe `textTransform: 'uppercase'`. Dans un document grec, les capitales perdent le tonos ; la page imprime ΑΝΑΒΕΙ ΞΑΝΑ et ΥΣΤΕΡΑ, comme s’écrivent les manchettes grecques. Le surtitre, les oreilles et le titre des brèves prennent la même transformation.

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

La manchette et son chapô sont dans une boîte `banner` avec `span: 'page'` et sans cadre ([boîtes](https://postext.dev/fr/docs/configuration-callouts.md)) : les colonnes en dessous partent à la même hauteur, et le second article reprend le procédé.

### 3 · La lettrine et son attaque

Le style de paragraphe `lede` donne au premier paragraphe de son groupe une lettrine de trois lignes en GFS Didot, et `leadIn` met les quatre mots suivants en capitales : ΜΕ ΜΙΑ ΓΙΟΡΤΗ ΠΟΥ. Ils perdent aussi leurs accents ([lettrines](https://postext.dev/fr/docs/configuration-text.md)). L’article s’ouvre sur Μ ; pour un article qui s’ouvre sur une capitale accentuée (Έ, Ό), regardez la lettrine sur la page, car les livres grecs composent leurs initiales sans accent.

### 4 · Le titre du journal

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

Le titre du journal, « Ο Φάρος » dans le frontmatter, est composé en capitales Didot espacées : ΦΑΡΟΣ. Les oreilles lisent les attributs du titre, `issue`, `city` et `price`, et le `publishDate` du frontmatter.

## La recette complète

Un seul fichier, composé à partir du dossier de la recette avec le texte d’exemple et le kit commun des Recettes déjà inclus ; il construit sa propre page. Pour l’exécuter, placez-le dans un `<script type="module">` d’une page vide ou collez-le dans le panneau JS d’un nouveau pen CodePen (en tant que module). Il importe postext depuis esm.sh : il n’y a rien à installer ni à compiler.

- Dossier de la recette: 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 ───────────────────────────────────────────────────────────────────────
```

## Erreurs fréquentes

- Une boîte qui demande une lettrine est composée sans elle : le premier paragraphe d’un article doit être dans le flux, après la boîte, pas dedans.
- Les brèves sont une boîte avec `placement="bottom"` : si la page déborde d’une ligne, toute la bande passe à la page suivante. Coupez du texte jusqu’à ce qu’elle tienne.
- Les oreilles font 52 mm. Une ligne de numéro plus longue passe à la ligne, et sa seconde ligne court sous la première lettre du titre ; mesurez les oreilles à l’espace que laisse le nom.

## Crédits

- Recette: Ignacio Ferro ([@drnachio](https://github.com/drnachio))
- Caractères: GFS Didot (OFL-1.1), Fira Sans Condensed (OFL-1.1), Noto Serif (OFL-1.1)
- Code: MIT · Contenu d’exemple: CC-BY-4.0

## Recettes liées

- [Nº 108 · Une page de journal arabe sur deux colonnes](https://postext.dev/fr/cookbook/arabic-newspaper-two-columns.md): Un quotidien arabe en langue 'ar' : la première colonne est à droite, les titres couvrent les deux, les brèves vont sur trois colonnes de droite à gauche. · Niveau 2 (Intermédiaire) · Journaux et lettres d’information
- [Nº 201 · Un roman grec coupé selon le grec monotonique](https://postext.dev/fr/cookbook/monotonic-greek-novel.md): Le premier chapitre de « Η τιμή και το χρήμα » de Theotokis en livre de 13,5 × 20,5 cm : motifs du grec monotonique, guillemets «» et capitales sans accent. · Niveau 2 (Intermédiaire) · Fiction, théâtre et prose littéraire
- [Nº 203 · Un chapitre de manuel de mathématiques grec](https://postext.dev/fr/cookbook/greek-maths-textbook.md): Trois pages sur le théorème de Pythagore pour des élèves grecs : sections 3.1 à 3.3 en capitales sans tonos, étiquettes Εικόνα et Πίνακας, formules MathJax. · Niveau 3 (Avancé) · Manuels scolaires
