انتقل إلى المحتوى الرئيسي
الوصفة رقم 157

دليل الوصفات · الفصل 12 · الكتب المدرسية

أطلس مدرسي تُكتب أسماء خرائطه في Markdown

خرائط مرسومة بالألوان بلا حرف واحد، تُسمّى بأسطر ::label عند مراسي كل مورد، على صفحات مركّبة وصفحتين متقابلتين، بثلاث لغات.

في هذه الصفحة

ص ٢–٣ · 2–3 من 4

  • مقاس القص 210 × 280 مم
  • عمود واحد
  • Noto Naskh Arabic 12/20
  • Noto Kufi Arabic
  • 4 صفحات
  • المستوى
  • Postext 1.57.1
  • أُخرجت في 95 ms
  • أسطر الشيفرة: 250

باختصار

ثلاث صفحات من أطلس مدرسي لبلد متخيَّل. الخرائط لوحات بلا نص، وكل أسمائها مكتوبة في النص، فتغيّر الترجمة الكلمات وتبقى الخرائط كما هي.

ما الذي ستنضده

ثلاث لوحات من أطلس مدرسي لفارينيا، وهي بلد اختُرع لهذه الوصفة. تبيّن اللوحة ١ موقعها في قارتها، وتمدّ اللوحة ٢ الخريطة الطبيعية على الصفحتين، من بحر ليرا إلى الحدود مع برونافيا، بألوان الارتفاع، مع ثلاثة أنهار وخط مقطع، وترسم اللوحة ٣ ذلك المقطع عبر سلسلة ألبار. تبدأ كل لوحة بشريط أزرق وتنتهي بمفتاح للخريطة أو بمفردات وببعض الأنشطة للصف. الخرائط الثلاث لوحات رُسمت بنموذج صور وليس فيها حرف واحد، أما الحدود والمدن ومقياس الرسم وسهم الشمال فرموز متجهة رُسمت معها. وليس خط المقطع جزءًا من الصورة: يصل بين مرساتين من الخريطة موصِّلان في القالب. وكل الأسماء والارتفاعات وأرقام مقياس الرسم أسطر ::label في Markdown، توضع عند مراسٍ يحفظها كل مورد، وكذلك مفتاح اللوحة ١ القائم في البحر. ولهذا تشترك الطبعات الإسبانية والإنجليزية والعربية في اللوحات الثلاث نفسها، وتُقرأ العربية وتُجلَّد من اليمين.

تجيب هذه الوصفة عن

  • كيف أضع أسماء الخريطة من النص، بحيث تغيّر الترجمة الكلمات ولا تمسّ الرسم؟
  • كيف أمدّ خريطة واحدة على صفحتين متقابلتين وأُبقي أسماءها مقروءة في طبعة تُقرأ من اليمين إلى اليسار؟

الجواب المختصر

script.js · الأسطر 43–71في الشيفرة الكاملة
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };
const style = (id, size, color, more) => ({ id, fontFamily: LABEL, fontSize: pt(size * SIZE),
  fontWeight: AR ? 500 : 400, color: col(color), ...more });
const water = (id, size, spacing, more) => style(id, size, 'water', { fontStyle: SLANT,
  textTransform: spacing ? 'uppercase' : 'none', letterSpacing: spacing * TRACK, ...more });
const caps = (id, size, color, spacing, more) => style(id, size, color, {
  fontWeight: AR ? 700 : 600, textTransform: 'uppercase', letterSpacing: spacing * TRACK,
  ...more });
const labelStyles = [
  water('ocean', 9.5, 0.3), water('sea', 7.5, 0.16), water('river', 6.8, 0, { halo }),
  caps('range', 7, 'relief', 0.32, { halo }), caps('region', 6.5, 'muted', 0.24, { halo,
    leader: { color: col('ink'), width: pt(0.6), endCap: 'dot', capSize: mm(1.2) } }),
  style('legend', 7.6, 'ink', { kind: 'legend', background: col('paper'), padding: mm(2.4),
    border: { color: col('muted'), width: pt(0.4) }, radius: mm(1) }),
  caps('country', 8.5, 'muted', 0.36, { halo }), caps('nation', 12, 'ink', 0.42, { halo }),
  style('capital', 7.6, 'ink', { fontWeight: 700, halo }), style('town', 7, 'ink', { halo }),
  style('peak', 6.5, 'ink', { fontWeight: AR ? 700 : 600, halo }),
  style('island', 6.5, 'ink', { halo }),
  style('point', 8.5, 'band', { fontWeight: 700, halo }), style('tick', 6, 'muted'),
];
// An anchor is a point of the picture in fractions of its width and height, with the side of
// the label that stands there, its turn and its style. km(win) reads a point in km off a map.
const km = (win) => (id, x, y, labelStyle, more) => ({ id, x: (x - win.x0) / (win.x1 - win.x0),
  y: (y - win.y0) / (win.y1 - win.y0), style: labelStyle, ...more });

المكونات

الخطوط
Source Sans 3, Source Serif 4, Noto Naskh Arabic, Noto Kufi Arabic (SIL OFL 1.1)
الأصول
  • locator-1776.jpg
  • relief-1984.jpg
  • section-1760.jpg
  • The locator map of Varenia and its neighbours, painted as a physical map with a golden wash over Varenia. (Generated With Diffusion Models, أصلي)
  • The relief map of Varenia across a double page: hypsometric tints, hill shading, coastal shelf, rivers and a lake. (Generated With Diffusion Models, أصلي)
  • The section from A to B painted as a slice of land cut along the line, in the height bands of the map. (Generated With Diffusion Models, أصلي)

طريقة التحضير

#1 · المكان نقطة من الرسم

script.js · الأسطر 434–478في الشيفرة الكاملة
const above = { verticalAlign: 'bottom' }, below = { verticalAlign: 'top' };
const r = km(WIN.relief), l = km(WIN.locator);
const ANCHORS = {
  relief: [
    r('ocean', 172, 157, 'ocean'), r('lira', 20, 52, 'sea', { rotate: -84 }),
    r('gulf', 318, 154, 'sea', { width: 0.07 }), r('nema', 22, 100, 'island', above),
    r('albar-range', 98, 108, 'range', { rotate: -33 }),
    r('gris-range', 308, 96, 'range', { rotate: -86 }),
    r('plateau', 236, 78, 'region'), r('plain', 70, 98, 'region', { width: 0.08 }),
    r('sela', 108, 62, 'river', { rotate: -4 }), r('duna', 121, 136, 'river', { rotate: -62 }),
    r('merel', 281, 92, 'river', { rotate: -47 }), r('ormo', 254, 104, 'river', above),
    // Calvera's name goes below its dot: the River Sela runs in just above it.
    ...TOWNS.map(([id, x, y]) => (id === 'calvera' ? r(id, x, y + 2.6, 'town', below)
      : r(id, x, y - 2.6, id === 'almaren' ? 'capital' : 'town', above))),
    ...PEAKS.map(([id, x, y]) => r(`${id}-peak`, x, y + 2.4, 'peak', below)),
    r('ostelia', 300, 9, 'country'), r('brunavia', 390, 112, 'country', { rotate: -90 }),
    r('varenia', 250, 46, 'nation'),
    r('a', PROFILE[0][0], PROFILE[0][1] - 2, 'point', above),
    r('b', PROFILE[1][0], PROFILE[1][1] + 2, 'point', below),
    r('scale-0', SCALE.x, SCALE.y + 3, 'tick', below),
    r('scale-25', SCALE.x + 25, SCALE.y + 3, 'tick', below),
    r('scale-50', SCALE.x + 50, SCALE.y + 3, 'tick', below),
    r('north', NORTH.x, NORTH.y - 8, 'point', above),
    r('a-end', ...PROFILE[0]), r('b-end', ...PROFILE[1]),
  ],
  locator: [
    l('varenia', 205, 80, 'nation'), l('ostelia', 150, -100, 'country'),
    l('brunavia', 560, -120, 'country'), l('lira', 210, -250, 'sea', { rotate: 20 }),
    l('ocean', -180, -40, 'ocean', { width: 0.2 }), l('almaren', 259, 127 + 22, 'capital', below),
    { id: 'key', x: 0.115, y: 0.965, style: 'legend', verticalAlign: 'bottom' },
  ],
  // The section: fractions of the drawing, whose plot starts 14 mm in and runs 3 to 51 mm down.
  section: (() => {
    const [w, h] = MAP.section, x = (u) => (14 + u * (w - 14)) / w;
    const y = (m) => (h - 7 - m * (h - 10) / PROFILE_TOP) / h;
    return [
      { id: 'a', x: x(0), y: (h - 5.5) / h, style: 'point', ...below },
      { id: 'b', x: x(0.98), y: (h - 5.5) / h, style: 'point', ...below },
      ...[500, 1000, 1500, 2000].map((m) => ({ id: `m${m}`, x: 7 / w, y: y(m), style: 'tick' })),
      { id: 'sela', x: x(0.3), y: y(40), style: 'region', labelAt: { x: x(0.3), y: y(850) } },
      { id: 'crest', x: x(0.47), y: y(2260), style: 'range', ...above },
      { id: 'plain', x: x(0.82), y: y(160), style: 'region', labelAt: { x: x(0.82), y: y(850) } },
    ];
  })(),
};

المرساة نقطة تُعطى بنسب من عرض الصورة وارتفاعها، فتبقى صحيحة مهما كان الحجم الذي يضع فيه الإطار الخريطة، وإذا صغّرت خطوات الملاءمة الخريطة انتقلت أسماؤها معها. تحوّل km() الكيلومترات المقروءة على شبكة موضوعة فوق اللوحة إلى هذه النسب، فتأتي نقطة المدينة واسمها كلاهما من TOWNS ولا يمكن أن يفترقا. وتحفظ المرساة ما يخصّ المكان لا اللغة: نمطه، ودوران اسم النهر أو السلسلة على امتداد مجراه، والجهة من التسمية التي تقف عند النقطة. وتُوسَّط أسماء المدن فوق نقاطها، لأن align: 'start' يعني يسار الاسم الإنجليزي ويمين الاسم العربي.

رُسمت اللوحات بالترتيب. جاءت لوحة التضاريس أولًا، رسمها نموذج صور اعتمادًا على خريطة ارتفاعات للبلد بتظليل التضاريس؛ ثم رُسمت خريطة الموقع انطلاقًا من لوحة التضاريس، ورُسم المقطع بالارتفاعات نفسها، فتتفق السواحل والارتفاعات في الثلاث. وأعطت شبكة مرسومة فوق كل صورة كيلومترات كل مرساة، وقُطعت الحدود حيث تبلغ الساحل المرسوم.

#2 · ثلاثة ملفات Markdown ومورد واحد

script.js · الأسطر 482–492في الشيفرة الكاملة
// A resource has no alt text, caption or note here: each edition's `:::figure` says its own.
const PAINTINGS = { // each plate's painting, a file in assets/, named by its width in pixels
  locator: asset('locator-1776.jpg'), relief: asset('relief-1984.jpg'),
  section: asset('section-1760.jpg') };
const drawings = { locator: locatorMap, relief: reliefMap, section: profile };
const resources = Object.entries(MAP).map(([id, [w, h]]) => ({ id, typeId: 'map', kind: 'svg',
  createdAt: 0, updatedAt: 0, svg: { fileId: `${id}.svg`, width: w * 10, height: h * 10 },
  anchors: ANCHORS[id] }));
for (const [id, draw] of Object.entries(drawings)) {
  await loadSvg(`${id}.svg`, draw(MAP[id], await dataUrl(PAINTINGS[id])));
}

للمورد صورة واحدة (ملف SVG فيه اللوحة والرموز المتجهة فوقها) وقائمة مراسٍ واحدة لكل الطبعات. وتكتب كل طبعة سطر ::label[…]{at="…"} لكل مرساة داخل :::figure{resource="relief" slot="map"}، فيقع ::label[سهل كالفيرا]{at="plain"} حيث يقع ::label[Calvera Plain]{at="plain"}، ويُقسَم على سطرين بحسب width المرساة عند الحاجة. ويتغيّر النص البديل مع الطبعة أيضًا: لكل :::figure نصه في سطر ::alt[…]، وكذلك يُكتب التعليق أو الملاحظة بـ::caption[…] و::note[…]. وإذا تركت طبعةٌ مرساةً ذات نمط بلا تسمية ظهر التحذير anchorUnlabelled، والتسمية التي يحدّد at فيها مرساة غير موجودة لا تُرسم ويظهر لها labelAnchorUnknown.

#3 · لوحة على صفحة ولوحة على صفحتين

script.js · الأسطر 75–118في الشيفرة الكاملة
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const kicker = { kind: 'text', id: 'unit', content: '{attr.unit}', fontFamily: LABEL,
  fontSize: pt(AR ? 10 : 8.5), fontWeight: AR ? 500 : 600, letterSpacing: pt(1.3 * TRACK),
  textTransform: 'uppercase', color: col('sky'), align: AR ? 'right' : 'left',
  // Decoration stands on the sheet: the kicker goes to the side the page starts reading from.
  placement: at('container', AR ? 'top-right' : 'top-left', 0, -11) };
const band = { kind: 'box', id: 'band', style: { backgroundColor: col('band') },
  placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(BAND + 3) } } };
const sheet = {
  id: 'sheet', header: false, decoration: { elements: [band, kicker] },
  frames: [
    { name: 'title', takes: 'h1', placement: at('container', 'top-left', 0, -3) },
    { name: 'text', flow: true, columns: 2, columnGap: mm(7),
      placement: at('container', 'top-left', 0, BAND - PAGE.top + 7) },
    { name: 'map' },
    { name: 'key', style: 'key', width: mm(66) },
    { name: 'tasks', style: 'tasks', placement: at('#key', 'right-of', 6) },
  ],
  // A longer text pushes the map and the key down; the map is set smaller before the text is.
  groups: [{ name: 'column', kind: 'stack', frames: ['text', 'map', 'key'], gap: mm(6) }],
};
const locator = { id: 'locator', extends: 'sheet', frames: [{ name: 'key', remove: true },
  { name: 'tasks', placement: at('#map', 'below', 0, 6) }],
  groups: [{ name: 'column', frames: ['text', 'map'] }] };
// Line A–B: two connectors between two anchors of the map, dotted ends, a see-through paper casing.
const section = (id, color, width, more) => ({ kind: 'connector', id, routing: 'straight',
  from: { to: '#map', anchor: 'a-end' }, to: { to: '#map', anchor: 'b-end' }, color: col(color),
  width: mm(width), ...more });
const sectionLine = [section('ab-casing', 'paper', 0.9, { opacity: 0.55 }), section('ab-line',
  'ink', 0.5, { dash: [mm(1), mm(1)], startCap: 'dot', endCap: 'dot', capSize: mm(2) })];
// The double sheet: one band and one map across both pages, the boxes under the map.
const spread = {
  id: 'spread', spread: true, header: false,
  decoration: { elements: [band, kicker, ...sectionLine] },
  frames: [
    { name: 'title', takes: 'h1', width: mm(177), placement: at('container', 'top-left', 0, -3) },
    { name: 'map', crossGutter: true, // the one frame that runs across the spine
      placement: at('container', 'top-left', 0, BAND - PAGE.top + 5) },
    { name: 'text', flow: true, columns: 2, columnGap: mm(7), width: mm(177) },
    { name: 'key', style: 'key', width: mm(72), placement: at('#map', 'below', 213, 6) },
    { name: 'tasks', style: 'tasks', placement: at('#key', 'right-of', 6) },
  ],
  groups: [{ name: 'column', kind: 'stack', frames: ['map', 'text'], gap: mm(6) }],
};

للوحة واللوحة المزدوجة الإطارات الخمسة نفسها، فيكون لـMarkdown اللوحة الشكل نفسه على صفحة أو على صفحتين: العنوان، والنص الذي لا يحدّد خانة، والخريطة، ومفتاحها، والأنشطة. وتوسّع لوحةُ الموقع اللوحةَ (extends) وتحذف منها إطار المفتاح (remove: true)، لأن مفتاحها تسمية على الخريطة، وتتدلّى أنشطتها تحت الخريطة. وخط المقطع من اللوحة المزدوجة: عنصرا connector في زخرفتها يمتدّان مستقيمين (straight) من المرساة a-end إلى المرساة b-end في الصورة التي يحملها إطار الخريطة، خط بلون الورق عرضه ٠٫٩ مم تحت خط متقطع بالحبر عرضه ٠٫٥ مم، بنقطة عند كل طرف. ولخط الورق opacity: 0.55، كالحافة الفاتحة للحدود المرسومة مع الخريطة، فتظهر ألوان التضاريس من تحته وتبقى الشرطات مقروءة على الأخضر والمغرة. والطرف الذي فيه anchor يتبع الصورة في قصّها ومقياسها، فيبقى الخط على أ وب وإن صغّرت خطوات الملاءمة الخريطة. وتُرسم الزخرفة تحت الإطارات، لكن الموصِّل الذي له طرف anchor يشير إلى داخل صورة، فيُرسم فوقها ويظهر الخط على اللوحة المرسومة. وفي اللوحة المزدوجة يجعل spread: true الصفحتين ورقة واحدة عرضها ٣٩٠ مم، وليس crossGutter إلا في إطار الخريطة، فيعبر الكعب ويبقى النص والإطاران الآخران في صفحاتهم. ويؤلّف النص والخريطة والمفتاح مجموعة stack: في اختبار الضغط على منصة الاختبار، حين تطول النصوص كلها بنسبة ٣٠ ٪، تضع الطبعة العربية خريطة الموقع بنسبة ٨٧٫٥ ٪ وتصعد الإطارات تحتها، بلا أي تحذير.

#4 · مفتاح على الخريطة، وأسماء بخطوط دالّة

script.js · الأسطر 43–71في الشيفرة الكاملة
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };
const style = (id, size, color, more) => ({ id, fontFamily: LABEL, fontSize: pt(size * SIZE),
  fontWeight: AR ? 500 : 400, color: col(color), ...more });
const water = (id, size, spacing, more) => style(id, size, 'water', { fontStyle: SLANT,
  textTransform: spacing ? 'uppercase' : 'none', letterSpacing: spacing * TRACK, ...more });
const caps = (id, size, color, spacing, more) => style(id, size, color, {
  fontWeight: AR ? 700 : 600, textTransform: 'uppercase', letterSpacing: spacing * TRACK,
  ...more });
const labelStyles = [
  water('ocean', 9.5, 0.3), water('sea', 7.5, 0.16), water('river', 6.8, 0, { halo }),
  caps('range', 7, 'relief', 0.32, { halo }), caps('region', 6.5, 'muted', 0.24, { halo,
    leader: { color: col('ink'), width: pt(0.6), endCap: 'dot', capSize: mm(1.2) } }),
  style('legend', 7.6, 'ink', { kind: 'legend', background: col('paper'), padding: mm(2.4),
    border: { color: col('muted'), width: pt(0.4) }, radius: mm(1) }),
  caps('country', 8.5, 'muted', 0.36, { halo }), caps('nation', 12, 'ink', 0.42, { halo }),
  style('capital', 7.6, 'ink', { fontWeight: 700, halo }), style('town', 7, 'ink', { halo }),
  style('peak', 6.5, 'ink', { fontWeight: AR ? 700 : 600, halo }),
  style('island', 6.5, 'ink', { halo }),
  style('point', 8.5, 'band', { fontWeight: 700, halo }), style('tick', 6, 'muted'),
];
// An anchor is a point of the picture in fractions of its width and height, with the side of
// the label that stands there, its turn and its style. km(win) reads a point in km off a map.
const km = (win) => (id, x, y, labelStyle, more) => ({ id, x: (x - win.x0) / (win.x1 - win.x0),
  y: (y - win.y0) / (win.y1 - win.y0), style: labelStyle, ...more });

النمط legend تسمية لها kind: 'legend'، ولوح أبيض، وإطار رفيع، وزوايا مستديرة. ويُكتب في Markdown كتلةً :::label{at="key" style="legend"} داخل الشكل، صفًّا في كل سطر: يصبغ :icon[]{resource="key-mark" color="country"} Varenia موردًا صغيرًا مربعًا بلون من لوحة الألوان، ويرسم :icon[]{line="dashed" color="border"} عيّنة من الحدود، وتصطفّ الرموز التي تبدأ بها الصفوف في عمود واحد، فتنتظم الكلمات عن يمينه، أو عن يساره في العربية. وتبقى الأقواس المعقوفة فارغة: الكلمة التالية تسمّي الصف، والرمز الذي لا نص بديلًا له يُقرأ زخرفةً. وفي المقطع تقف المرساتان sela وplain على الأرض، ويضع labelAt الخاص بهما الاسمين على ارتفاع ٨٥٠ م في السماء، ويرسم leader في النمط region خطًّا عرضه ٠٫٦ نقطة بنقطة في طرفه من كل اسم إلى موضعه.

#5 · لوحة ألوان واحدة للصفحة وألوان الارتفاع والمفتاح

script.js · الأسطر 19–33في الشيفرة الكاملة
const palette = {
  ink: '#1f2a2e', paper: '#ffffff', muted: '#55646a',
  band: '#1d5f73', // the accent: the head of each sheet, box stripes, list numbers
  sky: '#d4e9f2', // the kicker on the band
  tint: '#eef2ef', // the key's box
  water: '#0b2a47', sea: '#8ec5e9', // the names of water, and the sea of the key
  // The key's tints are the median colours of the painted relief at each height band.
  low: '#aec67f', hill: '#ced285', upland: '#efce80', mount: '#d79c61', peak: '#b5734b',
  relief: '#5a3519', // the names of ranges
  land: '#e1dfbe', country: '#ebcb73', border: '#8a3b52', // the locator map's washes and border
};
// col(id) links a colour to its palette entry; the vector symbols read the same hex from `palette`.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.band }) // the defaults' id
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));

ألوان الارتفاع الخمسة مدخلات في لوحة الألوان (من palette.low إلى palette.peak)، ضُبطت على اللون الوسيط للتضاريس المرسومة في كل نطاق، ويكتب مفتاح اللوحة ٢ ‏:swatch{color="low"} بالمعرّفات نفسها. ولا تقرأ اللوحة لوحة الألوان: يغيّر لون ست عشري جديد المفتاح والرموز المتجهة ويترك الصورة كما هي، ولتغيير ألوان الخريطة يجب رسمها من جديد. ولأسماء المياه في water تباين لا يقل عن ٦:١ على البحر المرسوم، وللعنوان الأبيض تباين ٧٫٢:١ على band.

#6 · الطبعة العربية

الشيفرة في الجواب المختصر أعلاه. يجعل locale: 'ar' النص من اليمين إلى اليسار ويجلّد الكتاب من اليمين، فتبدأ الصفحتان المتقابلتان بالصفحة اليمنى، وتتبع الإطارات منطقة المحتوى المعكوسة: العنوان والنص على اليمين، والمفتاح يمين الأنشطة. ولا تُعكس الخرائط، فيقف كل اسم عربي حيث رُسم مكانه. وتفقد أنماط التسميات في العربية الخط المائل وتباعد الحروف وتكبر بنسبة ١٥ ٪، لأن الكوفي يأتي صغيرًا. وتبقى الزخرفة وأرقام الصفحات مربوطة بالورقة، فينتقل العنوان الصغير إلى أعلى اليمين ويتبادل رقما الصفحتين جهتيهما.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 157 · A school atlas labelled from the Markdown ═══════
// https://postext.dev/en/cookbook/school-atlas-labelled-maps
// Code: MIT · Text: original (CC BY 4.0) · Maps: painted with diffusion models, symbols set in code
// Fonts: Source Sans 3, Source Serif 4, Noto Naskh and Kufi Arabic (OFL) · Needs postext ≥ 1.49.0
//
// Three pages of a school atlas of Varenia, an invented country: a locator map, the relief map
// across a double page and a section through the mountains. The maps are painted without a letter.
// Every name on them is a ::label in content.<lang>.md, standing at an anchor of the resource,
// so the Spanish, English and Arabic editions share the same paintings and the same anchors.
import {
  buildDocument, withLoadedFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';

const LANG = 'ar'; // @lang: the language of the sample document ('es' | 'en' | 'ar')
const RECIPE = 'school-atlas-labelled-maps';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: the page's colours and the key's tints, one object for both
const palette = {
  ink: '#1f2a2e', paper: '#ffffff', muted: '#55646a',
  band: '#1d5f73', // the accent: the head of each sheet, box stripes, list numbers
  sky: '#d4e9f2', // the kicker on the band
  tint: '#eef2ef', // the key's box
  water: '#0b2a47', sea: '#8ec5e9', // the names of water, and the sea of the key
  // The key's tints are the median colours of the painted relief at each height band.
  low: '#aec67f', hill: '#ced285', upland: '#efce80', mount: '#d79c61', peak: '#b5734b',
  relief: '#5a3519', // the names of ranges
  land: '#e1dfbe', country: '#ebcb73', border: '#8a3b52', // the locator map's washes and border
};
// col(id) links a colour to its palette entry; the vector symbols read the same hex from `palette`.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = Object.entries({ ...palette, 'main-color': palette.band }) // the defaults' id
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));
// #endregion
const AR = LANG === 'ar';
// Three voices per script: a text face, a display face and the face of the map labels.
const [TEXT, DISPLAY, LABEL] = AR ? ['Noto Naskh Arabic', 'Noto Kufi Arabic', 'Noto Kufi Arabic']
  : ['Source Sans 3', 'Source Serif 4', 'Source Sans 3'];
const PAGE = { w: 210, h: 280, top: 22, bottom: 20, inner: 18, outer: 15 }; // mm, mirrored
const BAND = 44; // mm from the trim to the foot of the band at the head of a sheet

// #region answer: label styles in the config, label fields on the anchors of a resource
// A label takes the style its anchor names: seas and rivers in italic blue, ranges in spaced
// brown capitals, towns on a white halo. Arabic is neither slanted nor letter-spaced, and
// Naskh and Kufi set small, so the Arabic edition gets the same styles upright, unspaced and
// 15 % larger.
const [SLANT, TRACK, SIZE] = AR ? ['normal', 0, 1.15] : ['italic', 1, 1];
const halo = { color: col('paper'), width: pt(1.4) };

يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)

تنويعات

#سمِّ مكانًا لا مرساة له

يمكن أن تقف التسمية عند نقطة تُعطى بنسب مئوية من الصورة، وبنمط خاص بها.

 :::figure{resource="relief" slot="map"}
+::label[منارة نيما]{at="7% 68%" style="town"}
 ::label[المحيط الضبابي]{at="ocean"}

#رقّم الخرائط وأضف إليها تعليقات

اجعل لنوع الخريطة عدّادًا وبادئة، ولكل مورد تعليقًا: انظر لوحة الأطلس ذات الخرائط المرقّمة، التي تضع تعليقات خرائطها على شريط أزرق.

أخطاء شائعة

تحذير الإخراج · labelAnchorUnknown

تسمية على مرساة غير موجودة

السبب. تحدّد ‎::label‎ في ‎:::figure‎ عبر at= مرساةً لا يملكها مورد الشكل. فلا تُرسم التسمية على الصورة؛ ويظل ملف EPUB القابل لإعادة التدفق يدرجها ويذكرها النص البديل للصورة.

الحل. صحّح معرّف المرساة في at= (يذكر التحذير مراسي المورد)، أو أضف المرساة إلى المورد، أو ضع التسمية باستخدام at="x% y%". التوثيق →

تحذير الإخراج · anchorUnlabelled

مرساة بلا تسمية

السبب. تحدّد مرساةٌ في مورد الشكل نمطَ تسمية، ولا توجد عندها أي ‎::label‎ من الشكل بهذه اللغة: الخريطة تتسع للكلمة لكن هذه الطبعة تخلو منها. هذه ملاحظة لا خطأ؛ ولا يظهر التحذير للمراسي التي بلا نمط (مثل مراسي شخصيات القصص المصورة).

الحل. اكتب التسمية في Markdown هذه اللغة (‎::label[…]{at="مرساة"}‎)، أو أزل النمط من المرساة إذا كانت هذه الطبعة تستغني عن الكلمة. التوثيق →

  • النص البديل لكل خريطة موجود في Markdown، في سطر ::alt[…] داخل :::figure الخاص بها، نصّ لكل طبعة. والشكل الذي لا يحدّد نصًّا يحتفظ بـaltText الخاص بالمورد، ولا يبقى في script.js أي كلمة من الصفحة.
  • الموصِّل الذي لا يسمّي طرفاه إلا إطارات يُرسم تحتها مع بقية الزخرفة، ولا يرفعه فوق الصورة إلا طرف فيه anchor. والخط الممدود من ملاحظة إلى حافة الخريطة بلا مرساة يختفي حيث يعبر اللوحة المرسومة.
  • المراسي والرموز المتجهة (الحدود والمدن والقمم وطرفا خط المقطع) واقعة عند كيلومترات قُرئت على اللوحة. وإذا رُسمت خريطة من جديد تحرّكت سواحلها وأنهارها وسلاسلها: ضع الشبكة فوق الصورة الجديدة واقرأها مرة أخرى، وإلا وقع اسم في البحر.
  • في صفحة من اليمين إلى اليسار تتبع الإطارات منطقة المحتوى المعكوسة، أما زخرفة القالب فلا: ضع العنوان الصغير بحسب الطبعة، كما يفعل kicker.
  • قد يقطع إطار من عمودين فقرةً قبل سطرها الأخير، فيبقى ذلك السطر في رأس العمود الثاني. راجع أعمدة كل طبعة، وانقل جملة من فقرة إلى التي تليها إن حدث ذلك.

الحقوق

الوصفة
Ignacio Ferro
النص
نص أصلي, CC BY 4.0
الصور
  • The locator map of Varenia and its neighbours, painted as a physical map with a golden wash over Varenia. · Generated With Diffusion Models · أصلي
  • The relief map of Varenia across a double page: hypsometric tints, hill shading, coastal shelf, rivers and a lake. · Generated With Diffusion Models · أصلي
  • The section from A to B painted as a slice of land cut along the line, in the height bands of the map. · Generated With Diffusion Models · أصلي
الخطوط
Source Sans 3 (SIL OFL 1.1) · Source Serif 4 (SIL OFL 1.1) · Noto Naskh Arabic (SIL OFL 1.1) · Noto Kufi Arabic (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
Sandbox