简单来说
按十九世纪开罗印的阿拉伯文书排的一页:正文在中间,对正文的简短注释在靠边的窄栏里,整页用印出的线框起来。
成品一览
六页,按十九世纪布拉克印书馆及其后开罗各家印注释书的方式来排。伊本·阿基勒对伊本·马利克语法诗《千行诗》(Alfiyya)开篇诗句的讲解排在主栏,诗句用红色;外侧页边是一份旁注(ḥāshiya),每条简注都以所解释的原文字句开头,排在所属段落旁边。双线框住版心,顶部有一条书眉带,放章名和页码,一条单线把正文和页边隔开。真正的布拉克页面,旁注从三面环绕正文;Postext只能放在一侧,这个食谱如实说明了这一点。
这道食谱解答
- 怎样排布拉克(Bulaq)版式,让注释加框环绕正文?
简短回答
// 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 · 页边注有自己的边栏
代码见上文的简短回答。用一栏半版式,并让侧栏只接收浮动内容,注释就不进入正文的文字流:每条旁注写成:::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' })] };
边框是页眉里的三个页面设计元素:两个有边线、无填充的框,相距1.3 mm,以及书眉带下方的一条线。页面元素按纸页的物理方向放置,所以边框按奇偶各建一次,用该侧的页边距计算(页序与右侧装订)。页码在每一页都放在书眉带的外端,章首页也不例外;章名居中,章首页上不放,因为标题本身就在它下面。
#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,下方那行拉丁文随版本语言变化。
完整食谱
// ═══ 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') },常见问题
易错点
阿拉伯文书标记为'ar',不要用LANG
食谱的版本是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'。只引用阿拉伯文的拉丁文页面保留自己的locale。 从右向左的文字 →
易错点
阿拉伯文字体需要通过arabic块加载其arabic文件
Fontsource把Amiri、Noto Naskh Arabic或Scheherazade New按子集分成多个文件提供,阿拉伯字母在arabic文件里。loadFonts只获取latin(以及latin-ext),所以屏幕上的阿拉伯文来自系统字体,测量不准;fontsourceProvider交给PDF的也是这个latin文件,印出来是空框。列出kit中的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)


