باختصار
صفحة مصنوعة على هيئة الكتب العربية التي طُبعت في القاهرة في القرن التاسع عشر: المتن في الوسط، وتعليقات قصيرة عليه في عمود ضيق عند الحافة، والصفحة كلها محصورة في خطوط مطبوعة.
ما الذي ستنضده
ست صفحات منضّدة كما كانت مطبعة بولاق ومن خلفها من مطابع القاهرة تطبع الشروح في القرن التاسع عشر. يجري شرح ابن عقيل لأول أبيات الألفية، منظومة ابن مالك في النحو في ألف بيت، في العمود الرئيسي، والأبيات بالأحمر؛ وفي الهامش الخارجي حاشية، تعليقات قصيرة تبدأ كل منها بألفاظ المتن الذي تشرحه، بجانب الموضع الذي تتعلق به. يحيط خطان مزدوجان بمساحة النص، في رأسها شريط لعنوان الباب ورقم الصفحة، ويفصل خط مفرد المتن عن هامشه. في صفحة بولاق الحقيقية تلتف الحاشية حول المتن من ثلاث جهات؛ أما 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 } };
المكونات
- الميزات
- ملاحظات الهامشالنصوص والخطوط والمربعات في تصاميم الصفحةالنص من اليمين إلى اليسارعمود ونصفعمود هامشي للعناصر العائمةالخط الفاصل بين الأعمدةكتب مجلّدة من اليمينالخطوط العربيةالعربية لغةً للمستندالشعر العربي (البيت بشطرين)أشكال الأرقام في الأعداد المولَّدةالأغلفة وصفحات العنوان وبيانات النشرأنماط العناوينسمات العنوانالترويسات وأرقام الصفحاتلون الورقأنماط الفقراتفقرات بالاتجاه المعاكسلوحة ألوان دلاليةالتصدير إلى PDF
- تستخدم أيضًا
- إطارات التنبيهصفحات افتتاح مصمَّمةالترويسات بحسب دور الصفحةالخطوط المضمَّنة في PDFترويسات لكل قسم
- الخطوط
- Amiri, Aref Ruqaa (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#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 مم، وخط تحت الشريط الذي فيه الترويسة. عناصر الصفحة فعلية الجوانب، فيُبنى الإطار مرتين، مرة لكل زوجية وفردية، من هوامش ذلك الجانب (ترتيب الصفحات والتجليد على اليمين). يقع رقم الصفحة عند الطرف الخارجي من الشريط في كل صفحة، وصفحات الافتتاح منها؛ وعنوان الباب موسّط ويُترك من صفحة الافتتاح، حيث يقف العنوان نفسه تحته.
#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 المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على 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' لنسخة مغاربية بالأرقام الأوروبية. أما الصفحة اللاتينية التي تقتبس العربية فقط فتحتفظ بلغتها. النص من اليمين إلى اليسار →
خطأ شائع
الخطوط العربية تحتاج إلى ملفها arabic، عبر الكتلة arabic
يقدّم Fontsource الخطوط Amiri وNoto Naskh Arabic وScheherazade New في ملف لكل مجموعة فرعية، والحروف العربية في ملف arabic. لا يجلب loadFonts إلا latin (وlatin-ext)، فيأتي النص العربي على الشاشة من خط النظام ويُقاس خطأً، ويسلّم fontsourceProvider ملف latin ذاك إلى PDF، فيطبع مربعات فارغة. اذكر كتلة الأدوات arabic، واستدعِ loadArabicFonts(FONTS, markdown) بعد loadFonts، مع ذكر كل وزن تضع به الصفحاتُ نصًا عربيًا في FONTS، وأعطِ renderToPdf القيمة fontProvider: arabicPdfProvider. الخطوط العربية →
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- 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)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


