In breve
Una poesia araba classica stampata come la stampano i vecchi libri di poesia: ogni verso diviso in due metà affiancate, entrambe allungate alla stessa larghezza perché le loro estremità si allineino lungo la pagina.
Che cosa comporrai
Quattro pagine di un dīwān, le poesie raccolte di al-Mutanabbī, come le componevano un secolo fa i tipografi del Cairo: un occhiello con ديوان in Ruqʿa rossa, poi la qaṣīda che recitò davanti a Sayf al-Dawla nel 954, sotto una testata filettata di rosso. Ognuno dei quarantasei bayt è un verso di due emistichi, lo ṣadr a destra e lo ʿajuz a sinistra, entrambi allungati con le kashida fino a una sola larghezza, così le rime in ‑mu scendono lungo il bordo sinistro in linea retta. Il libro è rilegato a destra e i numeri di pagina sono in cifre indo-arabe. Solo la nota sul testo, alla fine, cambia con l’edizione. Le poesie Tang di fronte ai versi inglesi compone la poesia cinese classica sulla sua griglia.
Questa ricetta risponde a
- Come compongo versi arabi classici con ogni verso in due emistichi?
La risposta breve
// In the Markdown, a :::verse block takes one bayt a line, the ṣadr and the ʿajuz parted
// by ||:
// :::verse{style="bayt"}
// عَلى قَدْرِ أهْلِ العَزْم تأتي العَزائِمُ || وَتأتي علَى قَدْرِ الكِرامِ المَكارمُ
// :::
// The ṣadr goes on the right, the ʿajuz on the left, both stretched to the width of the
// widest half with a gap of 2 em between them. The style gives the poem its face and a
// leading deep enough for the harakat: 1.9 × the size.
const bayt = { id: 'bayt', fontFamily: NASKH, fontSize: pt(14), lineHeight: pt(26.6),
color: col('ink'), marginTop: pt(LEAD / 2), marginBottom: pt(LEAD) };
// Justified lines lengthen their words with kashidas (tatweel) before they open the
// spaces wide: 'auto' is the default in an Arabic document, written out here to say so.
// A hemistich may stretch a word twice as far as a line of prose does: 1.2 em.
const bodyKashida = { kashida: 'auto', kashidaPatterns: 'naskh', kashidaMaxLength: 0.6 };
Ingredienti
- Funzionalità
- Versi arabi (bayt in due emistichi)Giustificazione con la kashidaTesto da destra a sinistraFont arabiL’arabo come lingua del documentoLibri rilegati a destraCifre dei numeri generatiAperture progettateAttributi dei titoliStili di titoloCopertine, frontespizi e colophonTestatine e folioTestatine secondo il ruolo della paginaColore della cartaStili di paragrafoParagrafi nell’altra direzioneTavolozza di colori semanticaEsportazione in PDFFont incorporati nel PDF
- Usa anche
- Testatine per sezione
- Tipo
- Amiri, Aref Ruqaa, Noto Kufi Arabic (SIL OFL 1.1)
- Risorse
- Nessuna: ogni immagine è disegnata nel codice
Preparazione
#1 · Un bayt per riga, le due metà a una sola larghezza
Il codice è nella risposta breve qui sopra. In :::verse ogni riga è un bayt, e || separa i due emistichi, così il Markdown si legge come il testo di Wikisource da cui proviene (:::verse). La poesia misura ogni emistichio, prende la metà più larga come larghezza di entrambe le colonne (fino a metà della giustezza meno lo spazio intermedio) e riempie ogni metà fino a quella larghezza, prima con le kashida e poi con gli spazi tra le parole (Poesia classica). Lo stile bayt è composto a 14 pt con un passo di 26,6 pt, 1,9 × il corpo, così le shadda e le kasra di righe vicine non si toccano (Segni vocalici). Il formato è 17 × 24 cm: a 14 × 21 cm un terzo dei bayt non stava nella sua metà della giustezza di 104 mm e ripiegava su una disposizione sfalsata, ṣadr e ʿajuz su righe proprie.

#2 · Una fascia di testata in Ruqʿa
const rule = (id, y, thickness) => ({ kind: 'rule', id, direction: 'horizontal',
thickness: pt(thickness), color: col('rubric'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(y) },
size: { width: 'fill' } } });
const opener = {
enabled: true, minHeight: mm(46),
slot: { elements: [
{ kind: 'box', id: 'band', reserve: false, style: { backgroundColor: col('tint') },
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(4) },
size: { width: 'fill', height: mm(26) } } },
rule('band-top', 4, 1.5), rule('band-foot', 30, 0.5),
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: RUQAA, fontWeight: 700,
fontSize: pt(34), lineHeight: 1.1, align: 'center', color: col('rubric'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(7.5) } } },
{ kind: 'text', id: 'metre', content: '{attr.metre}', fontFamily: KUFI, fontWeight: 500,
fontSize: pt(9), align: 'center', color: col('muted'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(35) } } },
] },
};
Il titolo di livello 1 si disegna con la sua grafica: un riquadro colorato filettato di rosso sopra e sotto, il titolo centrato su di esso in Aref Ruqaa, e sotto il metro da un attributo del titolo, {metre="من البحر الطويل"}. I caratteri da titolo in Ruqʿa non prendono kashida, quindi il titolo mantiene la sua larghezza naturale (Giustificazione e kashida).
#3 · Testatine sui lati del foglio
// Running heads stay on the sheet's sides: in a book bound on the right the verso (even)
// is the right-hand page, so its outer edge, where the folio goes, is the right one.
const head = (id, content, parity, edge, x, extra = {}) => ({ kind: 'text', id, content,
parity, pages: 'body', fontFamily: KUFI, fontWeight: 500, fontSize: pt(8.5),
color: col('muted'), placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(12) } },
...extra });
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-right', -OUTER, { color: col('ink') }),
head('verso-book', '{title}', 'even', 'top-right', -(OUTER + 10)),
head('recto-rhyme', '{subtitle}', 'odd', 'top-left', OUTER + 10),
head('recto-folio', '{pageNumber}', 'odd', 'top-left', OUTER, { color: col('ink') }),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'bottom', 0, {
pages: 'opener', color: col('ink'),
placement: { anchor: { to: 'page', edge: 'bottom' }, offset: { y: mm(-12) } } })] };
Il testo corre da destra a sinistra, e in esso sinistra e destra significano inizio e fine. Le testatine restano fisiche. In un libro rilegato a destra il verso, una pagina pari, sta a destra nella doppia pagina, quindi il suo numero di pagina va in alto a destra e quello del recto in alto a sinistra: entrambi stanno sul margine esterno (Ordine delle pagine e rilegatura a destra). Il solo tag locale: 'ar' imposta la direzione, la rilegatura e le cifre indo-arabe.
#4 · Un occhiello senza nulla nel flusso
const at = (y) => ({ anchor: { to: 'page', edge: 'top' }, offset: { y: mm(y) } });
const line = (id, content, y, style) => ({ kind: 'text', id, content, align: 'center',
overflow: 'wrap', color: col('ink'), placement: at(y), ...style });
const titlePage = {
id: 'title', span: 'page', runningChapter: false,
breakBefore: { enabled: true, parity: 'any' },
header: { elements: [] }, footer: { elements: [] },
advancedDesign: { enabled: true, slot: { elements: [
line('diwan', 'ديوان', 52, { fontFamily: RUQAA, fontWeight: 700, fontSize: pt(64),
lineHeight: 1.2, color: col('rubric') }),
line('poet', '{titleText}', 84, { fontFamily: NASKH, fontWeight: 700, fontSize: pt(20) }),
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.75),
color: col('rubric'), placement: { anchor: { to: 'page', edge: 'top' },
offset: { y: mm(100) }, size: { width: mm(24) } } },
line('rhyme', '{attr.rhyme}', 106, { fontFamily: KUFI, fontWeight: 500, fontSize: pt(11),
color: col('rubric') }),
line('latin', '{attr.latin}', 150, { fontFamily: NASKH, fontSize: pt(9.5),
color: col('muted'), italic: true }),
] } },
};
L’occhiello è uno stile di titolo con span: 'page' e intestazione e piè di pagina propri, vuoti. Il testo del titolo è il nome del poeta, quindi la parola ديوان è testo della grafica, composto a 64 pt sopra di esso, e la riga latina sotto la rima viene dall’attributo latin, che ogni edizione scrive nella propria lingua.
La ricetta completa
// ═══ Postext Cookbook · Nº 110 · A qasida on a diwan page, in two hemistichs ═══════════
// https://postext.dev/en/cookbook/qasida-diwan-page
// Code: MIT · Text: al-Mutanabbī, Dīwān, ar.wikisource (PD) · Pictures: none
// Fonts: Amiri, Aref Ruqaa, Noto Kufi Arabic (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import { buildDocument, withLoadedFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'qasida-diwan-page';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// Black text and red rubrics on a warm paper, as a Cairo diwan of the 1900s prints them.
const palette = {
ink: '#1f1a16', // text: a warm near-black
rubric: '#9a2b1f', // the accent: titles, the metre, the headpiece rules
tint: '#f1e6cf', // the headpiece band
rule: '#b8a27c', // hairlines
muted: '#6b6156', // running heads and the note on the text
paper: '#fbf7ee', // a cream paper
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'rubric (defaults)', value: { hex: palette.rubric, model: 'hex' } },
];
const NASKH = 'Amiri'; // the text: a Bulaq Naskh
const RUQAA = 'Aref Ruqaa'; // display: the titles
const KUFI = 'Noto Kufi Arabic'; // labels: metre, running heads, folios
const [SIZE, LEAD] = [13, 21]; // pt: the prose, at 1.6 × for a lightly vocalised headnote
const [OUTER, TOP] = [18, 23]; // mm: a 17 × 24 cm diwan
// #region answer: one bayt a line, both hemistichs stretched to one width
// In the Markdown, a :::verse block takes one bayt a line, the ṣadr and the ʿajuz parted
// by ||:
// :::verse{style="bayt"}
// عَلى قَدْرِ أهْلِ العَزْم تأتي العَزائِمُ || وَتأتي علَى قَدْرِ الكِرامِ المَكارمُ
// :::
// The ṣadr goes on the right, the ʿajuz on the left, both stretched to the width of the
// widest half with a gap of 2 em between them. The style gives the poem its face and a
// leading deep enough for the harakat: 1.9 × the size.
const bayt = { id: 'bayt', fontFamily: NASKH, fontSize: pt(14), lineHeight: pt(26.6),
color: col('ink'), marginTop: pt(LEAD / 2), marginBottom: pt(LEAD) };
// Justified lines lengthen their words with kashidas (tatweel) before they open the
// spaces wide: 'auto' is the default in an Arabic document, written out here to say so.
// A hemistich may stretch a word twice as far as a line of prose does: 1.2 em.
const bodyKashida = { kashida: 'auto', kashidaPatterns: 'naskh', kashidaMaxLength: 0.6 };
// #endregion
Lo script.js composto funziona così com’è: incollalo nello script modulo di qualsiasi pagina, oppure apri la ricetta su CodePen. Cartella della ricetta su GitHub ↗ (si apre in una nuova scheda)
Varianti
#Segna lo spazio con un ornamento
Alcuni dīwān stampano una piccola stella tra gli emistichi. ornament mette un segno al centro dello spazio senza aggiungerlo al testo.
-:::verse{style="bayt"}
+:::verse{style="bayt" ornament="٭"}#Dai a ogni emistichio la stessa larghezza
Una width fissa porta entrambe le colonne a una sola giustezza su ogni pagina del dīwān, qualunque sia la metà più larga di una data poesia.
-:::verse{style="bayt"}
+:::verse{style="bayt" width=58mm}Errori frequenti
Errore frequente
Assegna a un libro arabo il tag 'ar', non LANG
Le edizioni di una ricetta sono en ed es, ma un esempio arabo è arabo in entrambe: `locale: LANG` lo comporrebbe da sinistra a destra, lo rilegherebbe a sinistra, numererebbe le pagine 1 2 3 e darebbe alle figure didascalie Figure o Figura. Da postext 1.30 il tag è anche la lingua usata per lo shaping del testo (misura, disegno e incorporamento), quindi con un tag inglese o spagnolo un carattere come Markazi Text non disegna le forme arabe delle sue virgolette basse e dei suoi segni di interpunzione, e le righe vanno a capo altrove. Scrivi tu il tag: 'ar' (cifre arabo-indiane, la convenzione del Mashriq), una regione come 'ar-EG' o 'ar-SA', oppure 'ar-MA', 'ar-DZ' o 'ar-TN' per un’edizione del Maghreb con cifre europee. Una pagina latina che si limita a citare l’arabo mantiene la propria lingua. Testo da destra a sinistra →
Errore frequente
I caratteri arabi hanno bisogno del loro file arabic, tramite il blocco arabic
Fontsource serve Amiri, Noto Naskh Arabic o Scheherazade New come un file per sottoinsieme, e le lettere arabe stanno nel file arabic. loadFonts scarica solo latin (e latin-ext), così a schermo l’arabo viene da un font di sistema ed è misurato male, e fontsourceProvider passa al PDF quel file latin, che stampa riquadri vuoti. Elenca il blocco arabic del kit, chiama loadArabicFonts(FONTS, markdown) dopo loadFonts, con ogni peso che le pagine compongono in arabo elencato in FONTS, e passa a renderToPdf fontProvider: arabicPdfProvider. Font arabi →
Crediti
- Ricetta
- Ignacio Ferro
- Testo
- The qasida ʿAlā qadri ahli l-ʿazmi taʾtī l-ʿazāʾimu, as ar.wikisource gives it (revision 447620), with its vowels · al-Mutanabbī · pubblico dominio
- The headnote in Arabic, the note on the text and the colophon · Postext Cookbook · originale
- Font
- Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1)
- Codice
- MIT, come Postext
Modifica questo testo ↗ (si apre in una nuova scheda)Cartella della ricetta su GitHub ↗ (si apre in una nuova scheda)


