باختصار
تحقيق من أربع صفحات في مجلة يُنضَّد من قالب: ينتقل النص وحده من عمود إلى الذي يليه ثم إلى صفحات جديدة، ويلتف حول اقتباس وحول محيط صورة.
ما الذي ستنضده
الصفحات من 46 إلى 49 من Patio، فصلية متخيَّلة عن الحياة في المدينة: تحقيق عن منضِّدة حروف متقاعدة تربّي أربع عشرة خلية نحل على سطح المطبعة التي عملت فيها ثلاثين عامًا. الصفحة الزوجية من الافتتاح هي الصورة، والعنوان فوق حصى السطح، وفي السماء إطار ملوَّن للأرقام. وفي الصفحة الفردية التمهيد والعمودان الأولان، مع اقتباس بارز فوق الفاصل بين العمودين، وخلية نحل من القش مقصوصة عن خلفيتها تتبع أسطر العمود الثاني قبّتها. ثم يأخذ النص ما يحتاجه من صفحات، بثلاثة أعمدة في كل صفحة، وينتهي حيث ينتهي. الطبعات الإسبانية والإنجليزية والألمانية قالب واحد بكلمات أخرى، والألمانية تمرّر كلماتها المركّبة الطويلة في أعمدة عرضها 60 مم.
تجيب هذه الوصفة عن
- كيف أجعل مقال مجلة يجري عبر إطارات مترابطة على عدة صفحات؟
- كيف أُخرج مجلة مقسّمة إلى أبواب، يفتتح كل مقال فيها على صفحتين متقابلتين وصورته الرئيسية في الصفحة المقابلة؟
- هل يستطيع Postext تنضيد ثلاثة أعمدة نصية أو أكثر، أو التفاف النص حول صورة؟
الجواب المختصر
const opening = {
id: 'apertura',
spread: true,
header: false,
frames: [
{ name: 'titulo', takes: 'h1', layer: 2, width: mm(150),
placement: at('container', 'bottom-left', 4, -14) },
{ name: 'datos', style: 'datos', layer: 2, width: mm(64),
placement: at('container', 'top-left', 4, 6) },
{ name: 'entradilla', width: mm(2 * COLUMN + GAP),
placement: at('container', 'top-left', RECTO) },
// The story names no slot, so it goes to the flow frame, then on down the chain.
{ name: 'col-1', flow: true, next: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#entradilla', 'below', 0, 7) },
// What the last column cannot hold goes on to a page added after the spread.
{ name: 'col-2', width: mm(COLUMN), height: 'fill',
placement: at('#col-1', 'right-of', GAP),
overflow: { continueIn: 'template:seguido' } },
...pushers,
],
decoration: { elements: [
{ kind: 'image', id: 'foto', resourceId: '{attr.foto}',
fit: 'cover',
placement: { ...at('bleed', 'top-left'), size: { width: mm(W), height: 'fill' } } },
{ kind: 'text', id: 'seccion', content: '{attr.seccion}', fontFamily: SANS, fontSize: pt(9),
fontWeight: 700, letterSpacing: pt(2), textTransform: 'uppercase', color: col('paper'),
placement: at('#titulo', 'above', 0, -3) },
] },
};
المكونات
- الميزات
- إطارات نص متسلسلةإطارات تزيح النص بصندوقها أو بمحيطهاالصفحات المركّبةهوامش متناظرةالصور في تصاميم الصفحةتقسيم الكلمات ولغة المستندالترويسات وأرقام الصفحاتأنماط الفقراتالحروف الاستهلالية في صفحات الافتتاحإطارات التنبيهلوحة ألوان دلاليةالأشكال والجداول بوصفها مواردصفحات على اللوحة (Canvas)التصدير إلى PDF
- تستخدم أيضًا
- الحروف الاستهلالية في فقرات المتنقوالب الصفحتين المتقابلتينإطارات تستمر في الصفحة التاليةزخرفة مثبّتة بالإطاراتأشكال في هذا الموضع بالضبطالخطوط المضمَّنة في PDFأنواع موارد مخصّصة
- الخطوط
- Literata, Fraunces, Instrument Sans (SIL OFL 1.1)
- الأصول
rooftop-1400.jpgskep-720.png- Painted hives on a factory roof at sunrise (the opening spread) (Generated With Diffusion Models, أصلي)
- A straw bee skep on a transparent ground (the cut-out the text runs round) (Generated With Diffusion Models, أصلي)
طريقة التحضير
#1 · قالب واحد لنص واحد
الشيفرة في الجواب المختصر. التحقيق كله كتلة صفحة واحدة ::::page{template="apertura" spread}: يذهب العنوان إلى الإطار الذي له takes: 'h1'، والأرقام والتمهيد إلى خاناتهما، وكل ما عداها مما لا يحدّد خانة إلى إطار التدفق col-1. حين يمتلئ col-1 يستمر النص في col-2 ويُقسَّم من جديد على عرضه، وما لا يتسع له col-2 يستمر بعد كلمة Continúa في صفحة تُضاف بعد الصفحتين المتقابلتين (overflow.continueIn: 'template:seguido'). لا يحدّد النص عمودًا ولا صفحة: احذف فقرة فترجع كل الأسطر التي بعدها.
#2 · الصفحات التي يضيفها النص
// The third column continues into this same template: the story goes on in the frame its
// chain starts in, so every added page fills all three columns.
const seguido = {
id: 'seguido',
frames: [
{ name: 'seguido-1', flow: true, next: 'seguido-2', height: 'fill', width: mm(60.3) },
{ name: 'seguido-2', next: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-1', 'right-of', 5) },
{ name: 'seguido-3', height: 'fill', width: mm(60.3),
placement: at('#seguido-2', 'right-of', 5),
overflow: { continueIn: 'template:seguido' } },
],
};
في كل صفحة مضافة ثلاثة أعمدة متسلسلة، عرض كل منها 60.3 مم، وقالب واحد يخدم الصفحات كلها. يستمر العمود الثالث في هذا القالب نفسه، ويتابع النص في الإطار الذي تبدأ منه سلسلته، seguido-1، فتملأ كل صفحة مضافة أعمدتها الثلاثة مهما بلغ عدد الصفحات. ولا حاجة إلى تثبيت حجم الحرف: الإطار الذي يستطيع المتابعة في صفحة أخرى يتابع قبل أن يُصغَّر النص، فيحصل النص الذي يزيد خمسة أسطر على صفحة جديدة، لا على نسبة 92.5 % في الصفحة الأخيرة.
#3 · إطاران يزيحان الأعمدة
const pushers = [
// The pull quote straddles the gutter: each column loses the side it covers.
{ name: 'cita', style: 'cita', exclude: 'push', width: mm(62),
placement: at('#entradilla', 'below', COLUMN - 27.5, 82) },
// The skep's frame pushes with the shape of its picture, read from the PNG's alpha.
{ name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
placement: at('container', 'bottom-right', 9, -8) },
];
لا ينتمي أي من الإطارين إلى النص، فكل منهما يزيح أسطر الأعمدة التي يغطيها فقط. الاقتباس مربوط بالتمهيد، على بعد 82 مم تحته، ويمتد فوق الفاصل بين العمودين، فيفقد العمود الأول جانبه الأيمن والثاني جانبه الأيسر. وفي إطار الخلية wrap: 'contour': يُنضَّد كل سطر بجانبه أقصر بقدر عرض الصورة عند ارتفاع السطر، مع هامش 2.5 مم، فيتبع العمود الثاني القبة ثم يعود إلى عرضه الكامل تحت قاعدتها.
#4 · محيط يرافق الصورة
const photo = { id: 'azotea', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({
es: 'Seis colmenas de colores en la azotea de una fábrica, con la ciudad al amanecer',
en: 'Six painted hives on a factory roof, with the city behind them at sunrise',
de: 'Sechs bunte Bienenkästen auf einem Fabrikdach, dahinter die Stadt im Morgenlicht' }),
bitmap: { fileId: 'rooftop-1400.jpg', format: 'jpeg', width: 1400, height: 1848 } };
let skep = { id: 'cesto', typeId: 'foto', kind: 'bitmap', createdAt: 0, updatedAt: 0,
caption: '', altText: t({ es: 'Un cesto de paja para abejas', en: 'A straw bee skep',
de: 'Ein Bienenkorb aus Stroh' }),
contour: { threshold: 0.5, margin: mm(2.5) },
bitmap: { fileId: 'skep-720.png', format: 'png', width: 720, height: 828 } };
await loadImage('rooftop-1400.jpg', asset('rooftop-1400.jpg'));
await loadImage('skep-720.png', asset('skep-720.png'));
// The layout reads pictures by size, never by pixels: the outline travels as a trace.
const trace = await traceResourceContour(skep, imageBytes('skep-720.png'), 'image/png');
skep = withContourTrace(skep, trace);
const resources = [photo, skep];
يقرأ التنضيد الصورة بحجمها لا بنقاطها، ولذلك يُستخرج المحيط مرة واحدة من قناة ألفا في ملف PNG بـtraceResourceContour، ويرافق المورد في contour.traced. الخلية ملف PNG بعرض 720 بكسل و200 لون وخلفية شفافة (225 كيلوبايت). أما الصورة في الصفحة الزوجية فصورة من الزخرفة، resourceId: '{attr.foto}': تختار كتلة الصفحة الصورة، ويختار القالب مكانها. وفيها fit: 'cover': مهما كانت نسبة أبعاد الصورة فهي تملأ الصفحة اليسرى، ويقصّ المستطيل ما يزيد عنه.
#5 · ترويسات تُقرأ من السور
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, fontFamily: SANS, fontSize: pt(7.5), fontWeight: 600,
letterSpacing: pt(1.2), textTransform: 'uppercase', color: col('muted'),
placement: at('page', edge, x, 11), ...extra,
});
const folio = { fontWeight: 700, color: col('honey') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUT, folio),
head('verso-title', '{title}', 'even', 'top-left', OUT + 9),
head('recto-title', '{attr.seccion}', 'odd', 'top-right', -(OUT + 9)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUT, folio),
] };
تخفي صفحتا الافتتاح الترويسات (header: false)، وفي الصفحات المضافة اسم المجلة في الزوجية واسم القسم في الفردية. يأتي القسم من كتلة الصفحة، seccion="Ciudad"، ويقرؤه {attr.seccion} في الصفحات التي يضيفها النص كما يقرؤه في الافتتاح نفسه.
الوصفة كاملة
// ═══ Postext Cookbook · Nº 160 · A magazine feature threaded through frames ═════
// https://postext.dev/en/cookbook/magazine-threaded-frames
// Code: MIT · Text: original (CC BY 4.0) · Pictures: Generated With Diffusion Models
// Fonts: Literata, Fraunces, Instrument Sans (SIL OFL 1.1) · Needs postext ≥ 1.65.0
//
// A six-page feature of an invented city magazine, set as one composed page: an opening
// spread whose frames are drawn in the config, and pages the text adds as it runs on.
// Every word, the photo's id and the section name are in content.<lang>.md.
import {
buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
traceResourceContour, withContourTrace,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'es'; // @lang: the language of the sample document ('es' | 'en' | 'de')
const RECIPE = 'magazine-threaded-frames';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: honey on warm paper, every colour linked by id
const palette = {
ink: '#211c18', // text
honey: '#a65a12', // the accent: kickers, rules, the drop cap, the pull quote
tint: '#f5ecdc', // the fact box
rule: '#d8c6a6', // hairlines
muted: '#6b6158', // running heads, credits
paper: '#ffffff',
shade: '#1a1612', // the plate under the headline on the photo
};
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: 'honey (defaults)', value: { hex: palette.honey, model: 'hex' } },
];
// #endregion
const SERIF = 'Literata';
const DISPLAY = 'Fraunces';
const SANS = 'Instrument Sans';
const W = 225; // trim width in mm; the spread's sheet is twice as wide
const IN = 16; // inner margin
const OUT = 18; // outer margin
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
// The spread's content area runs from the verso's outer margin to the recto's: a frame
// on the recto starts RECTO mm in from its left edge.
const RECTO = W - OUT + IN;
const COLUMN = 92; // the two columns of the recto
const GAP = 7;
يعمل ملف script.js المجمّع كما هو: الصقه في سكربت الوحدة (module) لأي صفحة، أو افتح الوصفة على CodePen. مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)
تنويعات
#لفّ النص حول مستطيل الخلية
من دون wrap: 'contour' يزيح الإطار النص بمستطيله، فتقف الأسطر المجاورة للقبة عند حافة مستقيمة.
- { name: 'recorte', exclude: 'push', wrap: 'contour', layer: 2, width: mm(58),
+ { name: 'recorte', exclude: 'push', layer: 2, width: mm(58),#احذف علامة المتابعة
مع mark: false ينتهي الجزء المقطوع عند سطره الأخير بلا كلمة Continúa، فيتسع العمود لسطر إضافي.
- overflow: { continueIn: 'template:seguido' } },
+ overflow: { continueIn: 'template:seguido', mark: false } },أخطاء شائعة
- العنوان الذي يرسله القالب إلى إطار خاص به لا يفتح حرفًا استهلاليًا في إطارات النص. الفقرة الأولى من التحقيق ملفوفة في
:::paragraphs{style="inicio"}، والنمط هو الذي فيهdropCap.
الحقوق
- الوصفة
- Ignacio Ferro
- النص
- نص أصلي, CC BY 4.0
- الصور
- Painted hives on a factory roof at sunrise (the opening spread) · Generated With Diffusion Models · أصلي
- A straw bee skep on a transparent ground (the cut-out the text runs round) · Generated With Diffusion Models · أصلي
- الخطوط
- Literata (SIL OFL 1.1) · Fraunces (SIL OFL 1.1) · Instrument Sans (SIL OFL 1.1)
- الشيفرة
- MIT، مثل Postext
حرّر هذا الشرح ↗ (يفتح في تبويب جديد)مجلد الوصفة على GitHub ↗ (يفتح في تبويب جديد)


