باختصار
الصفحة الأولى وصفحة داخلية من صحيفة عربية. يبدأ الخبر في العمود الأيمن ويكمل في الأيسر، كما يقرأ القارئ العربي الصفحة.
ما الذي ستنضده
صفحتان من الساحل، صحيفة يومية متخيَّلة لمدينة ساحلية متخيَّلة، بقطع نصفي قياسه 246 × 328 مم. في الصفحة الأولى اسم الصحيفة بخط Aref Ruqaa بحجم 84 pt، والخبر الرئيسي عن الترام الجديد في المدينة تحت عنوان بعرض الصفحة وخريطة مرسومة بالشيفرة، وشريط من ثلاثة أخبار قصيرة في الأسفل. وتفتح الصفحة 2 قسم المحليات تحت لافتة زرقاء، بخمسة أخبار ومواقيت الصلاة لذلك اليوم. كل شيء يُقرأ من اليمين: عمود النص الأول، والأخبار القصيرة، وأعمدة الجدول، وأذنا اسم الصحيفة. وتنضّد الصفحة الأولى الإنجليزية العناصر نفسها من اليسار إلى اليمين.
تجيب هذه الوصفة عن
- أي عمود يأتي أولًا في الصفحة العربية، وكيف أنضد جريدة من عمودين؟
الجواب المختصر
// locale 'ar' mirrors the page: the body's first column is the right one, the story runs down
// it and on at the top of the left one, and the column rule sits between them as before.
const layout = { layoutType: 'double', gutterWidth: mm(6),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
// A headline over both columns is a page-span box without a frame: the columns under it start
// level, right then left, and a box with placement="bottom" closes the page the same way.
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
titleStyle: { ...kufi(9, 700, 'sea'), gap: mm(1.2) }, // the kicker, from the fence's title
marginTop: pt(0), marginBottom: pt(LEAD / 2),
body: { fontFamily: TEXT, fontSize: pt(13), lineHeight: pt(21), textAlign: 'right' } };
المكونات
- الميزات
- عمود واحد أو عمودانالنص من اليمين إلى اليسارالخط الفاصل بين الأعمدةإطارات بعرض الصفحةأعمدة داخل الإطار أو النصإطارات عائمةصفحات افتتاح مصمَّمةأنماط العناوينسمات العنوانالنصوص والخطوط والمربعات في تصاميم الصفحةالخطوط العربيةالعربية لغةً للمستندأشكال الأرقام في الأعداد المولَّدةالترويسات وأرقام الصفحاتلوحة ألوان دلاليةإطارات التنبيهأنماط الفقراتالتصدير إلى PDF
- تستخدم أيضًا
- فقرات بالاتجاه المعاكسأشكال في هذا الموضع بالضبطشريط فصل بعرض الصفحةلون الورقالخطوط المضمَّنة في PDFأنواع موارد مخصّصةالأشكال والجداول بوصفها مواردكتب مجلّدة من اليمينترويسات لكل قسم
- الخطوط
- Aref Ruqaa, Noto Kufi Arabic, Noto Naskh Arabic (SIL OFL 1.1)
- الأصول
- لا شيء: كل صورة مرسومة بالشيفرة
طريقة التحضير
#1 · عمودان، الأول على اليمين
الشيفرة هي الجواب المختصر أعلاه. layoutType: 'double' والخط الفاصل بين العمودين هما الإعدادان نفساهما في صحيفة إنجليزية؛ وlocale: 'ar' يقلب الصفحة، فيملأ الخبر العمود الأيمن أولًا ويكمل في رأس العمود الأيسر (ترتيب الصفحات والتجليد على اليمين). العنوان الممتد على العمودين إطار بعرض الصفحة بلا حدود، والعمودان تحته يبدآن على مستوى واحد. وشريط «باختصار» إطار بعرض الصفحة يطفو إلى أسفلها وفي داخله :::columns{count=3}، وأعمدته تجري من اليمين إلى اليسار أيضًا، شأنها شأن جدول مواقيت الصلاة في الصفحة 2: الجدول المنضّد في اتجاه المستند يضع عموده الأول على اليمين.
#2 · اسم الصحيفة بين أذنين
const ear = (id, side, lines) => lines.map(([key, content, look], i) => text(`${id}-${key}`,
content, { ...look, align: side }, { ...(i === 0 ? at('container', `top-${side}`, 0, 4)
: at(`#${id}-${lines[i - 1][0]}`, 'below', 0, 1)), size: { width: mm(48) } }));
const nameplate = { enabled: true, minHeight: mm(46), slot: { elements: [
text('name', '{titleText}', { fontFamily: NAME, fontSize: pt(84), fontWeight: 700,
lineHeight: 1.1, color: col('sea'), align: 'center' },
{ ...at('container', 'top', 0, -3), size: { width: 'fill' } }),
// In the mirrored page, 'right' is the start of the line: issue and date there, price opposite.
...ear('start', 'right', [['k', '{attr.issue}', kufi(8, 700, 'sea')],
['d', '{publishDate}', kufi(9, 400)]]),
...ear('end', 'left', [['k', '{attr.city}', kufi(8, 700, 'sea')],
['p', '{attr.price}', kufi(9, 400)]]),
{ kind: 'rule', id: 'thick', thickness: pt(2.5), color: col('ink'),
placement: { ...at('container', 'top-left', 0, 40), size: { width: 'fill' } } },
{ kind: 'rule', id: 'thin', thickness: pt(0.5), color: col('ink'),
placement: { ...at('#thick', 'below', 0, 0.8), size: { width: 'fill' } } },
] } };
العنوان من المستوى الأول في الصفحة الأولى هو اسم الصحيفة، يرسمه نمط عنوان. يُرسم تصميمه في الصفحة المعكوسة، فيكون top-right بداية السطر: هناك يوضع رقم العدد والتاريخ، والمدينة والسعر في الطرف الآخر (معنى اليسار واليمين والبداية والنهاية). خط الرقعة خط عرض لكلمات قليلة بحجم كبير؛ لا كشيدة فيه، ولا يُستعمل في النص أبدًا.
#3 · لافتات الأقسام وأسطر أرقام الصفحات
const flag = { enabled: true, minHeight: mm(13), slot: { elements: [
{ kind: 'rule', id: 'bar', thickness: pt(3), color: col('ink'),
placement: { ...at('container', 'top-left', 0, 9), size: { width: 'fill' } } },
text('flag', '{titleText}', { ...kufi(12, 700, 'paper'), align: 'right',
box: { backgroundColor: col('sea'), padding: { top: mm(1), right: mm(3), bottom: mm(1.4),
left: mm(3) } } }, at('#bar', 'above')),
] } };
// The folio line keeps its physical sides: the number at the outer corner of each page.
const folio = (parity, edge, x) => ({ kind: 'text', id: `n-${parity}`, parity,
content: '{pageNumber} · {title} · {publishDate}', ...kufi(8, 600, 'muted'),
align: edge, placement: at('page', `top-${edge}`, x, 7) });
const header = { elements: [folio('even', 'right', -SIDE), folio('odd', 'left', SIDE),
{ kind: 'rule', id: 'folio-rule', thickness: pt(0.5), color: col('rule'),
placement: { ...at('page', 'top-left', SIDE, 11.5),
size: { width: mm(TRIM.width - 2 * SIDE) } } }] };
تنفتح الصفحة الداخلية بعنوان من المستوى الأول مرسوم لافتةً فوق خط سميك. وسطر رقم الصفحة ترويسة، فيحتفظ بجوانبه الفعلية: الصفحة 2، وهي زوجية، رقمها عند الزاوية اليمنى، وهي الخارجية في صحيفة تنفتح من اليمين. وتُخلي الصفحة الأولى الترويسة في نمط عنوانها.
#4 · خريطة مرسومة بالكود
function routeSvg() { // 222 × 44 mm, 1 unit = 1 mm
const [W, H] = [222, 44];
const coast = 'M0 36C30 33 52 40 80 35S128 24 152 28S196 37 222 31V44H0Z';
// Eighteen stations along a line that leaves the port (east, on the right) for the university.
const line = 'M210 22C186 17 170 13 150 16S112 25 92 20S56 9 34 12S14 19 10 17';
const stops = Array.from({ length: 18 }, (_, i) => i / 17);
const pointAt = (t) => { // the line as three cubic pieces, sampled per piece
const seg = [[210, 22, 186, 17, 170, 13, 150, 16], [150, 16, 130, 19, 112, 25, 92, 20],
[92, 20, 72, 15, 56, 9, 34, 12], [34, 12, 22, 14, 14, 19, 10, 17]];
const k = Math.min(3, Math.floor(t * 4));
const u = t * 4 - k;
const [x0, y0, x1, y1, x2, y2, x3, y3] = seg[k];
const b = (a, c, d, e) => (1 - u) ** 3 * a + 3 * (1 - u) ** 2 * u * c + 3 * (1 - u) * u * u * d
+ u ** 3 * e;
return [b(x0, x1, x2, x3), b(y0, y1, y2, y3)];
};
const rings = stops.map((t, i) => {
const [x, y] = pointAt(t);
const big = i === 0 || i === 17 || i === 8;
return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="${big ? 2.6 : 1.6}" `
+ `fill="${palette.paper}" stroke="${palette.ink}" stroke-width="${big ? 1 : 0.7}"/>`;
}).join('');
let grid = '';
for (let x = 6; x < W; x += 12) grid += `M${x} 0V${H}`;
for (let y = 6; y < H; y += 12) grid += `M0 ${y}H${W}`;
return `<svg xmlns="http://www.w3.org/2000/svg" width="${W * 10}" height="${H * 10}" `
+ `viewBox="0 0 ${W} ${H}"><rect width="${W}" height="${H}" fill="${palette.sand}"/>`
+ `<path d="${grid}" stroke="${palette.paper}" stroke-width="0.6"/>`
+ `<path d="${coast}" fill="${palette.sea}" fill-opacity="0.25"/>`
+ `<path d="${line}" fill="none" stroke="${palette.sea}" stroke-width="2.4"/>${rings}</svg>`;
}
خريطة الترام صورة SVG من مسارات ودوائر بألوان لوحة الألوان، ولا نص فيها: تبقى أسماء الأماكن في التعليق، بخط الصفحة. ونوع الصور بلا عدّاد ولا تسمية، لأن الصحف لا ترقّم صورها.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 108 · A two-column Arabic newspaper page ══════════════════
// https://postext.dev/en/cookbook/arabic-newspaper-two-columns
// Code: MIT · Text: original Arabic news copy (CC BY 4.0) · Map: drawn in code
// Fonts: Aref Ruqaa, Noto Kufi Arabic, Noto Naskh Arabic (SIL OFL 1.1) · Needs postext ≥ 1.65.0
import {
buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'en'; // @lang: the language of the frame; the paper is Arabic in both editions
const RECIPE = 'arabic-newspaper-two-columns';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: newsprint, a cold ink and the sea blue of the paper's name
const palette = {
ink: '#121416', // text and the heavy rules
sea: '#0f5f7a', // the accent: the nameplate, section flags, kickers, the tram line
sand: '#e9e2d2', // the In brief strip and the map's land
rule: '#9b988f', // hairlines: the column rule, the folio line
muted: '#5b5852', // bylines, captions' credits, the imprint
paper: '#f8f5ee', // newsprint, and type reversed out of the flags
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.ink })
.map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const [NAME, HEAD, TEXT] = ['Aref Ruqaa', 'Noto Kufi Arabic', 'Noto Naskh Arabic'];
const TRIM = { width: 246, height: 328 }; // mm: a 3 : 4 compact
const SIDE = 12; // mm: newspaper margins, narrow and not mirrored
const LEAD = 16; // pt: the body leading, 1.5 × an 10.7 pt Naskh
const kufi = (size, weight, colour = 'ink') => ({ fontFamily: HEAD, fontSize: pt(size),
fontWeight: weight, color: col(colour) });
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, look, placement) => ({ kind: 'text', id, content, overflow: 'wrap',
...look, placement });
// #region answer: two columns, the first one on the right
// locale 'ar' mirrors the page: the body's first column is the right one, the story runs down
// it and on at the top of the left one, and the column rule sits between them as before.
const layout = { layoutType: 'double', gutterWidth: mm(6),
columnRule: { enabled: true, color: col('rule'), lineWidth: pt(0.5) } };
// A headline over both columns is a page-span box without a frame: the columns under it start
// level, right then left, and a box with placement="bottom" closes the page the same way.
const banner = { id: 'banner', backgroundEnabled: false, span: 'page',
padding: { top: pt(0), right: pt(0), bottom: pt(0), left: pt(0) },
titleStyle: { ...kufi(9, 700, 'sea'), gap: mm(1.2) }, // the kicker, from the fence's title
marginTop: pt(0), marginBottom: pt(LEAD / 2),
body: { fontFamily: TEXT, fontSize: pt(13), lineHeight: pt(21), textAlign: 'right' } };
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#ثلاثة أعمدة في الأخبار القصيرة، وأربعة في صفحة أعرض
الشريط إطار له أعمدته الخاصة، فيمكن أن يزيد على عمودي النص.
-:::columns{count=3 breaks="2,3"}
+:::columns{count=4 breaks="2,3,4"}#أرقام أوروبية لصحيفة مغاربية
- locale: 'ar', // written out, never LANG (gotcha: arabic-locale-tag): rtl, digits ٠–٩
+ locale: 'ar-MA', // rtl, digits 0–9أخطاء شائعة
خطأ شائع
اوسم الكتاب العربي بـ '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. الخطوط العربية →
- مواقيت الصلاة مكتوبة بالأرقام العربية المشرقية في خلايا الجدول: لا يغيّر
localeإلا الأعداد التي يكتبها المحرّك، فالطبعة المغاربية تعيد كتابتها.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- Two pages of an imaginary Arabic daily, الساحل, and its city, written in Arabic for the recipe · Postext Cookbook · أصلي
- الخطوط
- Aref Ruqaa (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


