Pular para o conteúdo principal
Receita número 209

Receitas · Capítulo 2 · Tipo e texto

Doze idiomas cirílicos em um mostruário tipográfico

Um mostruário de quatro páginas: um artigo em doze idiomas cirílicos, cada um dividido por suas regras e com suas formas locais.

Nesta página
Gênero
Catálogos
Saída
Canvas · PDF
Postext
Testada com o Postext 1.100.0
Requer ≥ 1.100.0 · postext-pdf ≥ 1.100.0
Licença
Atualizada em 2 de dez. de 2026
Código MIT · Texto MIT
  • Amostra em inglês: ainda sem edição em português
  • Refile 205 × 260 mm
  • 1 coluna
  • Source Serif 4 10,5/14
  • Source Sans 3
  • 4 páginas
  • Nível
  • Postext 1.100.0
  • Diagramado em 104 ms
  • 153 linhas de código

Em poucas palavras

A folha de amostras de uma fundição com o mesmo artigo em doze idiomas escritos em cirílico, do russo ao mongol. Cada trecho divide as palavras segundo o seu idioma; búlgaro, sérvio e macedônio mostram as letras que desenham de outro jeito.

O que você vai compor

Um mostruário de 205 × 260 mm em quatro páginas. A capa é um muro de doze ladrilhos, cada um com uma letra própria de um alfabeto. Duas páginas lado a lado reúnem doze fichas, seis idiomas eslavos à esquerda e cazaque, quirguiz, tártaro, basquir, tadjique e mongol à direita: o nome, as letras especiais em vermelhão, o artigo 1 da Declaração Universal dos Direitos Humanos em colunas justificadas, um verso de um autor do idioma e o alfabeto. A última página mostra as formas locais em corpo grande e a palavra “biblioteca” dividida nos doze.

Esta receita responde a

  • Como componho vários idiomas cirílicos num documento, cada um com sua hifenização e suas formas?
  • Como consigo boa justificação e hifenização em textos em espanhol, francês ou alemão?

A resposta curta

script.js · linhas 40–62no código 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 } },
];

Ingredientes

Tipografia
Source Serif 4, Source Sans 3 (SIL OFL 1.1)
Materiais
Nenhum: todas as imagens são desenhadas em código

Preparo

#1 · Nomear duas vezes o idioma de cada trecho

O código é a resposta curta acima. lang em um bloco :::paragraphs declara o idioma do seu texto: escolhe os padrões que dividem suas palavras, e o texto é medido, pintado e incorporado com as formas que a fonte guarda para esse idioma, e fica marcado com ele no PDF e no HTML. Um trecho dentro de uma linha usa um isolado, :ltr[…]{lang=bg}. As colunas têm 54 mm: divide-se a partir de duas letras e uma linha aceita até 20 ‰ de espacejamento.

#2 · Um título, quatro dados

script.js · linhas 66–80no código 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)),
  ] } } };

O código, o número de letras e as letras que o russo não tem viajam no título: ## Українська {code="uk" letters="33 буквы" special="Ґ Є І Ї"}. O desenho os imprime sob um fio grosso, e minHeight dá a todas as fichas a mesma cabeça, de modo que os textos de uma fileira começam na mesma linha.

#3 · Um muro de letras

script.js · linhas 94–113no código 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' } }),
  ] } } };

As doze letras da capa são os atributos l1 a l12 do seu título, e o desenho monta uma caixa e um texto para cada uma a partir de uma lista de tintas. Trocar uma letra é trocar o Markdown. Os ladrilhos partem do canto da página e chegam ao corte.

#4 · Formas locais, linha a linha

script.js · linhas 117–127no código 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 } },
];

A mesma sequência passa pela fonte em russo e depois em búlgaro; em itálico, em russo, sérvio e macedônio. Source Serif 4 tem os três conjuntos. Tabulações alinham as linhas, e cada uma é um isolado em seu idioma. Ênfase e formas locais lista as letras que mudam.

A receita 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'),

O script.js montado funciona como está: cole-o como script de módulo em qualquer página ou abra a receita no CodePen. Pasta da receita no GitHub ↗ (abre em uma nova aba)

Erros comuns

  • A fonte precisa ter as formas. PT Serif não tem nenhuma para esses idiomas; Vollkorn e Lora têm as búlgaras e as sérvias. Sem elas, o isolado ainda divide e marca o texto, mas as letras continuam russas.
  • Também precisa ter as letras. Ә, Ғ, Ң, Ҙ, Ҷ e Ӯ estão no arquivo cyrillic-ext da família, que kitCyrillicFonts carrega; faltam algumas em Literata e Spectral.

Créditos

Texto
  • 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 · domínio público
  • Article 1 in Bashkir · United Nations · domínio público
  • Opening lines and sayings of Pushkin, Shevchenko, Kupala, Vazov, Vuk Karadžić, Racin, Abai, Toktogul, Tukay, Akmulla, Rudaki and Natsagdorj · The authors named · domínio público
  • The titles, the alphabets and the colophon · Postext Cookbook · original
Fontes
Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
Sandbox