かんたんな説明
1800年代にカイロで印刷されたアラビア語の本のようなページです。中央に本文、端の細い列に本文への短い注、ページ全体は印刷した線で囲まれています。
できあがり
19世紀にブーラーク印刷所と、それに続くカイロの印刷所が注釈書を刷ったやり方で組んだ6ページです。主段には、イブン・マーリクが千行の詩で説いた文法書『アルフィーヤ』の冒頭の詩句に対するイブン・アキールの解説が流れ、詩句は赤で組まれます。外側の余白には傍注(ḥāshiya)が立ちます。短い注の一つひとつが、説明する本文の語句で書き出され、その箇所の横に置かれます。版面は二重の罫で囲み、上端には章題とノンブルを入れる帯を設けます。本文と余白のあいだは1本の罫で仕切ります。本物のブーラーク版では傍注が本文の三方を取り巻きますが、Postextでは片側にしか置けません。このレシピではその点も明記しています。
このレシピが答える質問
- 本文の周りを注釈が枠のように囲むブーラーク版のページをレイアウトするには?
手短な答え
// The text runs in the main column of a column-and-a-half layout; the side column, on the
// outer side, takes only boxes with span 'side'. A gloss is written before the passage it
// explains and starts level with its first line, on the page where that passage goes on
// (sideAtColumnEnd: 'after'). A column rule parts the two, as the jadwal of a Bulaq page does.
const layout = { layoutType: 'oneAndHalf', sideColumnRole: 'floats', sideColumnSide: 'outer',
sideColumnPercent: 31, gutterWidth: mm(7),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.6) } };
// A gloss is a callout with no box: the margin's own face, its lemma bold in the rubric.
const hashiya = { id: 'hashiya', span: 'side', sideAtColumnEnd: 'after',
backgroundEnabled: false, borderRadius: pt(0),
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
stripe: { enabled: false }, border: { enabled: false },
body: { fontFamily: NASKH, fontSize: pt(10), lineHeight: pt(16), color: col('ink'),
boldColor: col('rubric'), textAlign: 'justify', firstLineIndent: pt(0),
paragraphSpacing: true } };
材料
- 機能
- 欄外の注ページデザインのテキスト・罫・ボックス右から左のテキスト1段半組みフロート用の余白段段間罫右綴じの本アラビア語のフォント文書の言語としてのアラビア語アラビア語の詩(2つの半句からなるバイト)生成される番号の数字表紙、扉、奥付見出しスタイル見出しの属性柱とノンブル用紙の色段落スタイル逆方向の段落セマンティックカラーパレットPDFの書き出し
- 種類
- Amiri, Aref Ruqaa (SIL OFL 1.1)
- 素材
- なし:画像はすべてコードで描画
作り方
#1 · 傍注のための専用のサイド段
コードは上の手短な答えにあります。1.5段組みにしてサイド段にはフロートだけを受けさせると、注釈は本文の流れに入りません。各傍注は、説明する箇所の前に:::callout{type="hashiya" span="side"}として書きます。すると、その箇所の最初の行と同じ高さから始まります。その箇所が次のページへ送られるときは、sideAtColumnEnd: 'after'によって傍注もいっしょに移ります(レイアウト)。囲みには背景も枠線も内側余白もないので、余白に組まれた文字として読めます。見出し語は太字で、boldColorが赤にします。sideColumnSide: 'outer'は、どちらのページでもサイド段を小口側に置きます。偶数ページなら右側です。右綴じの本では、偶数ページは見開きの右に来ます。

#2 · 見開きの左右それぞれに引く枠
// Page-level design elements are physical: the frame follows the margins of each side of
// the spread. In a book bound on the right the even page is the right-hand one, its spine
// on its left, so its inner margin is the left one. A heading's design is set in the flow
// and mirrored with the page (inFlow): there 'left' is the sheet's right.
const frame = (parity, withBand = true, inFlow = false) => {
const left = (parity === 'even') !== inFlow ? M.inner : M.outer;
const width = TRIM.width - M.inner - M.outer;
const box = (id, inset, thickness) => ({ kind: 'box', id: `${id}-${parity}`, parity,
style: { borderColor: col('rule'), borderWidth: pt(thickness) },
placement: { anchor: { to: 'page', edge: 'top-left' },
offset: { x: mm(left - 4 + inset), y: mm(M.top - 13 + inset) },
size: { width: mm(width + 8 - 2 * inset),
height: mm(TRIM.height - M.top - M.bottom + 17 - 2 * inset) } } });
return [box('outer', 0, 1.4), box('inner', 1.3, 0.4), ...(withBand ? [
{ kind: 'rule', id: `band-${parity}`, parity, direction: 'horizontal', thickness: pt(0.4),
color: col('rule'), placement: { anchor: { to: 'page', edge: 'top-left' },
offset: { x: mm(left - 2.7), y: mm(M.top - 4) },
size: { width: mm(width + 5.4) } } }] : [])];
};
// The chapter centred in the band, the folio at its outer end. The frame stands off the
// sheet's centre by half the difference of the margins, towards the outer edge.
const SHIFT = (M.inner - M.outer) / 2; // mm
const band = (id, content, parity, edge, x, extra = {}) => ({ kind: 'text', id, content,
parity, pages: 'body', fontFamily: NASKH, fontWeight: 700, fontSize: pt(10.5),
color: col('ink'),
placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(M.top - 11) } }, ...extra });
const header = { elements: [...frame('even'), ...frame('odd'),
band('head-even', '{chapterTitle}', 'even', 'top', SHIFT),
band('head-odd', '{chapterTitle}', 'odd', 'top', -SHIFT),
band('folio-even', '{pageNumber}', 'even', 'top-right', -(M.outer + 1), { pages: 'all' }),
band('folio-odd', '{pageNumber}', 'odd', 'top-left', M.outer + 1, { pages: 'all' })] };
枠は、ヘッダーに置いた3つのページデザイン要素でできています。塗りなしで枠線だけの箱が2つ、間隔1.3mmで重なり、柱を入れる帯の下に罫が1本引かれます。ページ要素は物理的な位置で決まるため、枠は奇数・偶数ページ用に2回、それぞれの側の余白から組み立てます(ページの順序と右綴じ)。ノンブルは章扉も含めて全ページで帯の小口側の端に置きます。章題は中央にそろえ、章扉では省きます。章扉ではその下に題そのものが立つからです。
#3 · 同じ枠に収めた扉
const line = (id, content, y, style) => ({ kind: 'text', id, content, align: 'center',
overflow: 'wrap', color: col('ink'),
// Centred in the frame: the title page is an odd page set in the mirrored flow.
placement: { anchor: { to: 'page', edge: 'top' }, offset: { x: mm(SHIFT), y: mm(y) },
size: { width: mm(110) } }, ...style });
const titlePage = { id: 'title', span: 'page', runningChapter: false,
breakBefore: { enabled: true, parity: 'any' }, header: { elements: [] },
footer: { elements: [] },
advancedDesign: { enabled: true, slot: { elements: [...frame('odd', false, true),
line('book', '{titleText}', 64, { fontFamily: RUQAA, fontWeight: 700, fontSize: pt(40),
lineHeight: 1.3, color: col('rubric') }),
line('on', '{attr.on}', 88, { fontFamily: NASKH, fontWeight: 700, fontSize: pt(17) }),
{ kind: 'rule', id: 'rule', direction: 'horizontal', thickness: pt(0.75), color: col('rubric'),
placement: { anchor: { to: 'page', edge: 'top' }, offset: { x: mm(SHIFT), y: mm(104) },
size: { width: mm(30) } } },
line('margin', '{attr.margin}', 112, { fontFamily: NASKH, fontSize: pt(13) }),
line('latin', '{attr.latin}', 196, { fontFamily: NASKH, fontSize: pt(9), italic: true,
color: col('muted') }),
] } } };
扉は帯を除いた同じ枠を使い回します。見出しのデザインは本文の流れの中で組まれ、ページとともに鏡像になるので、そこでは枠の左右を入れ替えて作ります(inFlow)。枠の左は紙面の右です。扉の各行は見出しの属性onとmarginから作るので、扉全体がMarkdownの1行で済みます。その下のラテン文字の行は版ごとに変わります。
レシピの全体
// ═══ Postext Cookbook · Nº 114 · A Bulaq page: the text framed by its commentary ════════
// https://postext.dev/en/cookbook/bulaq-framed-page
// Code: MIT · Text: Ibn ʿAqīl, Sharḥ; Ibn Mālik, Alfiyya, ar.wikisource (PD) · Pictures: none
// Fonts: Amiri, Aref Ruqaa (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 = 'bulaq-framed-page';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// Black and a brown-red on a toned paper: the two inks of a Cairo press around 1900.
const palette = {
ink: '#1d1915', // text and frame rules
rubric: '#8e3020', // the accent: lemmas of the glosses, the matn, titles
rule: '#3a312a', // the frame
muted: '#6a6056', // the note on the text
paper: '#f6efe0', // a toned 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, the matn and the glosses
const RUQAA = 'Aref Ruqaa'; // the title page and the chapter title
const TRIM = { width: 170, height: 240 }; // mm
const M = { top: 34, bottom: 24, inner: 20, outer: 15 }; // mm: the type area inside the frame
// #region answer: the commentary's column beside the text, both inside one ruled frame
// The text runs in the main column of a column-and-a-half layout; the side column, on the
// outer side, takes only boxes with span 'side'. A gloss is written before the passage it
// explains and starts level with its first line, on the page where that passage goes on
// (sideAtColumnEnd: 'after'). A column rule parts the two, as the jadwal of a Bulaq page does.
const layout = { layoutType: 'oneAndHalf', sideColumnRole: 'floats', sideColumnSide: 'outer',
sideColumnPercent: 31, gutterWidth: mm(7),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.6) } };
// A gloss is a callout with no box: the margin's own face, its lemma bold in the rubric.
const hashiya = { id: 'hashiya', span: 'side', sideAtColumnEnd: 'after',
backgroundEnabled: false, borderRadius: pt(0),
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
stripe: { enabled: false }, border: { enabled: false },
body: { fontFamily: NASKH, fontSize: pt(10), lineHeight: pt(16), color: col('ink'),
boldColor: col('rubric'), textAlign: 'justify', firstLineIndent: pt(0),
paragraphSpacing: true } };
// #endregion
// #region frame: a double rule round the type area and a band for the running head
組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)
アレンジ
#注釈を内側に置く
傍注を背の側に置き、本文に広い外側の余白を残す印刷所もありました。
-const layout = { layoutType: 'oneAndHalf', sideColumnRole: 'floats', sideColumnSide: 'outer',
+const layout = { layoutType: 'oneAndHalf', sideColumnRole: 'floats', sideColumnSide: 'inner',#傍注を一つずつ囲む
後代のカイロの刷りに見られるように、各傍注のまわりに細い罫を引くには、囲みの枠線そのものを使います。
- stripe: { enabled: false }, border: { enabled: false },
+ stripe: { enabled: false }, border: { enabled: true, width: pt(0.4), color: col('rule') },よくあるつまずき
つまずき
アラビア語の本のタグは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を渡してください。 アラビア語のフォント →
クレジット
- 本文
- Ibn ʿAqīl’s commentary on the opening of the Alfiyya, with Ibn Mālik’s verses, as ar.wikisource gives it (revision 521625), without the modern editor’s footnotes · Ibn ʿAqīl, Ibn Mālik · パブリックドメイン
- The glosses in the margin, the title page, the note on the text and the colophon · Postext Cookbook · オリジナル
- フォント
- Amiri (SIL OFL 1.1) · Aref Ruqaa (SIL OFL 1.1)


