本文へスキップ
レシピ番号202

レシピ集 · 第2章 · 文字と本文

多調ギリシャ語のホメロスと訳の対訳

左ページに『オデュッセイア』の冒頭、右ページにエフタリオティスの現代ギリシャ語訳。grcパターンで分綴し、5行ごとに行番号を入れます。

このページの内容
ジャンル
詩歌
出力
Canvas
レベル
中級
Postext
Postext 1.99.1で検証済み
1.99.1以上が必要
ライセンス
2026年11月29日更新
コードMIT · 本文CC BY 4.0

2〜3ページ(全6ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり140 × 215 mm
  • 1段
  • GFS Didot 10.2/15
  • 6ページ
  • レベル
  • Postext 1.99.1
  • 組版時間43 ms
  • コード150行

かんたんな説明

ホメロス『オデュッセイア』冒頭の古代ギリシャ語を、アクセントと気息記号をすべて付けて左ページに、現代ギリシャ語の韻文訳を右ページに置き、訳の各行を原文の行と同じ高さにそろえます。

できあがり

ギリシャ書体協会の多調書体GFS Didotで組む、14 × 21.5 cmの小さな古典テキストです。冒頭は、『スーダ辞典』がミレトスのヘシュキオスの名で伝えるビザンティンの『ホメロス伝』の1ページで、イオス島のホメロスの墓碑銘が付きます。続く2つの見開きでは、左ページに『オデュッセイア』第1歌1〜27行、右ページにアルギリス・エフタリオティスの十五音節詩による現代ギリシャ語訳を1行ずつ対応させて置き、外側の余白に5行ごとの番号を入れます。3つのテキストはいずれもパブリックドメインで、ギリシャ語版ウィキソースから取りました。柱と章扉の題は大文字で組み、気息記号とアクセントをすべて落とします。

このレシピが答える質問

  • 詩とその翻訳を見開きに向かい合わせで組み、原文を常に奇数ページに置くには?
  • 詩の5行ごとに余白へ行番号を付け、注をその行番号に対応させるには?
  • 詩を組むには(1行に1詩行、連の間のアキ、折り返した行のぶら下げインデント、ハイフネーションなし)?
  • スペイン語・フランス語・ドイツ語のテキストで、きれいな両端そろえとハイフネーションを得るには?

手短な答え

script.js · 31〜51行コード全体で見る
// 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);
}

材料

種類
GFS Didot (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · テキストをgrcとし、アクセント付きの文字を読み込む

コードは上の手短な答えです。locale: 'grc'は多調の分綴パターンを使います(分綴)。気息記号、曲アクセント、下書きのイオタ、分音記号を、それが付く文字の一部として読みます。1ページ目はΒατρα-χομυομαχία、ἐπι-δειξάμενος、τυράν-νουと分かれます。Fontsourceは書体を文字体系ごとのファイルに分けており、loadFontsが加えるのはlatinとgreekだけです。合成済みの多調文字U+1F00–1FFFは3つ目のファイルgreek-extにあり、loadGreekExtendedが組版の前に各書体に加えます。loadFontsの後に呼んでください。先に呼ぶと、エンジンが書体を読み込み済みとみなしてgreekのファイルを飛ばします。

#2 · 外側の余白に5行ごとの番号

script.js · 67〜73行コード全体で見る
// 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'は詩行だけを数え、restart: 'poem'は:::verseブロックごとにその先頭から数えます。詩の各ページは別のブロックです。2つ目の見開きの原文と訳はどちらも{lineStart=11}で始まるので、向かい合うページの番号がそろいます。position: 'outer'で番号は偶数ページの左、奇数ページの右の余白に入ります(行番号)。墓碑銘は{numbered=false}で、番号を付けません。

#3 · 大文字の章扉と柱

script.js · 83〜124行コード全体で見る
// 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'はὈδύσσειαをΟΔΥΣΣΕΙΑに、ῬαψῳδίαをΡΑΨΩΔΙΑにします。ギリシャ語の大文字は気息記号もアクセントも下書きのイオタも付けないので、エンジンが組むときに外します。スタイルoriginalは原文を偶数ページから、translationは訳を向かいの奇数ページから始めます。2つ目の見開きでは:::pagebreak{parity="even"}と{parity="odd"}が同じ役をします。見出しの文字とPDFのテキストは書いたとおり、記号もすべて残ります。

レシピの全体

Sandbox
// ═══ 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());

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

よくあるつまずき

つまずき

見出しスタイルはその階層の改ページを受け継ぐ

headingStylesの項目は、指定しなかったフィールドをすべて見出しの階層から受け継ぎ、breakBeforeも例外ではありません。:::pagebreakのあとのH1に付けた目次や奥付のスタイルはparity 'odd'を受け継ぎ、白ページの後ろに置かれます。こうしたスタイルにはbreakBefore: { enabled: false }を指定してください。 見出しスタイル →

  • greek-extのファイルがないと、アクセント付きの母音がすべて、まず合わないシステム書体に落ちます。キャプチャは各グリフを読み込んだファイルと照合し(C36)、そのページを不合格にします。
  • GFS Didotはウェイトが1つでイタリックがありません。強調はレンダラーが機械的に傾けてしまうので、本文についての注記は立体で組みます。
  • キットのPDFフォントプロバイダーはlatinとgreekしか読み込まないため、このレシピはキャンバス表示だけで、PDFは出しません。
  • 訳のどの行も行長を超えないようにします。折り返した行があるとページの残りが1行下がり、2ページが行ごとに対応しなくなります。10.2 ptで103 mmあれば、エフタリオティスのいちばん長い行、59文字が収まります。

クレジット

レシピ
Ignacio Ferro
本文
フォント
GFS Didot (SIL OFL 1.1)
Sandbox