Em poucas palavras
Os primeiros versos da Odisseia de Homero em grego antigo, com todos os acentos e espíritos, nas páginas da esquerda, e uma tradução em verso para o grego moderno à direita, cada verso na altura do que traduz.
O que você vai compor
Um pequeno clássico de 14 × 21,5 cm em GFS Didot, a fonte politônica da Greek Font Society. Abre com uma página da Vida de Homero bizantina que a Suda dá sob o nome de Hesíquio de Mileto, com o epitáfio de Homero em Íos. Seguem duas aberturas: os versos 1 a 27 do primeiro canto da Odisseia nas pares e a versão em versos de quinze sílabas de Argyris Eftaliotis nas ímpares, verso a verso, numerados de cinco em cinco na margem externa. Os três textos são de domínio público e vêm da Wikisource grega. Cabeços e aberturas põem os títulos em versais, que perdem todo espírito e acento.
Esta receita responde a
- Como componho um poema e sua tradução em páginas opostas, com o original sempre na página ímpar?
- Como numero na margem cada quinto verso de um poema e remeto minhas notas a esses números de verso?
- Como componho poesia: um verso por linha, espaço entre estrofes, recuo deslocado nos versos que quebram e sem hifenização?
- Como consigo boa justificação e hifenização em textos em espanhol, francês ou alemão?
A resposta curta
// locale 'grc' takes the polytonic patterns, which read breathings, circumflexes, the iota
// subscript and the diaeresis as the letters they sit on (Πει-σι-στρά-του, ὀφ-θαλ-μῶν,
// ἀ-ναμ-φί-λε-κτα). Eftaliotis's modern Greek is written polytonic too; under 'el' a
// polytonic word would be divided by the same patterns, so the two pages hyphenate alike.
// The labels are the modern Greek ones (Εικόνα, Πίνακας), as for 'el'.
const LOCALE = 'grc';
// Fontsource cuts each face into files by script, and loadFonts adds latin and greek. The
// accented letters of polytonic Greek (ἀ ὃ ῷ, U+1F00–1FFF) are in a third file, greek-ext:
// each face takes it too before the build, so no letter falls to a system font.
async function loadGreekExtended(faces) {
const jobs = Object.entries(faces).flatMap(([family, specs]) => specs.map(async (spec) => {
const id = fontsourceId(family);
const style = spec.endsWith('i') ? 'italic' : 'normal';
const file = `${id}-greek-ext-${parseInt(spec, 10)}-${style}.woff2`;
const url = `${await fontsourceAt(id)}files/${file}`;
const face = new FontFace(family, `url(${url}) format('woff2')`,
{ weight: String(parseInt(spec, 10)), style, unicodeRange: 'U+1F00-1FFF' });
document.fonts.add(await face.load());
}));
await Promise.all(jobs);
}
Ingredientes
- Funcionalidades
- Hifenização e idioma do documentoNumeração de linhasVerso linha a linhaFontes antes da diagramaçãoEstilos de títuloAtributos de títuloAberturas desenhadasTextos, fios e caixas nos designs de páginaCabeços e fóliosCabeços por tipo de páginaQuebras de página e de colunaMargens espelhadasCor do papelEstilos de parágrafoMetadados do documentoPaleta de cores semânticaPáginas em um canvas
- Tipografia
- GFS Didot (SIL OFL 1.1)
- Materiais
- Nenhum: todas as imagens são desenhadas em código
Preparo
#1 · Marque o texto como grc e carregue as letras acentuadas
O código é a resposta curta acima. locale: 'grc' usa os padrões politônicos (hifenização), que leem um espírito, um circunflexo, um iota subscrito ou um trema como parte da letra em que estão. A página 1 divide Βατρα-χομυομαχία, ἐπι-δειξάμενος e τυράν-νου. O Fontsource separa cada família por sistema de escrita, e loadFonts acrescenta só os arquivos latin e greek. As letras politônicas pré-compostas, U+1F00–1FFF, estão num terceiro arquivo, greek-ext, que loadGreekExtended acrescenta a cada família antes da composição. Chame-a depois de loadFonts, senão o motor dá a família por carregada e pula o arquivo greek.
#2 · Numere a cada cinco versos na margem externa
// Each page of verse is its own :::verse block. The Greek and the translation of a spread
// both open with {lineStart=11}, so the numbers on the two pages agree: restart 'poem'
// counts each block from its own start, and the epitaph, {numbered=false}, is not counted.
const lineNumbers = {
enabled: true, count: 'verse', interval: 5, restart: 'poem', position: 'outer',
gap: mm(6), fontFamily: DIDOT, fontSize: em(0.8), color: col('rubric'),
};
count: 'verse' numera só versos, e restart: 'poem' conta cada bloco :::verse desde o próprio início. Cada página de verso é um bloco. O grego e a tradução da segunda abertura abrem os dois com {lineStart=11}, e os números das páginas em face coincidem. position: 'outer' os leva à margem esquerda de uma par e à direita de uma ímpar (números de linha). O epitáfio leva {numbered=false} e não recebe número.
#3 · Aberturas e cabeços em versais
// textTransform 'uppercase' turns Ὀδύσσεια into ΟΔΥΣΣΕΙΑ and Ῥαψῳδία into ΡΑΨΩΔΙΑ: Greek
// capitals take no breathing, no accent and no iota subscript (a dialytika stays, Ϊ Ϋ).
const caps = (size, tracking, color = 'muted') => ({ fontFamily: DIDOT, fontSize: pt(size),
letterSpacing: pt(tracking), textTransform: 'uppercase', color: col(color) });
const opener = (title) => ({ enabled: true, minHeight: pt(5 * LEAD), slot: { elements: [
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', align: 'center', ...caps(8, 2, 'rubric'),
placement: { ...at('container', 'top', 0, LINE), size: { width: 'fill' } } },
{ kind: 'text', id: 'title', content: title, align: 'center', ...caps(17, 3.5, 'ink'),
placement: { ...at('container', 'top', 0, 2.2 * LINE), size: { width: 'fill' } } },
] } });
// # Ὀδύσσεια {style="original"} opens a verso, {style="translation"} the recto facing it;
// a style sets its own break side (gotcha: style-inherits-break).
const headingStyles = [
{ id: 'original', breakBefore: { enabled: true, parity: 'even' }, marginBottom: pt(0),
advancedDesign: opener('{titleText}') },
{ id: 'translation', breakBefore: { enabled: true, parity: 'odd' }, marginBottom: pt(0),
advancedDesign: opener('{titleText}') },
{ id: 'life', breakBefore: { enabled: true, parity: 'odd' }, marginBottom: pt(0),
advancedDesign: { enabled: true, minHeight: pt(6 * LEAD), slot: { elements: [
{ kind: 'text', id: 'title', content: '{titleText}', align: 'center', ...caps(15, 3, 'ink'),
placement: { ...at('container', 'top', 0, 1.6 * LINE), size: { width: 'fill' } } },
{ kind: 'text', id: 'source', content: '{attr.source}', align: 'center', fontFamily: DIDOT,
fontSize: pt(10), color: col('muted'),
placement: { ...at('container', 'top', 0, 3.2 * LINE), size: { width: 'fill' } } },
] } } },
{ id: 'note-page', breakBefore: { enabled: true, parity: 'even' }, marginBottom: pt(LEAD),
header: { elements: [] }, advancedDesign: { enabled: true, minHeight: pt(3 * LEAD),
slot: { elements: [{ kind: 'text', id: 'label', content: '{titleText}', align: 'center',
...caps(7.5, 1.6, 'rubric'), placement: { ...at('container', 'top', 0, LINE),
size: { width: 'fill' } } }] } } },
];
// The author and the title over the versos, the translator over the rectos; folios outside.
const head = (id, content, parity, edge, x, extra = {}) => ({ kind: 'text', id, content, parity,
pages: 'body', ...caps(7.5, 1.5), ...extra, placement: at('page', edge, x, 12) });
const folio = { textTransform: 'none', letterSpacing: pt(0), fontSize: pt(9), color: col('ink') };
const SHIFT = (INNER - OUTER) / 2; // mm: the text block's centre is off the page's centre
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
head('verso-head', '{author} · {title}', 'even', 'top', -SHIFT),
head('recto-head', '{subtitle}', 'odd', 'top', SHIFT),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
textTransform: 'uppercase' transforma Ὀδύσσεια em ΟΔΥΣΣΕΙΑ e Ῥαψῳδία em ΡΑΨΩΔΙΑ: as maiúsculas gregas não levam espírito, acento nem iota subscrito, e o motor os tira ao compor. O estilo original abre o grego numa par e translation a versão na ímpar em frente. :::pagebreak{parity="even"} e {parity="odd"} fazem o mesmo na segunda abertura. O texto do título e o do PDF ficam como foram escritos, com todas as marcas.
A receita completa
// ═══ Postext Cookbook · Nº 202 · Homer in polytonic Greek, facing its translation ═══════
// https://postext.dev/en/cookbook/homer-polytonic-facing-translation
// Code: MIT · Texts: Homer, Hesychius, A. Eftaliotis (PD, el.wikisource) · Pictures: none
// Fonts: GFS Didot (SIL OFL 1.1) · Needs postext ≥ 1.99.1
// The opening of the Odyssey on the versos, Eftaliotis's line-for-line modern Greek on the
// rectos, both numbered every fifth line, after a page of the Byzantine Life of Homer.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
const LANG = 'en'; // @lang: the language of the note on the text ('en' | 'es' | 'el')
const RECIPE = 'homer-polytonic-facing-translation';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// Black text on a warm white, and the dull red of a classical text's rubrics.
const palette = {
ink: '#1c1a18', // the texts
rubric: '#8c2f23', // line numbers, headings, rules
muted: '#6b6359', // running heads, the note on the text, the colophon
paper: '#fcfaf5',
};
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 DIDOT = 'GFS Didot'; // the Greek Font Society's Didot: polytonic, with its own Latin
const [BODY, LEAD] = [10.2, 15]; // pt
const LINE = (LEAD * 25.4) / 72; // mm: one line, 5.29
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// #region answer: Ancient Greek is 'grc', with the polytonic accents written in the text
// locale 'grc' takes the polytonic patterns, which read breathings, circumflexes, the iota
// subscript and the diaeresis as the letters they sit on (Πει-σι-στρά-του, ὀφ-θαλ-μῶν,
// ἀ-ναμ-φί-λε-κτα). Eftaliotis's modern Greek is written polytonic too; under 'el' a
// polytonic word would be divided by the same patterns, so the two pages hyphenate alike.
// The labels are the modern Greek ones (Εικόνα, Πίνακας), as for 'el'.
const LOCALE = 'grc';
// Fontsource cuts each face into files by script, and loadFonts adds latin and greek. The
// accented letters of polytonic Greek (ἀ ὃ ῷ, U+1F00–1FFF) are in a third file, greek-ext:
// each face takes it too before the build, so no letter falls to a system font.
async function loadGreekExtended(faces) {
const jobs = Object.entries(faces).flatMap(([family, specs]) => specs.map(async (spec) => {
const id = fontsourceId(family);
const style = spec.endsWith('i') ? 'italic' : 'normal';
const file = `${id}-greek-ext-${parseInt(spec, 10)}-${style}.woff2`;
const url = `${await fontsourceAt(id)}files/${file}`;
const face = new FontFace(family, `url(${url}) format('woff2')`,
{ weight: String(parseInt(spec, 10)), style, unicodeRange: 'U+1F00-1FFF' });
document.fonts.add(await face.load());
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
Erro comum
Um estilo de título herda a quebra de página do seu nível
Uma entrada de headingStyles recebe do seu nível de título todos os campos que não define, inclusive breakBefore. Um sumário ou um colofão com estilo sobre um H1 depois de um :::pagebreak herda a paridade 'odd' e cai depois de uma página em branco. Dê a esse estilo breakBefore: { enabled: false }. Estilos de título →
- Sem o arquivo greek-ext, cada vogal acentuada cai numa fonte do sistema que raramente combina. A captura confere cada glifo com os arquivos carregados (C36) e reprova essa página.
- A GFS Didot tem um só peso e não tem itálico: uma ênfase seria inclinada pelo renderizador. Por isso a nota sobre o texto vai em redondo.
- O provedor de fontes PDF do kit carrega só latin e greek, e esta receita mostra o canvas sem oferecer PDF.
- Nenhum verso da tradução pode passar da mancha. Um verso que quebra empurra uma linha o resto da página, e as duas páginas deixam de se corresponder verso a verso; 103 mm a 10,2 pt comportam o verso mais longo de Eftaliotis, 59 letras.
Créditos
- Receita
- Ignacio Ferro
- Texto
- Odyssey, Book I, lines 1–27, in the polytonic text of el.wikisource (revision 165777) · Homer · domínio público
- The modern Greek translation of the same lines, line for line, from el.wikisource (revision 166701), with one accent corrected · Argyris Eftaliotis · domínio público
- Life of Homer, §§ 6–7 and the epitaph, from the Suda (ed. A. Westermann, 1845), via el.wikisource (revision 152483), with four slips corrected · Hesychius of Miletus · domínio público
- The note on the text and the colophon · Postext Cookbook · original
- Fontes
- GFS Didot (SIL OFL 1.1)
- Código
- MIT, como o Postext
Editar este texto ↗ (abre em uma nova aba)Pasta da receita no GitHub ↗ (abre em uma nova aba)


