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

دليل الوصفات · الفصل 10 · الإخراج والدمج

غلاف كتاب ورقي بألسنة، وكعبه محسوب من الصفحات

كتاب ورقي بقياس 120 × 190 مم وألسنة عرضها 60 مم: تُنضَّد الصفحات أولًا، ثم تصنع منها buildCover فرخ الغلاف، بكعب سمكه سمك ورقها.

في هذه الصفحة
المُخرَج
Canvas · PDF
المستوى
متقدم
Postext
اختُبرت مع Postext 1.92.0
تتطلب ≥ 1.92.0 · postext-pdf ≥ 1.92.0
الترخيص
حُدّثت في 23 نوفمبر 2026
الشيفرة MIT · النص CC BY 4.0

ص 1 · 38 من 38

  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 120 × 190 مم
  • عمود واحد
  • Crimson Pro 11/15.2
  • Cormorant Garamond
  • Josefin Sans
  • 38 صفحة
  • المستوى
  • Postext 1.92.0
  • أُخرجت في 287 ms
  • أسطر الشيفرة: 189

باختصار

كتاب جيب صغير فيه أسطورتان لبيكر، ومعه فرخ غلافه كما يذهب إلى المطبعة: الغلاف الخلفي والكعب والغلاف الأمامي واللسانان المطويان في قطعة واحدة. عرض الكعب هو سمك الصفحات، ولذلك يُحسب من الكتاب نفسه.

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

أسطورتان لبيكر، «The Spirits’ Mountain» و«The Emerald Eyes» (وعنوانهما بالإسبانية «El monte de las ánimas» و«Los ojos verdes»)، في كتاب جيب ورقي بقياس 120 × 190 مم وألسنة عرضها 60 مم، ومعه الفرخ الذي يُطبع عليه غلافه. ينضّد Postext أولًا الصفحات السبع والثلاثين: صفحة نصف العنوان، وصفحة العنوان، والحقوق، والفهرس، وورقة عنوان لكل أسطورة، ثم المتن بخط Crimson Pro بقياس 11/15.2. بعدها تأخذ buildCover هذه الصفحات وتركّب الفرخ: اللسان الخلفي، والغلاف الخلفي بنبذته ورمزه الشريطي، والكعب، والغلاف الأمامي بلوحة لكنيسة مهدمة عند سفح جبل مونكايو، واللسان الأمامي. ويأتي العنوان والعنوان الفرعي واسم المؤلف من بيانات الكتاب الوصفية، ونص الألسنة من ملف Markdown مستقل.

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

  • كيف أصنع فرخ غلاف كتاب ورقي بألسنة، والكعب محسوب من عدد الصفحات؟

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

script.js · الأسطر 28–47في الشيفرة الكاملة
// The book's own binding profile: PUR perfect binding in 16-page signatures, flaps of
// 60 mm whatever the trim. The spine is written nowhere: buildCover works it out from the
// laid-out pages, rounded up to whole signatures, on the paper of `folio.paper`.
const production = {
  bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
    signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
  versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
    flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The design: a night ground over the whole sheet and the painting on the front, into the
// bleed at head and foot and up to the flap's fold. The texts come from the cover Markdown,
// the title, subtitle and author from the book's metadata.
const cover = {
  background: col('night'),
  elements: [{ id: 'art', kind: 'image', zone: 'front', x: 0, y: -3, width: 118, height: 196,
    resourceId: 'moncayo', fit: 'cover' }],
  verticalAlign: { back: 'middle' },
};

المكونات

الخطوط
Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
الأصول
  • moncayo-1100.jpg
  • The front cover: a ruined chapel under the Moncayo on All Souls’ Night, in oils (Generated With Diffusion Models, أصلي)

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

#1 · التجليد يحدد الألسنة، والورق يحدد الكعب

الشيفرة هي الجواب المختصر أعلاه. يصف ملف التجليد طريقة عمل المجلّد: تجليد حراري بغراء PUR في ملازم من 16 صفحة، وألسنة عرضها 60 مم، ونزف 3 مم، ونصف مليمتر يُضاف إلى الكعب للغراء. وتحمل النسخة الردمك ورقمه الإضافي ذا الخانات الخمس؛ والردمك رقم للتمثيل لا يخص أي كتاب. ولا يُكتب عرض الكعب في أي موضع. تُقرَّب الصفحات السبع والثلاثون صعودًا إلى ثلاث ملازم، أي 48 صفحة أو 24 ورقة، وكل ورقة من ورق وزنه 100 غ/م² وانتفاخه 2.4 سمكها 240 ميكرومترًا: 24 × 0.24 + 0.5 تعطي كعبًا عرضه 6.3 مم. والكعب الذي يقل عن 6 مم لا يُكتب عليه شيء افتراضيًا (spineText.minSpine)، ولذلك طُبع الكتاب على ورق منتفخ.

#2 · الصفحات أولًا

script.js · الأسطر 72–124في الشيفرة الكاملة
const [W, H, TOP, FOOT, INNER, OUTER, LEAD] = [120, 190, 20, 22, 18, 15.5, 15.2]; // mm, pt
const at = (to, edge, x, y, size) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) },
  ...(size && { size }) });
const text = (id, content, look, place) => ({ kind: 'text', id, content, align: 'center',
  overflow: 'wrap', placement: place, ...look });
const face = (fontFamily, size, color, extra) => ({ fontFamily, fontSize: pt(size), color,
  ...extra });
const label = (size, color = col('muted')) => face('Josefin Sans', size, color, caps(size / 5));
const none = { header: { elements: [] }, footer: { elements: [] }, numbered: false, toc: false };
const design = (minHeight, elements) => ({ enabled: true, minHeight: mm(minHeight),
  slot: { elements } });
const page = (parity) => ({ breakBefore: { enabled: true, parity } });
const rule = (id, y, to = 'page') => ({ kind: 'rule', id, direction: 'horizontal',
  thickness: pt(0.6), color: col('accent'), placement: at(to, 'top', 0, y, { width: mm(10) }) });
const folioAt = (y, pages) => ({ elements: [text('f', '{pageNumber}',
  { ...face('Crimson Pro', 9, col('ink')), pages }, at('page', 'bottom', 0, y))] });
const serif = (size, extra) => face('Cormorant Garamond', size, col('ink'), extra);
const headingStyles = [
  { ...none, id: 'half-title', advancedDesign: design(60, [
    text('t', '{title}', serif(17, { fontWeight: 500 }), at('page', 'top', 0, 62))]) },
  { ...none, ...page('odd'), id: 'title-page', advancedDesign: design(H - TOP - FOOT, [
    text('t', '{title}', serif(27, { fontWeight: 600 }), at('page', 'top', 0, 46)),
    text('s', '{subtitle}', serif(13, { italic: true }), at('page', 'top', 0, 58)),
    rule('r', 67),
    text('a', '{author}', label(8, col('accent')), at('page', 'top', 0, 72)),
    text('tr', '{attr.translators}', face('Crimson Pro', 9.5, col('muted'), { italic: true }),
      at('page', 'top', 0, 118, { width: mm(70) })),
    text('i', '{attr.imprint}', label(7), at('page', 'bottom', 0, -26)),
  ]) },
  // The rights at the foot of the verso, under a short rule.
  { ...none, ...page('even'), id: 'rights',
    advancedDesign: design(92, [rule('r', 86, 'container')]) },
  { ...none, ...page('odd'), id: 'contents', advancedDesign: design(34, [
    text('t', '{titleText}', label(8, col('accent')), at('container', 'top', 0, 14)),
    rule('r', 21, 'container')]) },
  // Each legend has a title leaf of its own (the contents point to it), then opens on the
  // next recto, sunk 40 mm.
  { ...none, ...page('odd'), id: 'tale-title', toc: true, advancedDesign: design(90, [
    text('k', '{attr.kicker}', serif(15, { fontWeight: 600, color: col('accent') }),
      at('page', 'top', 0, 58)),
    text('t', '{titleText}', serif(23, { fontWeight: 500 }), at('page', 'top', 0, 67)),
    text('p', '{attr.place}', face('Crimson Pro', 10.5, col('muted'), { italic: true }),
      at('page', 'top', 0, 79)),
    rule('r', 88)]) },
  { ...page('odd'), id: 'tale', toc: false, advancedDesign: design(40, [
    text('t', '{titleText}', serif(15, { fontWeight: 500, italic: true }),
      at('container', 'top', 0, 16)),
    rule('r', 25, 'container')]) },
  { ...none, ...page('any'), id: 'colophon', advancedDesign: design(70, [
    rule('r', 60, 'container')]) },
];
const head = (id, content, parity) => text(id, content, { ...label(6.8), parity, pages: 'body' },
  at('page', 'top', 0, 11));

متن الكتاب مستند Postext عادي، وكل صفحة فيه تُحسب في الكعب. وتستعمل الصفحات التمهيدية أنماط عناوين تضع تصاميمُها العنوانَ والخطَّ واسمَ الناشر على ارتفاعات ثابتة من الصفحة. ولكل أسطورة ورقة عنوان خاصة بها (وهي التي يشير إليها الفهرس)، ثم يبدأ نصها من جديد في الصفحة الفردية التالية، على بعد 40 مم من أعلاها. غيّر حجم الخط أو الهوامش فيتغير عدد الصفحات، ويتبعه الكعب في التنضيد التالي.

#3 · أنماط الغلاف تقيم مع أنماط الكتاب

script.js · الأسطر 51–68في الشيفرة الكاملة
const style = (id, fontFamily, size, lead, color, extra) => ({ id, fontFamily, fontSize: pt(size),
  lineHeight: pt(lead), color, italicColor: color, firstLineIndent: mm(0), textAlign: 'left',
  hyphenation: false, ...extra });
const caps = (tracking) => ({ fontWeight: 600, textTransform: 'uppercase',
  letterSpacing: pt(tracking) });
const coverStyles = [
  style('cover-title', 'Cormorant Garamond', 40, 40, col('bone'), { fontWeight: 600,
    textAlign: 'center', marginTop: mm(12) }),
  style('cover-subtitle', 'Cormorant Garamond', 15, 19, col('bone'), { italic: true,
    textAlign: 'center' }),
  style('cover-author', 'Josefin Sans', 8.5, 11, col('gold'), { ...caps(1.8),
    textAlign: 'center', marginTop: pt(16) }),
  style('cover-spine', 'Josefin Sans', 7.5, 9, col('bone'), { ...caps(1.2), textAlign: 'center' }),
  style('cover-blurb', 'Crimson Pro', 10.5, 14.5, col('bone'), { marginBottom: pt(7) }),
  style('cover-note', 'Crimson Pro', 10.5, 14.5, col('gold'), { italic: true }),
  style('flap-head', 'Josefin Sans', 7.5, 10, col('gold'), caps(1.4)),
  style('flap-text', 'Crimson Pro', 9.6, 13.2, col('bone'), { marginTop: pt(5) }),
];

يُنضَّد الفرخ بإعدادات الكتاب، فأنماط فقراته في القائمة نفسها التي فيها أنماط الحقوق وخاتمة الطبع. وcover-title وcover-subtitle وcover-author وcover-spine هي الأسماء التي تعطيها buildCover للبيانات الوصفية التي تضعها؛ أما cover-blurb وcover-note وflap-head وflap-text فيسمّيها ملف Markdown الخاص بالغلاف. وعلى الأرضية الليلية يُصفّ النص غير مضبوط الحافة، بلا تقطيع للكلمات، بلون العاج والذهب من لوحة الألوان.

#4 · الفرخ يُصنع من الصفحات المنضدة

script.js · الأسطر 496–505في الشيفرة الكاملة
const built = buildCover({ config, version: 'paperback', pages: book.pages, markdown: coverText,
  metadata: book.metadata, resources });
if (!('config' in built)) throw new Error(built.issues.map((i) => i.kind).join(', '));
// The barcode is the cover's own picture. Its digits name OCR-B, which no font server
// has: they are set in the label face, which the PDF embeds like the rest.
for (const [id, bytes] of Object.entries(built.files)) {
  await loadSvg(id, new TextDecoder().decode(bytes)
    .replace(/font-family="[^"]*"/g, 'font-family="Josefin Sans"'));
}
const sheet = await buildDocumentWithFonts(built.content, built.config, kitFonts(FONTS));

تتلقى buildCover الصفحات والبيانات الوصفية وملف Markdown الخاص بالغلاف، وفيه :::frame للغلاف الخلفي وآخر لكل لسان. وتُرجع مستندًا تنضّده buildDocumentWithFonts كأي مستند آخر، ومعه الرمز الشريطي في ملف SVG. تطلب أرقام الرمز خط OCR-B، ولا يقدّمه أي خادم خطوط، فيصفّها المثال بخط Josefin Sans الذي يضمّنه ملف PDF أصلًا. ويحمل ملف PDF الصفحات السبع والثلاثين ثم الفرخ بقياسه الخاص، وهو الملف الذي تنتظره المطبعة.

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 196 · A paperback cover with flaps, spine from the pages ═══
// https://postext.dev/en/cookbook/paperback-cover-with-flaps
// Code: MIT · Text: Bécquer, tr. C. F. & K. L. Bates (public domain) · Art: diffusion models
// Fonts: Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1) · Needs postext ≥ 1.92.0
//
// Two of Bécquer's legends as a 120 × 190 mm paperback with 60 mm flaps. Postext lays the
// pages out first; buildCover then makes the cover sheet from them, its spine as thick as
// the pages on their paper.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
import { buildCover } from 'https://esm.sh/postext/production';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'paperback-cover-with-flaps';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { ink: '#25221e', accent: '#86472a', muted: '#6b645a', paper: '#fbf7ee',
  night: '#16242a', gold: '#c99b4e', bone: '#eee5d1' }; // the last three: the cover's
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: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];

// #region answer: the paperback: a printer's binding with 60 mm flaps, its ISBN, its paper
// The book's own binding profile: PUR perfect binding in 16-page signatures, flaps of
// 60 mm whatever the trim. The spine is written nowhere: buildCover works it out from the
// laid-out pages, rounded up to whole signatures, on the paper of `folio.paper`.
const production = {
  bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
    signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
  versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
    flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The design: a night ground over the whole sheet and the painting on the front, into the
// bleed at head and foot and up to the flap's fold. The texts come from the cover Markdown,
// the title, subtitle and author from the book's metadata.
const cover = {
  background: col('night'),
  elements: [{ id: 'art', kind: 'image', zone: 'front', x: 0, y: -3, width: 118, height: 196,
    resourceId: 'moncayo', fit: 'cover' }],
  verticalAlign: { back: 'middle' },
};
// #endregion

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

تنويعات

#اكتب الكعب من الأعلى إلى الأسفل

تُقرأ كعوب الكتب الإنجليزية والأمريكية من الأعلى إلى الأسفل؛ أما الاتجاه الافتراضي، من الأسفل إلى الأعلى، فهو عادة إسبانيا وأوروبا القارية.

   versions: [{ id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
-    flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' }],
+    flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000',
+    spineText: { direction: 'topToBottom' } }],

#اطبع على ورق أرق

بوزن 80 غ/م² وانتفاخ 2.2 يصير سمك الورقة 176 ميكرومترًا، وينزل الكعب إلى 4.7 مم ويفقد كتابته التي تحتاج إلى 6 مم.

-const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
+const folio = { paper: { type: 'bookWove', grammage: 80, bulk: 2.2, shade: '#f7f1e3' } };

أخطاء شائعة

  • في قائمة الصفحات الملتقطة يأتي الفرخ بعد صفحات الكتاب، فرقمه هو عدد صفحات الكتاب زائد واحد. وإذا زادت صفحات الكتاب صفحة تغيّر الرقم.
  • إذا طلبت أرقام الرمز الشريطي خطًا لا يجده ملف PDF فشل التصدير. حمّل ملف SVG الخاص به مع font-family لخط حمّله المثال من قبل.

الحقوق

الوصفة
Ignacio Ferro
النص
  • The Spirits’ Mountain and The Emerald Eyes, translated by Cornelia Frances Bates and Katharine Lee Bates, from Romantic Legends of Spain (1909), Project Gutenberg eBook #50044 · Gustavo Adolfo Bécquer · ملك عام
  • El monte de las ánimas and Los ojos verdes, from the Obras (Madrid, Fernando Fe, 1885) as transcribed on Wikisource, accents modernised · Gustavo Adolfo Bécquer · ملك عام
الصور
  • The front cover: a ruined chapel under the Moncayo on All Souls’ Night, in oils · Generated With Diffusion Models · أصلي
الخطوط
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
SandboxPDF