باختصار
وحدة من كتاب مدرسي عن نهر، في تسع صفحات. كل موضوع صفحتان متقابلتان على أرضية ملوّنة، بلسان للعنوان ونص وصور وإطارات. لا كلمة على الخريطة، وأسماؤها كلها من النص. وتتفاوت اللغات في الطول وتتسع لها القوالب نفسها.
ما الذي ستنضده
تسع صفحات من نهرنا، الوحدة 4 من كتاب مُتخيَّل للعلوم الاجتماعية للصف الثالث، على صفحة 210 × 280 مم، بعشر لغات: الإسبانية والكتالونية والإنجليزية والبرتغالية والفرنسية والألمانية والإيطالية والعربية والصينية واليابانية. يفتح الوحدةَ وادٍ مرسوم، وتسرد صفحة الفهرس جزأين، ثم تأتي ثلاثة موضوعات صفحتين متقابلتين، لكل منها أرضيتها: زرقة الماء، وخضرة الحقل، ورمل الشمس. في كل موضوع لسان فيه الرقم والعنوان، ونص في عمودين، وإطارات بألسنة تطول مع نصها. الموضوع الثاني خريطة مرسومة واحدة تمتد على الصفحتين، وتُسمّى عليها النهر والقرى والمجاري الثلاثة من Markdown، ويمتد خط من كل إطار مجرى إلى مقطعه من النهر. وما يتكرر يُرسم مرة واحدة: يضع القالب بطاقة صورة وإطار مجرى وإطارًا بصورة بقدر ما يطلب Markdown، والأسئلة الثلاثة في أول الوحدة ثلاثة استعمالات لوحدة نمطية واحدة. تختلف النصوص في الطول بخُمس أو أكثر وتتسع لها القوالب نفسها: يأخذ الإطار الارتفاع الذي تطلبه كلماته ويدفع الذي يليه إلى الأسفل، وتصغر الخريطة قليلًا قبل أي نص. يجري الكتاب العربي من اليمين إلى اليسار، ويجري الكتابان الصيني والياباني من أعلى الصفحة إلى أسفلها؛ والثلاثة تُجلَّد من اليمين وتُقرأ في كل صفحتين متقابلتين من الصفحة اليمنى إلى اليسرى.
تجيب هذه الوصفة عن
- كيف أنضّد وحدة من كتاب مدرسي بثلاث لغات بقوالب الصفحة نفسها، وطول النص يختلف من لغة إلى أخرى؟
- كيف أجعل إطارات الصفحة تطول مع نصها وتدفع الإطارات التي تحتها إلى الأسفل؟
- كيف أضع أسماء الخريطة من النص، بحيث تغيّر الترجمة الكلمات ولا تمسّ الرسم؟
الجواب المختصر
// Ground, tab and number are decoration anchored to the title frame; the number,
// `{headingNumber}`, stands over the padding before its words. A topic extends the base.
const ground = () => ({ kind: 'box', id: 'ground',
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } },
style: { backgroundColor: col('tema-ground') } });
const titleTab = () => ({ kind: 'box', id: 'tab', placement: { ...at('#titulo',
'top-left'), size: { width: { to: '#titulo', edge: 'right' }, height: { to: '#titulo',
edge: 'bottom' } } }, style: { backgroundColor: col('tema'), borderRadius: mm(4) } });
const badge = () => ({ kind: 'text', id: 'number', content: '{headingNumber}',
fontFamily: DISPLAY, fontSize: pt(22), fontWeight: fw(700), color: col('tema'), align: 'center',
box: { backgroundColor: col('paper'), borderRadius: mm(6) }, placement: { ...at('#titulo',
corner('top'), inward(CJK ? 2.6 : 5), CJK ? 5 : 2.4), size: { width: mm(12), height: mm(12) } },
});
const title = { name: 'titulo', takes: 'h1', style: 'titulo', width: mm(MEASURE),
placement: at('container', 'top-left') };
const base = {
id: 'tema', spread: true, gutter: mm(12),
decoration: { elements: [ground(), titleTab(), badge()] },
frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
width: mm(MEASURE), fit: { minScale: 0.9 } }],
groups: [{ name: 'izquierda', kind: 'stack', gap: mm(6), frames: ['titulo', 'texto'] }],
};
const topic = (id, f, more) => ({ id, extends: 'tema', palette: swap(f), ...more });
const box = (name, style, minHeight, more) => ({ name, style, width: mm(MEASURE),
minHeight: mm(minHeight), ...more });
const answer = (name, lines) => ({ name, optional: true, style: 'respuesta', width: mm(MEASURE),
height: mm(LINE * lines), minHeight: mm(LINE * lines),
rules: { every: mm(LINE), color: col('rule'), width: pt(0.75) } });
const PIC = CJK ? 30 : 56; // a picture at the end of a box's first lines pushes the text aside
const withPic = (name, style, minHeight, more) => [box(name, style, minHeight,
{ padding: { right: mm(PIC + 8) }, ...more }), { name: `${name}-foto`, layer: 2, width: mm(PIC),
exclude: 'push', placement: at(`#${name}`, 'top-right', -5, 8) }];
المكونات
- الميزات
- الصفحات المركّبةشبكات تكرّر الإطاراتوحدات مكدّسة في صفحةخطوط الإشارة ومفاتيح الأشكالإطارات تكبر داخل مجموعةألسنة الإطارات المرقّمةتسميات على الصورةجدول المحتوياتقوالب الصفحتين المتقابلتينإطارات التنبيهالنصوص والخطوط والمربعات في تصاميم الصفحةالصور في تصاميم الصفحةتثبيت عناصر التصميمزخرفة مثبّتة بالإطاراتهوامش متناظرةالترويسات وأرقام الصفحاتأنماط العناوينلوحة ألوان دلاليةالأشكال والجداول بوصفها موارد
- تستخدم أيضًا
- أشكال الأرقام في الأعداد المولَّدةإطارات تزيح النص بصندوقها أو بمحيطهاسمات العنوانصفحات فواصل الأجزاءالتصدير إلى PDFالخطوط المضمَّنة في PDFأنواع موارد مخصّصةكتب مجلّدة من اليمينالنص من اليمين إلى اليسارفصول بلا أرقام
- الخطوط
- Nunito, Fredoka, Noto Naskh Arabic, Baloo Bhaijaan 2, Klee One, Zen Maru Gothic, Noto Serif SC, ZCOOL KuaiLe (SIL OFL 1.1)
- الأصول
arroyo-720.jpgcascada-720.jpglimpieza-720.jpgmapa-1900-rtl.jpgmapa-1900.jpgmolino-720.jpgnacimiento-720.jpgpiraguas-720.jpgportada-1400.jpgriego-720.jpg- The valley of the River Aldara, painted from the mountains to the sea, with two children watching the water. (Generated With Diffusion Models, أصلي)
- The painted map of the valley, from the spring to the port, with no lettering: the names are labels set from the Markdown. (Generated With Diffusion Models, أصلي)
- The same painted map mirrored, the mountains on the right, for the books bound on the right (Arabic, Chinese, Japanese). (Generated With Diffusion Models, أصلي)
- A spring between mossy rocks. (Generated With Diffusion Models, أصلي)
- A mountain stream over round stones. (Generated With Diffusion Models, أصلي)
- A small waterfall into a green pool. (Generated With Diffusion Models, أصلي)
- A farmer opening the gate of an irrigation canal. (Generated With Diffusion Models, أصلي)
- An old stone watermill with its wheel. (Generated With Diffusion Models, أصلي)
- Children paddling canoes on a calm river. (Generated With Diffusion Models, أصلي)
- Children and a teacher picking up litter on a river bank. (Generated With Diffusion Models, أصلي)
طريقة التحضير
#1 · اعرف من أي جانب تبدأ كل لغة
// Arabic runs right to left, Chinese and Japanese down the page, all bound on the right. Frames
// stand in the flow (x along the lines, mirrored in Arabic, down the page when vertical).
const AR = LANG === 'ar', CJK = LANG === 'zh' || LANG === 'ja';
const RIGHT_BOUND = AR || CJK, LATIN = !RIGHT_BOUND; // italics, capitals, tracking, hyphens
const [TEXT, DISPLAY] = { ar: ['Noto Naskh Arabic', 'Baloo Bhaijaan 2'], ja: ['Klee One',
'Zen Maru Gothic'], zh: ['Noto Serif SC', 'ZCOOL KuaiLe'] }[LANG] ?? ['Nunito', 'Fredoka'];
const START = RIGHT_BOUND ? 'right' : 'left'; // the side a page starts reading from
const corner = (v) => `${v}-${START}`, inward = (x) => (RIGHT_BOUND ? -x : x);
const [SLANT, CAPS] = LATIN ? ['italic', 'uppercase'] : ['normal', 'none'];
const LEAD = AR ? 20 : CJK ? 21 : 17.5, track = (v) => (LATIN ? v : 0); // Naskh, ruby need room
const fw = (w) => ({ 'ZCOOL KuaiLe': 400, 'Zen Maru Gothic': w > 550 ? 700 : 500 })[DISPLAY] ?? w;
const BOLD = TEXT === 'Klee One' ? 600 : 700; // and the weights the faces have
تقف إطارات القالب في نظام إحداثيات التدفق في الصفحة، حيث يجري x على امتداد الأسطر. ومع locale: 'ar' يعكس المحرك هذا النظام، فيستعمل الكتاب العربي الإطارات اللاتينية بلا تغيير: يأتي العنوان أولًا في الصفحة اليمنى، وتجري الصور الثلاث وإطارات المجاري الثلاثة من اليمين إلى اليسار، وتتبع ألسنة الإطارات وأشرطتها وحشواتها الأسطر. ومع layout.writingMode: 'vertical-rl' يجري x إلى أسفل الصفحة وy من اليمين إلى اليسار: فيصير width الإطار طولًا إلى الأسفل، وتتقدّم المجموعة نحو اليسار، وتعطي columns: 2 طبقتين (段) من 27 حرفًا، والإطار الموضوع below إطار آخر يقف على يساره. أما الزخرفة (الأرضيات، ولسان العنوان، والرقم، والترويسات، وأرقام الصفحات) فتقف على الورقة نفسها، ولذلك تُوضع بدءًا من START، الجانب الذي تبدأ منه قراءة الصفحة. ولكل كتابة خط للنص وخط مستدير للعناوين، ولا تستعمل الطبعات العربية والصينية واليابانية مائلًا ولا أحرفًا كبيرة ولا تباعدًا بين الحروف.
#2 · ابنِ الإطارات بـ extends
// Two steps of `extends`: the box (shape, type, tab), then the kind. The colours are `tema`
// entries, so one style serves the three topics; paddings, stripes and tabs are in the flow.
const tab = (f) => ({ position: 'top-left', background: col(f), color: col('paper'),
fontFamily: DISPLAY, fontSize: pt(12), fontWeight: fw(600), height: mm(7), paddingX: mm(3.2),
offset: mm(7), inset: mm(5), rule: { enabled: false, color: col(f) } });
const boxText = { fontFamily: TEXT, fontSize: pt(12), lineHeight: pt(LEAD), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), boldFontWeight: BOLD, firstLineIndent: pt(0),
textAlign: CJK ? 'justify' : 'left', paragraphSpacing: true };
const calloutStyles = [
{ id: 'caja', backgroundEnabled: true, background: col('paper'), borderRadius: mm(3),
border: { enabled: false }, padding: { top: mm(3.4), right: mm(5), bottom: mm(4), left: mm(5) },
body: boxText, lists: { color: col('ink'), gap: mm(2), itemSpacing: mm(1.6) } },
{ id: 'caja-tema', extends: 'caja', label: tab('tema'), lists: { color: col('tema') } },
{ id: 'dato', extends: 'caja-tema', background: col('tema-tint') },
{ id: 'palabras', extends: 'caja-tema', border: { enabled: true, color: col('tema'),
width: pt(1.4) } }, { id: 'actividad', extends: 'caja-tema',
stripe: { enabled: true, side: 'left', width: pt(4), color: col('tema') } },
{ id: 'titulo', extends: 'caja', backgroundEnabled: false,
padding: { top: mm(2.6), right: mm(6), bottom: mm(3.2), left: mm(TAB) } },
{ id: 'titulo-plano', extends: 'titulo', padding: { left: mm(8) } },
{ id: 'portada', extends: 'caja', background: col('agua'), borderRadius: mm(4),
padding: { top: mm(2.6), right: mm(8), bottom: mm(3.6), left: mm(8) } },
{ id: 'foto', extends: 'caja', borderRadius: mm(2),
padding: { top: mm(1.8), right: mm(1.8), bottom: mm(2.2), left: mm(1.8) } },
{ id: 'respuesta', extends: 'caja', padding: NONE }, { id: 'colofon', extends: 'caja',
backgroundEnabled: false, padding: NONE,
body: { ...boxText, fontSize: pt(8), lineHeight: pt(AR ? 13 : 11), color: col('muted') } },
];
يُبنى نمط الإطار في ثلاث خطوات. يحدّد caja الشكل والخط وهندسة اللسان؛ ثم يضع caja-tema لون الموضوع على اللسان والنقاط؛ ثم تحدّد dato وpalabras وactividad النوع: إطار ملوّن الخلفية، أو ذو حدّ، أو ذو شريط. وألوانها مداخل في لوحة الألوان (tema وtema-tint)، فيُكتب كل نمط مرة واحدة ويلوّنه قالب الموضوع.
#3 · اجعل كل موضوع يرث قالبًا أساسيًا واحدًا
// Ground, tab and number are decoration anchored to the title frame; the number,
// `{headingNumber}`, stands over the padding before its words. A topic extends the base.
const ground = () => ({ kind: 'box', id: 'ground',
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: 'fill' } },
style: { backgroundColor: col('tema-ground') } });
const titleTab = () => ({ kind: 'box', id: 'tab', placement: { ...at('#titulo',
'top-left'), size: { width: { to: '#titulo', edge: 'right' }, height: { to: '#titulo',
edge: 'bottom' } } }, style: { backgroundColor: col('tema'), borderRadius: mm(4) } });
const badge = () => ({ kind: 'text', id: 'number', content: '{headingNumber}',
fontFamily: DISPLAY, fontSize: pt(22), fontWeight: fw(700), color: col('tema'), align: 'center',
box: { backgroundColor: col('paper'), borderRadius: mm(6) }, placement: { ...at('#titulo',
corner('top'), inward(CJK ? 2.6 : 5), CJK ? 5 : 2.4), size: { width: mm(12), height: mm(12) } },
});
const title = { name: 'titulo', takes: 'h1', style: 'titulo', width: mm(MEASURE),
placement: at('container', 'top-left') };
const base = {
id: 'tema', spread: true, gutter: mm(12),
decoration: { elements: [ground(), titleTab(), badge()] },
frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
width: mm(MEASURE), fit: { minScale: 0.9 } }],
groups: [{ name: 'izquierda', kind: 'stack', gap: mm(6), frames: ['titulo', 'texto'] }],
};
const topic = (id, f, more) => ({ id, extends: 'tema', palette: swap(f), ...more });
const box = (name, style, minHeight, more) => ({ name, style, width: mm(MEASURE),
minHeight: mm(minHeight), ...more });
const answer = (name, lines) => ({ name, optional: true, style: 'respuesta', width: mm(MEASURE),
height: mm(LINE * lines), minHeight: mm(LINE * lines),
rules: { every: mm(LINE), color: col('rule'), width: pt(0.75) } });
const PIC = CJK ? 30 : 56; // a picture at the end of a box's first lines pushes the text aside
const withPic = (name, style, minHeight, more) => [box(name, style, minHeight,
{ padding: { right: mm(PIC + 8) }, ...more }), { name: `${name}-foto`, layer: 2, width: mm(PIC),
exclude: 'push', placement: at(`#${name}`, 'top-right', -5, 8) }];
القالب الأساسي صفحتان متقابلتان: أرضية حتى منطقة النزف، ولسان عنوان فيه الرقم، ونص في عمودين. يرثه كل موضوع بـextends: 'tema'، ويحدّد palette الخاصة به (تأخذ المداخل الثلاثة tema ألوان العائلة، فتتغير الأرضية واللسان والرقم وكل الإطارات معًا)، ويضيف إطاراته. اللسان والرقم زخرفة مربوطة بإطار العنوان، فيكون اللسان بارتفاع العنوان الذي تطلبه اللغة. والرقم هو {headingNumber}، عدّاد العنوان الذي أخذه الإطار، مرسومًا فوق حشوة الإطار التي تسبق كلماته: لا تكرّره كتلة صفحة، والنقر عليه يصل إلى الرقم لا إلى الإطار.
#4 · ارسم مرة واحدة ما يتكرر
const grid = (name, frames, columns, placement, more, width = MEASURE) => ({ name, kind: 'grid',
columns, columnGap: mm(5), rowGap: mm(CJK ? 8 : 12), repeat: { frames },
placement: { ...placement, size: { width: mm(width), height: 'fill' } }, ...more });
const question = { id: 'pregunta', role: 'module', // a question and the lines to answer it on
frames: [box('caja', 'dato', CJK ? 22 : 14, { width: 'fill' }), { ...answer('lineas',
CJK ? 2 : 3), width: 'fill', placement: at('#caja', 'below', 0, CJK ? 4 : 7) }] };
تكرّر المجموعة الشبكية طقمًا من الإطارات مرة لكل عنصر في الصفحة. شريط الصور هو grid('fotos', ['foto'], 3, …): ثلاث كتل :::figure{slot="foto"} تعطي ثلاث بطاقات، اسمها من #foto[1] إلى #foto[3]، ويتدلّى إطار «جرّب بنفسك» تحت #foto[1]. وإطارات موضوع الشمس شبكة من عمود واحد طقمها إطار وصورته (['uso', 'uso-foto']): يحمل كل :::frame{slot="uso"} كلماته، وفي داخله :::figure{slot="uso-foto"} الذي يرافقها. وصفحة الأسئلة تكدّس وحدة نمطية: pregunta قالب بـrole: 'module'، فيه إطار ملوّن الخلفية وأسطر للإجابة، وتضع مجموعة preguntas في الصفحة (modules: true) واحدة لكل :::module{template="pregunta"} في Markdown. الإطار بارتفاع كلماته ولا ينزل عن minHeight، فيدفع النص الإسباني الأطول الصفوفَ التي تحته إلى الأسفل، وحين يضيق المكان على صفحة يصغّر سلّم الملاءمة الخريطة والصور قبل النص، حتى 90 %.
وإطارات المجاري شبكة من ثلاثة تحت الخريطة (grid('cursos', ['curso'], 3, …))، إطار لكل :::frame{slot="curso"}. وتسمّي الخريطة المقاطع الثلاثة نفسها بعناوين من نمط curso، على خضرة ألسنة الإطارات، فيجد القارئ مقطع كل إطار باسمه ولونه. وفي الصفحة العمودية تقف المجاري في عمود واحد بجوار الخريطة.
#5 · ضع أسماء الخريطة من النص
// An anchor is a point of the painting (fractions of its width and height) and a label style;
// every language's ::label lines use the same anchors. A right-bound book shows the painting
// mirrored, the mountains on the right, so the river runs the way its pages are read: x comes
// from the other edge and a turn goes the other way. `start` is a label's own start, so the
// spring's label keeps it in Arabic and takes `end` in a label set left to right.
const halo = { color: col('paper'), width: pt(1.8) };
const labelStyles = [
{ id: 'sierra', fontFamily: DISPLAY, fontSize: pt(13), fontWeight: fw(600), color: col('ink'),
textTransform: CAPS, letterSpacing: track(0.14), halo },
{ id: 'agua', fontFamily: TEXT, fontSize: pt(11), fontWeight: BOLD, fontStyle: SLANT,
color: { hex: '#0b3a5c', model: 'hex' }, halo, // a name set away draws a leader to its point
leader: { width: pt(1), endCap: 'dot', capSize: mm(1.6) } },
{ id: 'mar', fontFamily: TEXT, fontSize: pt(12), fontWeight: BOLD, fontStyle: SLANT,
color: col('paper'), halo: { color: { hex: '#0b3a5c', model: 'hex' }, width: pt(1.8) } },
{ id: 'pueblo', fontFamily: DISPLAY, fontSize: pt(12), fontWeight: fw(600), color: col('ink'),
halo },
{ id: 'curso', fontFamily: DISPLAY, fontSize: pt(10.5), fontWeight: fw(600), color: col('paper'),
textTransform: CAPS, letterSpacing: track(0.08), background: col('campo'),
padding: mm(1.6) },
];
const ANCHORS = [
{ id: 'sierra', x: 0.21, y: 0.055, style: 'sierra' },
// The spring and the dam: the point is the place, `labelAt` where its name stands.
{ id: 'nacimiento', x: 0.049, y: 0.098, labelAt: { x: 0.075, y: 0.115 }, style: 'agua',
align: 'start' },
{ id: 'fontalba', x: 0.135, y: 0.255, style: 'pueblo', verticalAlign: 'top' },
{ id: 'embalse', x: 0.293, y: 0.275, labelAt: { x: 0.31, y: 0.155 }, style: 'agua',
width: 0.12 },
{ id: 'molinar', x: 0.505, y: 0.35, style: 'pueblo', verticalAlign: 'bottom' },
{ id: 'aldamar', x: 0.845, y: 0.505, style: 'pueblo', verticalAlign: 'bottom' },
{ id: 'mar', x: 0.965, y: 0.28, style: 'mar' },
{ id: 'rio', x: 0.61, y: 0.715, style: 'agua', rotate: -3 },
{ id: 'alto', x: 0.17, y: 0.45, style: 'curso' },
{ id: 'medio', x: 0.4, y: 0.77, style: 'curso' },
{ id: 'bajo', x: 0.74, y: 0.865, style: 'curso' },
];
const flip = (x) => Math.round((1 - x) * 1000) / 1000;
const flipped = (a) => ({ ...a, x: flip(a.x), ...(a.labelAt && { labelAt: { ...a.labelAt,
x: flip(a.labelAt.x) } }),
...(a.rotate && { rotate: -a.rotate }), ...(a.align && !AR && { align: 'end' }) });
const anchors = RIGHT_BOUND ? ANCHORS.map(flipped) : ANCHORS;
الخريطة لوحة بلا حرف واحد. كل مكان مرساة في الصورة، نقطة بكسور من العرض والارتفاع مع نمط تسمية، وكل طبعة تكتب أسطر ::label الخاصة بها عند هذه المراسي. تقف Penalta Reservoir وPantà de Penyalta وEmbalse de Peñalta في المكان نفسه، والاسم الأطول ينكسر داخل width المرساة. ويعرض الكتاب المجلّد من اليمين اللوحة نفسها معكوسة (mapa-1900-rtl.jpg)، فيجري النهر من الجبال على اليمين إلى البحر على اليسار، في الاتجاه الذي تُقرأ به صفحاته؛ وتنقل flipped كل مرساة، والموضع الذي تُوضع فيه تسميتها، إلى الجانب الآخر وتدير الدوران في الاتجاه المعاكس. ويُوضع المنبع وخزان بنيالتا بعيدًا عن مكانيهما بـlabelAt، ويرسم leader النمط agua خطًّا بنقطة من الاسم إلى النبع وإلى السد.
#6 · أبقِ كل جزء من الفهرس متماسكًا
const partAt = (x) => (CJK ? at('container', 'left', x) : at('container', START, inward(x)));
const toc = {
levels: [{ level: 1, fontFamily: DISPLAY, fontSize: pt(15), lineHeight: pt(22),
fontWeight: fw(500), color: col('ink'), numberFontWeight: fw(600), numberColor: col('agua'),
numberWidth: mm(9), marginTop: pt(4) }, { level: 2, fontFamily: TEXT, fontSize: pt(11.5),
lineHeight: pt(18), indent: mm(9), color: col('ink') }],
pageNumber: { fontFamily: DISPLAY, fontWeight: fw(500), width: mm(9), color: col('agua') },
leader: { char: CJK ? '…' : '.', gap: mm(1.5) },
parts: { height: pt(34), marginTop: pt(12), marginBottom: pt(4), design: { elements: [
{ kind: 'box', id: 'band',
placement: { ...at('container', 'top-left'), size: { width: 'fill', height: 'fill' } },
style: { backgroundColor: col('paper'), borderRadius: mm(3) } },
{ kind: 'text', id: 'letter', content: '{number}', fontFamily: DISPLAY, fontSize: pt(16),
fontWeight: fw(700), color: col('paper'), align: 'center',
box: { backgroundColor: col('agua'), borderRadius: mm(4) },
placement: { ...partAt(2), size: { width: mm(8), height: mm(8) } } },
{ kind: 'text', id: 'name', content: '{titleText}', fontFamily: DISPLAY, fontSize: pt(13),
fontWeight: fw(600), color: col('agua'), align: START, placement: partAt(14) },
] } },
};
يسرد :::toc{keep="part" levels="1-2"} الموضوعات وفقراتها ويُبقي صف كل جزء مع مداخله. وكتلة :::part مع parts.page: false ليست إلا صفًّا في جدول المحتويات وقسمًا للترويسات، فلا يضيف صفحة فاصلة. وجدول المحتويات صفحة مركّبة: في قالبها إطار بـtakes: "toc" يستقبل :::toc ويُنضّده بقواعد جدول المحتويات نفسها، فتعمل صفوف الأجزاء والنقاط الإرشادية وkeep كما في النص المتصل، وتكون الأرضية الفاتحة زخرفة القالب.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 156 · A children's textbook unit in ten languages ═════
// https://postext.dev/en/cookbook/children-textbook-pages
// Code: MIT · Text: original (CC BY 4.0) · Pictures: generated with diffusion models
// Fonts: Nunito, Fredoka and three pairs for Arabic, Chinese, Japanese · Needs postext ≥ 1.65.0
import {
buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
loadVerticalAlternates,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'ar'; // @lang: the language of the unit (es en ca pt fr de it ar zh ja)
const RECIPE = 'children-textbook-pages';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// One ink and three families (accent, box tint, page ground); a topic swaps the `tema` entries.
const FAMILIES = {
agua: { main: '#1b6aa0', tint: '#e1f0fa', ground: '#d3e8f6' },
campo: { main: '#336f27', tint: '#e5f1dc', ground: '#d9ebcb' },
sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
};
const palette = { ink: '#1d2f3f', muted: '#4f6272', rule: '#7e98ab', paper: '#ffffff',
agua: FAMILIES.agua.main, campo: FAMILIES.campo.main, // the blue of the folios and the contents
tema: FAMILIES.agua.main, 'tema-tint': FAMILIES.agua.tint, 'tema-ground': FAMILIES.agua.ground };
const swap = (f) => `tema=${FAMILIES[f].main}, tema-tint=${FAMILIES[f].tint}, `
+ `tema-ground=${FAMILIES[f].ground}`;
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: 'water (defaults)', value: { hex: palette.agua, model: 'hex' } },
];
// #region editions: how each language runs and is bound, and the two faces of its script
// Arabic runs right to left, Chinese and Japanese down the page, all bound on the right. Frames
// stand in the flow (x along the lines, mirrored in Arabic, down the page when vertical).
const AR = LANG === 'ar', CJK = LANG === 'zh' || LANG === 'ja';
const RIGHT_BOUND = AR || CJK, LATIN = !RIGHT_BOUND; // italics, capitals, tracking, hyphens
const [TEXT, DISPLAY] = { ar: ['Noto Naskh Arabic', 'Baloo Bhaijaan 2'], ja: ['Klee One',
'Zen Maru Gothic'], zh: ['Noto Serif SC', 'ZCOOL KuaiLe'] }[LANG] ?? ['Nunito', 'Fredoka'];
const START = RIGHT_BOUND ? 'right' : 'left'; // the side a page starts reading from
const corner = (v) => `${v}-${START}`, inward = (x) => (RIGHT_BOUND ? -x : x);
const [SLANT, CAPS] = LATIN ? ['italic', 'uppercase'] : ['normal', 'none'];
const LEAD = AR ? 20 : CJK ? 21 : 17.5, track = (v) => (LATIN ? v : 0); // Naskh, ruby need room
const fw = (w) => ({ 'ZCOOL KuaiLe': 400, 'Zen Maru Gothic': w > 550 ? 700 : 500 })[DISPLAY] ?? w;
const BOLD = TEXT === 'Klee One' ? 600 : 700; // and the weights the faces have
// #endregion
const PAGE = { w: 210, h: 280, top: 18, bottom: 18, inner: 14, outer: 12 }; // mm, mirrored
const HALF = PAGE.w - PAGE.inner - PAGE.outer, TALL = PAGE.h - PAGE.top - PAGE.bottom; // 184, 244
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#أضف عائلة رابعة
موضوع عن البحر مدخل رابع في FAMILIES وقالب يُصنع بـtopic('tema-mar', 'mar', { frames }). وتكتب swap('mar') لوحته، فتتبعها الإطارات والأرضية.
- sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
+ sol: { main: '#9a5209', tint: '#fcefd2', ground: '#f8e6b8' },
+ mar: { main: '#0f5a6b', tint: '#dcf0f2', ground: '#cbe6ea' },#أبقِ النص بحجمه
الإطار الذي لا يجوز تصغير نصه فيه fit: { shrinkText: false }. فيضغط النص الأطول بقوة أكبر على الإطارات المجاورة وتبلغ خطوات الملاءمة الصور أبكر.
frames: [title, { name: 'texto', flow: true, columns: 2, columnGap: mm(CJK ? 16 : 7), // 段
- width: mm(MEASURE), fit: { minScale: 0.9 } }],
+ width: mm(MEASURE), fit: { shrinkText: false } }],أخطاء شائعة
- اسم مرسوم داخل صورة لا يتغيّر مع اللغة: لا كلمة على الخريطة، وكل اسم تسمية.
- لوحة الموضوع تغيّر مداخل
temaوحدها. أرقام الصفحات وجدول المحتويات تستعملagua، وله الأزرق نفسه، فتبقى زرقاء في الصفحات الخضراء والرملية؛ اربطها بـtemaفتتبع الموضوع. - الرقم الهندي العربي بجوار نقطة وسطى يُقرأ رقمين: يبدو
١ · ماءمثل٠١ ماء، لأن الصفر العربي نقطة. فتكتب الطبعة العربية١- ماء للحقولوتكتب رقم الوحدة بالحروف. - عنصر الزخرفة يقف على الورقة لا في التدفق: الشارة الموضوعة
top-leftفي إطار تبقى على اليسار في العربية. وتضعهاcorner('top')وinward(x)من الجانب الذي تبدأ منه قراءة الصفحة. - في الشبكة كل عنصر كتلة قائمة بذاتها: لا تنتمي صورة الإطار إلى طقمه إلا إذا كُتب
:::figureالخاص بها داخل:::frameالإطار. وإذا كُتبت بعده صارت الصورة عنصرًا مستقلًا وأخذت خلية خاصة بها. - شكلان يضبطان المورد نفسه يأخذان كلمات الأول: الخريطة الصغيرة في الفهرس هي الملف نفسه تحت مورد آخر،
rio، بلا مراسٍ.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- Our river, a children's textbook unit written for this recipe in Spanish and set in ten languages · Postext Cookbook · CC BY 4.0
- الصور
- The valley of the River Aldara, painted from the mountains to the sea, with two children watching the water. · Generated With Diffusion Models · أصلي
- The painted map of the valley, from the spring to the port, with no lettering: the names are labels set from the Markdown. · Generated With Diffusion Models · أصلي
- The same painted map mirrored, the mountains on the right, for the books bound on the right (Arabic, Chinese, Japanese). · Generated With Diffusion Models · أصلي
- A spring between mossy rocks. · Generated With Diffusion Models · أصلي
- A mountain stream over round stones. · Generated With Diffusion Models · أصلي
- A small waterfall into a green pool. · Generated With Diffusion Models · أصلي
- A farmer opening the gate of an irrigation canal. · Generated With Diffusion Models · أصلي
- An old stone watermill with its wheel. · Generated With Diffusion Models · أصلي
- Children paddling canoes on a calm river. · Generated With Diffusion Models · أصلي
- Children and a teacher picking up litter on a river bank. · Generated With Diffusion Models · أصلي
- الخطوط
- Nunito (SIL OFL 1.1) · Fredoka (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1) · Baloo Bhaijaan 2 (SIL OFL 1.1) · Klee One (SIL OFL 1.1) · Zen Maru Gothic (SIL OFL 1.1) · Noto Serif SC (SIL OFL 1.1) · ZCOOL KuaiLe (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


