かんたんな説明
古い詩集と同じ形で組んだ古典アラビア語の詩です。各行を2つに分けて横に並べ、どちらも同じ幅まで伸ばすので、行の端がページの上から下までそろいます。
できあがり
ムタナッビーの詩を集めたディーワーン(詩集)の4ページを、1世紀前のカイロの印刷所が組んだ形で組みます。まず赤いルクア体でديوانと記した小扉があり、続いて、彼が954年にサイフ・アッダウラの前で詠んだカスィーダが、赤い罫の飾り見出しの下に入ります。46のバイトはそれぞれ2つの半句からなる1行で、右に前半句(サドル)、左に後半句(アジュズ)を置き、どちらもカシーダで同じ幅まで伸ばします。そのため‑muの脚韻が左端を一直線に下っていきます。本は右綴じで、ノンブルはアラビア・インド数字で数えます。版によって変わるのは、最後にある本文についての注記だけです。唐詩と向かい合う英訳詩では、古典中国語の詩を独自のグリッドに組んでいます。
このレシピが答える質問
- 古典アラビア語の韻文を、各行を2つの半句に分けて組むには?
手短な答え
// In the Markdown, a :::verse block takes one bayt a line, the ṣadr and the ʿajuz parted
// by ||:
// :::verse{style="bayt"}
// عَلى قَدْرِ أهْلِ العَزْم تأتي العَزائِمُ || وَتأتي علَى قَدْرِ الكِرامِ المَكارمُ
// :::
// The ṣadr goes on the right, the ʿajuz on the left, both stretched to the width of the
// widest half with a gap of 2 em between them. The style gives the poem its face and a
// leading deep enough for the harakat: 1.9 × the size.
const bayt = { id: 'bayt', fontFamily: NASKH, fontSize: pt(14), lineHeight: pt(26.6),
color: col('ink'), marginTop: pt(LEAD / 2), marginBottom: pt(LEAD) };
// Justified lines lengthen their words with kashidas (tatweel) before they open the
// spaces wide: 'auto' is the default in an Arabic document, written out here to say so.
// A hemistich may stretch a word twice as far as a line of prose does: 1.2 em.
const bodyKashida = { kashida: 'auto', kashidaPatterns: 'naskh', kashidaMaxLength: 0.6 };
材料
- 機能
- アラビア語の詩(2つの半句からなるバイト)カシーダによる両端そろえ右から左のテキストアラビア語のフォント文書の言語としてのアラビア語右綴じの本生成される番号の数字デザインした章扉見出しの属性見出しスタイル表紙、扉、奥付柱とノンブルページの役割ごとの柱用紙の色段落スタイル逆方向の段落セマンティックカラーパレットPDFの書き出しPDFに埋め込むフォント
- 併用する機能
- 節ごとの柱
- 種類
- Amiri, Aref Ruqaa, Noto Kufi Arabic (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 1行に1バイト、両方の半句を同じ幅に
コードは前出の手短な答えにあります。:::verseの中では各行が1つのバイトで、||が2つの半句を分けます。そのためMarkdownは、もとになったウィキソースのテキストと同じように読めます(:::verse)。詩全体ですべての半句の幅を測り、いちばん広い半句の幅を両方の列の幅とし(上限は行長の半分から列間を引いた値)、各半句をその幅まで埋めます。まずカシーダで伸ばし、その後で語間を広げます(古典詩)。baytのスタイルは14 ptの文字を26.6 ptの行送り、つまり文字サイズの1.9倍で組みます。これで隣り合う行のシャッダとカスラがぶつかりません(母音記号)。仕上がりは17 × 24 cmです。14 × 21 cmでは、バイトの3分の1が104 mmの行長の半分に収まらず、前半句と後半句をそれぞれ別の行に置く、ずらした組み方に戻ってしまいました。

#2 · ルクア体の飾り見出しの帯
const rule = (id, y, thickness) => ({ kind: 'rule', id, direction: 'horizontal',
thickness: pt(thickness), color: col('rubric'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(y) },
size: { width: 'fill' } } });
const opener = {
enabled: true, minHeight: mm(46),
slot: { elements: [
{ kind: 'box', id: 'band', reserve: false, style: { backgroundColor: col('tint') },
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(4) },
size: { width: 'fill', height: mm(26) } } },
rule('band-top', 4, 1.5), rule('band-foot', 30, 0.5),
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: RUQAA, fontWeight: 700,
fontSize: pt(34), lineHeight: 1.1, align: 'center', color: col('rubric'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(7.5) } } },
{ kind: 'text', id: 'metre', content: '{attr.metre}', fontFamily: KUFI, fontWeight: 500,
fontSize: pt(9), align: 'center', color: col('muted'),
placement: { anchor: { to: 'container', edge: 'top' }, offset: { y: mm(35) } } },
] },
};
レベル1の見出しはそのデザインで描きます。上下に赤い罫を引いた地色付きの囲みの上に、Aref Ruqaaでタイトルを中央に置き、その下に見出しの属性{metre="من البحر الطويل"}から韻律名を入れます。ルクア体の大きな見出し文字にはカシーダが入らないので、タイトルは自然な幅のままです(両端そろえとカシーダ)。
#3 · 紙面の左右に置く柱
// Running heads stay on the sheet's sides: in a book bound on the right the verso (even)
// is the right-hand page, so its outer edge, where the folio goes, is the right one.
const head = (id, content, parity, edge, x, extra = {}) => ({ kind: 'text', id, content,
parity, pages: 'body', fontFamily: KUFI, fontWeight: 500, fontSize: pt(8.5),
color: col('muted'), placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(12) } },
...extra });
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-right', -OUTER, { color: col('ink') }),
head('verso-book', '{title}', 'even', 'top-right', -(OUTER + 10)),
head('recto-rhyme', '{subtitle}', 'odd', 'top-left', OUTER + 10),
head('recto-folio', '{pageNumber}', 'odd', 'top-left', OUTER, { color: col('ink') }),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'bottom', 0, {
pages: 'opener', color: col('ink'),
placement: { anchor: { to: 'page', edge: 'bottom' }, offset: { y: mm(-12) } } })] };
本文は右から左へ進み、本文での左右は始端と終端を意味します。柱の左右は物理的な位置のままです。右綴じの本では、偶数ページが見開きの右側に来るので、そのノンブルは右上に、奇数ページのノンブルは左上に置きます。どちらも小口側です(ページの順序と右綴じ)。組み方向、綴じ、アラビア・インド数字は、locale: 'ar'のタグだけで決まります。
#4 · 本文の流れに何も置かない小扉
const at = (y) => ({ anchor: { to: 'page', edge: 'top' }, offset: { y: mm(y) } });
const line = (id, content, y, style) => ({ kind: 'text', id, content, align: 'center',
overflow: 'wrap', color: col('ink'), placement: at(y), ...style });
const titlePage = {
id: 'title', span: 'page', runningChapter: false,
breakBefore: { enabled: true, parity: 'any' },
header: { elements: [] }, footer: { elements: [] },
advancedDesign: { enabled: true, slot: { elements: [
line('diwan', 'ديوان', 52, { fontFamily: RUQAA, fontWeight: 700, fontSize: pt(64),
lineHeight: 1.2, color: col('rubric') }),
line('poet', '{titleText}', 84, { fontFamily: NASKH, fontWeight: 700, fontSize: pt(20) }),
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.75),
color: col('rubric'), placement: { anchor: { to: 'page', edge: 'top' },
offset: { y: mm(100) }, size: { width: mm(24) } } },
line('rhyme', '{attr.rhyme}', 106, { fontFamily: KUFI, fontWeight: 500, fontSize: pt(11),
color: col('rubric') }),
line('latin', '{attr.latin}', 150, { fontFamily: NASKH, fontSize: pt(9.5),
color: col('muted'), italic: true }),
] } },
};
小扉はspan: 'page'を指定した見出しスタイルで、専用の空の柱とフッターを使います。見出しのテキストは詩人の名前なので、ديوانの語はデザイン要素のテキストとして、その上に64 ptで組みます。脚韻の下の欧文の行はlatin属性から取り、各版がそれぞれの言語で書きます。
レシピの全体
// ═══ Postext Cookbook · Nº 110 · A qasida on a diwan page, in two hemistichs ═══════════
// https://postext.dev/en/cookbook/qasida-diwan-page
// Code: MIT · Text: al-Mutanabbī, Dīwān, ar.wikisource (PD) · Pictures: none
// Fonts: Amiri, Aref Ruqaa, Noto Kufi Arabic (SIL OFL 1.1) · Needs postext ≥ 1.28.0
import { buildDocument, withLoadedFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'qasida-diwan-page';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// Black text and red rubrics on a warm paper, as a Cairo diwan of the 1900s prints them.
const palette = {
ink: '#1f1a16', // text: a warm near-black
rubric: '#9a2b1f', // the accent: titles, the metre, the headpiece rules
tint: '#f1e6cf', // the headpiece band
rule: '#b8a27c', // hairlines
muted: '#6b6156', // running heads and the note on the text
paper: '#fbf7ee', // a cream paper
};
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 NASKH = 'Amiri'; // the text: a Bulaq Naskh
const RUQAA = 'Aref Ruqaa'; // display: the titles
const KUFI = 'Noto Kufi Arabic'; // labels: metre, running heads, folios
const [SIZE, LEAD] = [13, 21]; // pt: the prose, at 1.6 × for a lightly vocalised headnote
const [OUTER, TOP] = [18, 23]; // mm: a 17 × 24 cm diwan
// #region answer: one bayt a line, both hemistichs stretched to one width
// In the Markdown, a :::verse block takes one bayt a line, the ṣadr and the ʿajuz parted
// by ||:
// :::verse{style="bayt"}
// عَلى قَدْرِ أهْلِ العَزْم تأتي العَزائِمُ || وَتأتي علَى قَدْرِ الكِرامِ المَكارمُ
// :::
// The ṣadr goes on the right, the ʿajuz on the left, both stretched to the width of the
// widest half with a gap of 2 em between them. The style gives the poem its face and a
// leading deep enough for the harakat: 1.9 × the size.
const bayt = { id: 'bayt', fontFamily: NASKH, fontSize: pt(14), lineHeight: pt(26.6),
color: col('ink'), marginTop: pt(LEAD / 2), marginBottom: pt(LEAD) };
// Justified lines lengthen their words with kashidas (tatweel) before they open the
// spaces wide: 'auto' is the default in an Arabic document, written out here to say so.
// A hemistich may stretch a word twice as far as a line of prose does: 1.2 em.
const bodyKashida = { kashida: 'auto', kashidaPatterns: 'naskh', kashidaMaxLength: 0.6 };
// #endregion
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
よくあるつまずき
つまずき
アラビア語の本のタグはLANGではなく'ar'にする
レシピの版はenとesですが、アラビア語のサンプルはどちらの版でもアラビア語です。`locale: LANG`では左から右に組まれ、左綴じになり、ページ番号は1 2 3となり、図のキャプションにはFigureやFiguraが付きます。postext 1.30以降、このタグはテキストを組む言語(計測、描画、埋め込みに使う言語)でもあるので、英語やスペイン語のタグでは、Markazi Textのようなフォントがギュメ(« »)や終止符をアラビア語の字形で描かず、改行の位置も変わります。タグは自分で書いてください。'ar'(アラビア・インド数字、マシュリク地域の慣習)、'ar-EG'や'ar-SA'のような地域付きのタグ、ヨーロッパ式数字を使うマグレブ版なら'ar-MA'、'ar-DZ'、'ar-TN'です。アラビア語を引用するだけのラテン文字のページは、自分のロケールのままにします。 右から左のテキスト →
つまずき
アラビア語の書体にはarabicブロックを通じてarabicファイルが必要
FontsourceはAmiri、Noto Naskh Arabic、Scheherazade Newをサブセットごとに1ファイルとして配信し、アラビア文字はarabicファイルに入っています。loadFontsが取得するのはlatin(とlatin-ext)だけなので、画面ではアラビア文字がシステムの書体で出て計測が狂い、fontsourceProviderはPDFにそのlatinファイルを渡すため、空の四角が印字されます。キットのarabicブロックを挙げ、loadFontsのあとにloadArabicFonts(FONTS, markdown)を呼び(ページでアラビア文字に使うすべてのウェイトをFONTSに挙げておきます)、renderToPdfにfontProvider: arabicPdfProviderを渡してください。 アラビア語のフォント →
クレジット
- 本文
- The qasida ʿAlā qadri ahli l-ʿazmi taʾtī l-ʿazāʾimu, as ar.wikisource gives it (revision 447620), with its vowels · al-Mutanabbī · パブリックドメイン
- The headnote in Arabic, the note on the text and the colophon · Postext Cookbook · オリジナル
- フォント
- Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1)


