In short
The first lines of Homer's Odyssey in ancient Greek, with all its accents and breathings, on the left pages, and a modern Greek verse translation on the right, each line level with the one it translates.
What you'll build
A small classical text, 14 × 21.5 cm, in GFS Didot, the Greek Font Society's polytonic face. A page of the Byzantine Life of Homer that the Suda gives under Hesychius of Miletus opens it, with Homer's epitaph from Ios. Then come two spreads: lines 1 to 27 of the first book of the Odyssey on the versos, and Argyris Eftaliotis's fifteen-syllable modern Greek version on the rectos, line for line, numbered every fifth line in the outer margin. All three texts are public domain and come from the Greek Wikisource. The running heads and openers set the titles in capitals, which drop every breathing and accent.
This recipe answers
- How do I set a poem and its translation on facing pages, with the original always on the recto?
- How do I number every fifth line of a poem in the margin and key my notes to those line numbers?
- How do I set poetry: one line per verse, stanza gaps, hanging indents for wrapped lines, no hyphenation?
- How do I get good justification and hyphenation for Spanish, French or German text?
The short answer
// 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);
}
Ancient Greek is 'grc', with the polytonic accents written in the text
Ingredients
- Features
- Hyphenation and document languageLine numbersVerse line by lineFonts before layoutHeading stylesHeading attributesDesigned openersText, rules and boxes in page designsRunning heads and foliosHeads by page rolePage and column breaksMirrored marginsPaper colourParagraph stylesDocument metadataSemantic colour palettePages on a canvas
- Type
- GFS Didot (SIL OFL 1.1)
- Assets
- None: every picture is drawn in code
Method
#1 · Tag the text grc and load its accented letters
The code is the short answer above. locale: 'grc' takes the polytonic patterns (hyphenation), which read a breathing, a circumflex, an iota subscript or a diaeresis as part of the letter it sits on. Page 1 divides Βατρα-χομυομαχία, ἐπι-δειξάμενος and τυράν-νου. Fontsource splits each face by script, and loadFonts adds the latin and greek files only. The precomposed polytonic letters, U+1F00–1FFF, live in a third file, greek-ext, which loadGreekExtended adds for every face before the build. Call it after loadFonts, or the engine takes the face as loaded and skips the greek file.
#2 · Number every fifth line at the outer edge
// 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' numbers verse lines only, and restart: 'poem' counts each :::verse block from its own start. Each page of verse is its own block. The Greek and the translation of the second spread both open with {lineStart=11}, so the numbers on facing pages agree. position: 'outer' sends them to the left margin of a verso and the right margin of a recto (line numbers). The epitaph is fenced {numbered=false} and takes no number.
#3 · Openers and running heads in capitals
// 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' turns Ὀδύσσεια into ΟΔΥΣΣΕΙΑ and Ῥαψῳδία into ΡΑΨΩΔΙΑ: Greek capitals take no breathing, no accent and no iota subscript, and the engine removes them as it sets the letters. The original style opens the Greek on a verso and translation the version on the recto facing it. :::pagebreak{parity="even"} and {parity="odd"} do the same for the second spread. The heading text and the PDF's text stay as written, with every mark.
The whole recipe
// ═══ 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());
The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)
Pitfalls
Pitfall
A heading style inherits its level's page break
A headingStyles entry takes every field it leaves out from its heading level, breakBefore included. A contents page or a colophon styled on an H1 after a :::pagebreak inherits parity 'odd' and lands behind a blank page. Give such a style breakBefore: { enabled: false }. Heading styles →
- Without the greek-ext file, every accented vowel falls back to a system face that rarely matches. The capture checks each glyph against the files loaded (C36) and fails such a page.
- GFS Didot has a single weight and no italic: an emphasis would be slanted by the renderer. The note on the text is set upright for that reason.
- The PDF font provider in the kit loads latin and greek only, so this recipe shows the canvas and offers no PDF.
- Keep every line of a translation no wider than the measure. A line that turns over pushes the rest of the page down by one, and the two pages stop facing line for line; 103 mm at 10.2 pt holds Eftaliotis's longest line, 59 letters.
Credits
- Recipe
- Ignacio Ferro
- Text
- Odyssey, Book I, lines 1–27, in the polytonic text of el.wikisource (revision 165777) · Homer · public domain
- The modern Greek translation of the same lines, line for line, from el.wikisource (revision 166701), with one accent corrected · Argyris Eftaliotis · public domain
- 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 · public domain
- The note on the text and the colophon · Postext Cookbook · original
- Fonts
- GFS Didot (SIL OFL 1.1)
Edit this write-up ↗ (opens in a new tab)Recipe folder on GitHub ↗ (opens in a new tab)


