Vai al contenuto principale
Ricetta numero 209

Ricettario · Capitolo 2 · Caratteri e testo

Dodici lingue cirilliche in un campionario

Un campionario di quattro pagine: un articolo in dodici lingue cirilliche, ognuna divisa con le sue regole e disegnata con le sue forme locali.

In questa pagina
Genere
Cataloghi
Output
Canvas · PDF
Livello
Intermedio
Postext
Provata con Postext 1.100.0
Richiede ≥ 1.100.0 · postext-pdf ≥ 1.100.0
Licenza
Aggiornata il 2 dic 2026
Codice MIT · Testo MIT
  • Esempio in inglese: non c’è ancora un’edizione italiana
  • Formato 205 × 260 mm
  • 1 colonna
  • Source Serif 4 10,5/14
  • Source Sans 3
  • 4 pagine
  • Livello
  • Postext 1.100.0
  • Impaginato in 104 ms
  • 153 righe di codice

In breve

Il foglio di campioni di una fonderia con lo stesso articolo in dodici lingue scritte in cirillico, dal russo al mongolo. Ogni brano va a capo secondo la sua lingua; bulgaro, serbo e macedone mostrano le lettere che disegnano in altro modo.

Che cosa comporrai

Un campionario di 205 × 260 mm in quattro pagine. La copertina è un muro di dodici piastrelle, ciascuna con una lettera propria di un alfabeto. Due pagine affiancate raccolgono dodici schede, sei lingue slave a sinistra e kazako, kirghiso, tataro, baschiro, tagico e mongolo a destra: il nome, le lettere particolari in vermiglio, l’articolo 1 della Dichiarazione universale dei diritti umani in colonne giustificate, un verso di un autore della lingua e l’alfabeto. L’ultima pagina mostra le forme locali in corpo grande e la parola «biblioteca» divisa in tutte e dodici.

Questa ricetta risponde a

  • Come compongo più lingue cirilliche in un documento, ognuna con la sua sillabazione e le sue forme?
  • Come ottengo una buona giustificazione e sillabazione per testi in spagnolo, francese o tedesco?

La risposta breve

script.js · righe 40–62nel codice completo
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
//   :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
  fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
  boldColor: col('ink'), italicColor: col('ink'), referenceColor: col('ink'),
  textAlign: 'justify', firstLineIndent: pt(0),
  // 54 mm hold about 32 letters: words are divided at two letters, the spaces give from
  // 0.75 to 1.8 of the face's own, and a line takes up to 20 ‰ of tracking.
  hyphenation: { leftMin: 2, rightMin: 2 }, minWordSpacing: 0.75, maxWordSpacing: 1.8,
  maxJustifyTracking: 20, shapingLanguage: 'document', // the default: locale, then lang
};
const passages = [ // config().paragraphStyles
  { id: 'article', firstLineIndent: pt(0), marginBottom: pt(LEAD / 2) },
  { id: 'line', fontSize: pt(11.2), lineHeight: pt(LEAD), textAlign: 'left',
    italicColor: col('red'), hyphenation: { enabled: false }, marginBottom: pt(LEAD / 2) },
  { id: 'abc', ...face(SANS, 8.4, 400, 'muted'), lineHeight: pt(11.4), textAlign: 'left',
    hyphenation: { enabled: false } },
];

Ingredienti

Tipo
Source Serif 4, Source Sans 3 (SIL OFL 1.1)
Risorse
Nessuna: ogni immagine è disegnata nel codice

Preparazione

#1 · Nominare due volte la lingua di ogni brano

Il codice è la risposta breve qui sopra. lang su un blocco :::paragraphs dichiara la lingua del suo testo: sceglie i modelli che ne dividono le parole, e il testo è misurato, disegnato e incorporato con le forme che il carattere riserva a quella lingua, e marcato come tale nel PDF e nell’HTML. Un tratto dentro una riga prende un isolato, :ltr[…]{lang=bg}. Le colonne sono di 54 mm: si divide dopo due lettere e una riga accetta fino al 20 ‰ di spaziatura.

#2 · Un titolo, quattro dati

script.js · righe 66–80nel codice completo
// ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}
const entry = { level: 2, fontFamily: SERIF, fontSize: pt(21), lineHeight: pt(26), fontWeight: 900,
  marginTop: pt(0), marginBottom: pt(LEAD / 4),
  advancedDesign: { enabled: true, minHeight: mm(25.4), slot: { elements: [
    { kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(2.5), color: col('ink'),
      placement: { ...at('container', 'top-left'), size: { width: 'fill' } } },
    text('code', '{attr.code}', face(SANS, 8, 700, 'red', { textTransform: 'uppercase',
      letterSpacing: pt(1.2) }), at('container', 'top-left', 0, 2.6)),
    text('count', '{attr.letters}', face(SANS, 8, 400, 'muted', { align: 'right' }),
      at('container', 'top-right', 0, 2.6)),
    text('name', '{titleText}', face(SERIF, 22, 900, 'ink', { lineHeight: 1.1 }),
      at('container', 'top-left', 0, 6.6)),
    text('special', '{attr.special}', face(SERIF, 17, 700, 'red', { lineHeight: 1.2 }),
      at('container', 'top-left', 0, 18)),
  ] } } };

Il codice, il numero di lettere e le lettere che il russo non ha viaggiano nel titolo: ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}. Il disegno li stampa sotto un filetto pesante, e minHeight dà a tutte le schede la stessa testa, così i testi di una fila cominciano sulla stessa riga.

#3 · Un muro di lettere

script.js · righe 94–113nel codice completo
const [TILE_W, TILE_H] = [TRIM_W / 3, 52]; // mm
const INKS = ['red', 'ink', 'ochre', 'pine', 'cream', 'red', 'ink', 'ochre', 'pine', 'red', 'ink',
  'cream']; // ink of each tile, row by row
const tile = (ink, i) => {
  const place = { ...at('page', 'top-left', (i % 3) * TILE_W, Math.floor(i / 3) * TILE_H),
    size: { width: mm(TILE_W), height: mm(TILE_H) } };
  const letter = ink === 'cream' ? 'red' : ink === 'ochre' ? 'ink' : 'cream';
  return [{ kind: 'box', id: `tile-${i}`, style: { backgroundColor: col(ink) }, placement: place },
    text(`letter-${i}`, `{attr.l${i + 1}}`, face(SERIF, 108, 900, letter, { align: 'center',
      verticalAlign: 'center', lineHeight: 1 }), place)];
};
const cover = { id: 'cover', breakBefore: { enabled: true, parity: 'any' },
  header: { elements: [] }, footer: { elements: [] },
  advancedDesign: { enabled: true, minHeight: mm(200), slot: { elements: [
    ...INKS.flatMap(tile),
    text('title', '{titleText}', face(SERIF, 40, 900, 'ink', { lineHeight: 1.05, align: 'left' }),
      { ...at('page', 'top-left', SIDE, 4 * TILE_H + 10), size: { width: mm(TRIM_W - 2 * SIDE) } }),
    text('subtitle', '{subtitle}', face(SANS, 13, 400, 'muted', { lineHeight: 1.3, align: 'left' }),
      { ...at('#title', 'below', 0, 2), size: { width: 'fill' } }),
  ] } } };

Le dodici lettere della copertina sono gli attributi da l1 a l12 del suo titolo, e il disegno costruisce un riquadro e un testo per ciascuna da un elenco di inchiostri. Cambiare una lettera significa cambiare il Markdown. Le piastrelle partono dall’angolo della pagina e arrivano al taglio.

#4 · Forme locali, riga per riga

script.js · righe 117–127nel codice completo
const tabs = (...at) => at.map((x) => ({ position: mm(x), align: 'start' }));
const formsStyles = [ // config().paragraphStyles
  { id: 'forms', fontSize: pt(29), lineHeight: pt(3 * LEAD), textAlign: 'left',
    tabStops: tabs(26, 78), hyphenation: { enabled: false } },
  { id: 'weights', fontSize: pt(15.5), lineHeight: pt(2 * LEAD), textAlign: 'left',
    hyphenation: { enabled: false } },
  { id: 'cuts', fontSize: pt(12), lineHeight: pt(1.5 * LEAD), textAlign: 'left', tabStops: tabs(22),
    hyphenation: { enabled: false } },
  { id: 'colophon', ...face(SANS, 7.8, 400, 'muted'), lineHeight: pt(11), textAlign: 'left',
    marginTop: pt(3 * LEAD), hyphenation: { locale: LANG, enabled: false } },
];

La stessa stringa passa per il carattere in russo e poi in bulgaro; in corsivo, in russo, serbo e macedone. Source Serif 4 ha tutti e tre gli insiemi. Le tabulazioni allineano le righe, ciascuna un isolato nella sua lingua. Enfasi e forme locali elenca le lettere che cambiano.

La ricetta completa

Sandbox
// ═══ Postext Cookbook · Nº 209 · Twelve Cyrillic languages in one type specimen ═══════
// https://postext.dev/en/cookbook/cyrillic-specimen-twelve-languages
// Code: MIT · Text: UDHR, article 1 (UN, PD) and lines by twelve authors (PD) · Pictures: none
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.100.0
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the colophon ('en' | 'es' | 'ru')
const RECIPE = 'cyrillic-specimen-twelve-languages';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// The sheet of a type foundry between the wars: black, vermilion and two dull inks on cream.
const palette = {
  ink: '#1d1b1a', // text, heavy rules, the dark tiles
  red: '#b8321e', // the letters Russian lacks, the plates' titles, red tiles
  pine: '#1f4b4a', // green tiles
  ochre: '#d59b3a', // ochre tiles
  cream: '#f6efdf', // the paper and the letters on the tiles
  muted: '#655d51', // alphabets, author names, the colophon
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.red })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
const [SERIF, SANS] = ['Source Serif 4', 'Source Sans 3']; // both draw local forms by language
const [BODY, LEAD] = [10.5, 14]; // pt
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 });
const face = (fontFamily, size, fontWeight, color, extra = {}) => ({ fontFamily,
  fontSize: pt(size), fontWeight, color: col(color), ...extra });

// #region page: 84 × 108/16, 205 × 260 mm trimmed, three columns to a plate
const [TRIM_W, SIDE] = [205, 15]; // mm
const page = { sizePreset: '84x108/16', dpi: 150, backgroundColor: col('cream'),
  margins: { top: mm(18), bottom: mm(17), left: mm(SIDE), right: mm(SIDE), mirror: true } };
const COLUMN_GAP = 6; // mm
// #endregion

// #region answer: each passage named in its own language, for its breaks and its letters
// The document is Russian, so that is what divides and shapes anything left unnamed. A
// passage names its language on its container:
//   :::paragraphs{style="article" lang=bg}
// Its words are divided by Bulgarian patterns and kept together by Bulgarian rules; it is
// measured, painted and embedded with the Bulgarian forms (locl) the font holds, and tagged
// as Bulgarian in the HTML and the PDF. A run inside a line takes :ltr[…]{lang=bg}.
const LOCALE = 'ru';
const bodyText = { // config().bodyText
  fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),

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)

Errori frequenti

  • Il carattere deve avere le forme. PT Serif non ne ha per queste lingue; Vollkorn e Lora hanno quelle bulgare e serbe. Se mancano, l’isolato continua a dividere e marcare il testo, ma le lettere restano russe.
  • Deve avere anche le lettere. Ә, Ғ, Ң, Ҙ, Ҷ e Ӯ stanno nel file cyrillic-ext della famiglia, che kitCyrillicFonts carica; a Literata e Spectral ne mancano alcune.

Crediti

Testo
  • Article 1 of the Universal Declaration of Human Rights in eleven languages, from the plain texts of the UDHR in XML project, with four misprints of the Kazakh, Kyrgyz and Tatar files corrected · United Nations · pubblico dominio
  • Article 1 in Bashkir · United Nations · pubblico dominio
  • Opening lines and sayings of Pushkin, Shevchenko, Kupala, Vazov, Vuk Karadžić, Racin, Abai, Toktogul, Tukay, Akmulla, Rudaki and Natsagdorj · The authors named · pubblico dominio
  • The titles, the alphabets and the colophon · Postext Cookbook · originale
Font
Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
Sandbox