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

دليل الوصفات · الفصل 9 · منشورات كاملة

كتاب أغانٍ فيه اللحن والكلمات والأكوردات

كل أغنية كتلة ABC: اللحن، وأسماء الأكوردات فوق المدرج، والمقطع الأول تحت النوتات، يُنقش كل ذلك بعرض العمود بنمط مدونة واحد.

في هذه الصفحة
المُخرَج
Canvas · PDF
المستوى
متوسط
Postext
اختُبرت مع Postext 1.54.0
تتطلب ≥ 1.54.0 · postext-pdf ≥ 1.54.0
الترخيص
حُدّثت في 22 أكتوبر 2026
الشيفرة MIT · النص CC BY 4.0
  • نموذج باللغة الإنجليزية: لا توجد طبعة عربية بعد
  • مقاس القص 148 × 210 مم
  • عمود واحد
  • Spectral 10.3/14
  • Fraunces
  • Spectral SC
  • 6 صفحات
  • المستوى
  • Postext 1.54.0
  • أُخرجت في 300 ms
  • أسطر الشيفرة: 164

باختصار

كتاب أغانٍ صغير للغناء حول المائدة. تُكتب كل أغنية نصًا عاديًا بتدوين موسيقي اسمه ABC، ويرسم Postext المدرج والنوتات وأكوردات الغيتار والكلمات تحت النوتات. وتتبعها المقاطع الأخرى في عمودين.

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

Songs for the Long Table، كتاب أغانٍ للجيب بمقاس A5: صفحة عنوان بلون الفُوّة، وكلمة إلى المغنّين فيها المحتويات، وثلاث أغانٍ، وملاحظات عن مصدر كل واحدة منها. تبدأ كل أغنية تحت رقم كبير بلون الفوّة، ثم عنوان بخط Fraunces، وسطر نسبة بحروف كبيرة مصغّرة (small capitals). وتحته يجري اللحن على مدرج ارتفاعه 5.5 mm بخط Leland، وأكوردات الغيتار فوق المازورات، والمقطع الأول تحت النوتات بخط Spectral، وهو خط النص في الكتاب. وتقف المقاطع الباقية في عمودين، فينزل المغنّي بعينه من آخر مازورة إليها مباشرة. أما Amazing Grace فأسطرها الطويلة كانت ستلتف في العمود، لذلك تُنضد مقاطعها واحدًا تحت الآخر في الوسط. والطبعة الإسبانية كتاب أغانٍ لحفلات أعياد الميلاد، فيه ثلاث أغانٍ أقصر، اثنتان في كل صفحة.

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

  • كيف أُخرج كتاب أغانٍ فيه اللحن والكلمات تحت النوتات ورموز الكوردات؟

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

script.js · الأسطر 33–50في الشيفرة الكاملة
// A song is an ```abc fence in the Markdown: the melody, its chords written "G" before the note
// they fall on, and the first verse on a w: line under it. The look is set here, once.
const scoreStyle = {
  staffSize: mm(5.5), // a songbook rastral; the words under it come out at about 8 pt
  musicFont: 'Leland', // lighter noteheads than Bravura, close to Spectral's colour
  textFont: TEXT, // words and chord names in the text face, not the engraver's Times
  spacing: 1, // the engraver's own: five or six bars of 3/4 to a system on this measure
  barNumbers: 'none', // a table of singers counts verses, not bars
  systemGap: mm(4.5), // room for the chord names between one system's words and the next
  marginTop: pt(4),
  marginBottom: pt(LEAD),
  color: col('ink'),
  minSystemsAtBreak: 2, // never a lone system at a page foot or head
};
// Two habits of Verovio's ABC reader shape the w: lines. Every sung note takes the next
// syllable in order: the `_` and `*` holds are read as nothing, so the second note of a
// slurred pair (B/G/ under "-ing") gets a no-break space, which prints nothing. A tied note
// takes none. `~` joins two syllables on one note: "de~a-trás".

المكونات

الخطوط
Spectral, Spectral SC, Fraunces (SIL OFL 1.1)
الأصول
لا شيء: كل صورة مرسومة بالشيفرة

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

#1 · اكتب الأغنية، واضبط نمط المدونة مرة واحدة

نمط المدونة هو الجواب المختصر أعلاه. في Markdown كل أغنية كتلة ```abc: تحدد أسطر الترويسة الميزان وطول النوتة والمقام؛ واسم الأكورد بين علامتي تنصيص مزدوجتين ("D7"A) يُطبع فوق النوتة التي يسبقها؛ وسطر w: تحت الموسيقى يضع مقطعًا لفظيًا واحدًا تحت كل نوتة، والمقاطع اللفظية مفصولة بشرطات. واللحن الذي له مقطع ولازمة يُكتب سطرين من الموسيقى، لكل منهما سطر w: خاص به. حجم المدرج والخط الموسيقي وخط الكلمات وأرقام المازورات والمسافة بين الأسطر الموسيقية كلها تأتي من scoreStyle، فتتطابق الأغاني الثلاث، ولا تحمل الكتل غير الموسيقى.

#2 · افتتح كل أغنية تحت رقمها وسطر نسبتها

script.js · الأسطر 66–81في الشيفرة الكاملة
// # Amazing Grace {credit="Words John Newton, 1779 · Tune New Britain, American, 1835"}
// The songs run on, three lines apart: a short song shares its page with the next one.
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const text = (id, content, font, size, color, placement, extra = {}) => ({ kind: 'text', id,
  content, fontFamily: font, fontSize: pt(size), color: col(color), align: 'left', placement,
  ...extra });
const songHead = { enabled: true, minHeight: mm(21), slot: { elements: [
  text('number', '{number}', DISPLAY, 26, 'madder', at('container', 'top-left', 0, 1),
    { fontWeight: 600, lineHeight: 1 }),
  text('title', '{titleText}', DISPLAY, 21, 'ink', { ...at('container', 'top-left', 12, 2),
    size: { width: mm(100) } }, { fontWeight: 600, lineHeight: 1.05 }),
  text('credit', '{attr.credit}', LABEL, 8.4, 'madder', { ...at('#title', 'below', 0, 2.2),
    size: { width: mm(100) } }, { fontWeight: 600, letterSpacing: pt(0.6) }),
] } };
const songs = { level: 1, numberingTemplate: '{1}', advancedDesign: songHead,
  marginTop: pt(LEAD * 3), marginBottom: pt(0), breakBefore: { enabled: false } };

الأغنية عنوان من المستوى الأول له السمة credit، ويضع تصميمه منها الرقم والعنوان وسطر النسبة. ويعطي minHeight كل أغنية رأسًا بارتفاع 21 mm، فتبدأ المدرجات على العمق نفسه في كل صفحة. تتوالى الأغاني بمسافة ثلاثة أسطر فوق كل عنوان، ولا تنقسم المدونة أبدًا قبل سطرها الموسيقي الثاني (minSystemsAtBreak: 2): تملأ كل أغنية في الطبعة الإنجليزية صفحة، وتتقاسم اثنتان من الأغاني الإسبانية القصيرة صفحة واحدة.

#3 · انضد المقاطع الأخرى في عمودين

script.js · الأسطر 54–62في الشيفرة الكاملة
// :::columns{count=2} holds one :::verse block per stanza; each line of the stanza is a
// line of Markdown, the turned lines indented two spaces (one em). A hymn in long lines
// (Amazing Grace) drops the columns: its stanzas stand one under another, centred.
const verse = { id: 'verse', fontSize: pt(9.4), lineHeight: pt(13), hyphenation: false,
  marginBottom: pt(13 / 2) };
const chorus = { id: 'chorus', fontSize: pt(9.4), lineHeight: pt(13), italic: true,
  hyphenation: false, marginBottom: pt(LEAD / 2) };
const colophon = { id: 'colophon', fontFamily: LABEL, fontSize: pt(7.8), lineHeight: pt(11),
  color: col('muted'), textAlign: 'left', firstLineIndent: pt(0), marginTop: pt(LEAD * 2) };

كل مقطع كتلة :::verse، فتنكسر أسطره حيث كسرها الشاعر، ويُزاح السطران الثاني والرابع بمقدار em واحد. وتصفّها مجموعة :::columns{count=2 gap=4mm} جنبًا إلى جنب بحجم 9.4 pt. عُدّ الحروف أولًا: أسطر Burns يتسع لها عمود عرضه 55 mm، وأسطر Newton على الوزن الطويل (long metre) لا يتسع لها، لذلك تبقى Amazing Grace كتلة :::verse واحدة في الوسط، وتفصل الأسطر الفارغة بين مقاطعها.

#4 · اجعل عناصر الصفحة الثابتة هادئة

script.js · الأسطر 119–131في الشيفرة الكاملة
const head = (id, content, parity, edge, x, style = {}) => ({
  kind: 'text', id, content, parity, pages: 'all', // a song's first page carries them too
  fontFamily: LABEL, fontSize: pt(8.4), fontWeight: 600, letterSpacing: pt(0.9),
  color: col('muted'), ...style,
  placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(12.5) } },
});
const folio = { fontFamily: TEXT, fontWeight: 600, letterSpacing: pt(0), color: col('madder') };
const header = { elements: [
  head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
  head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
  head('recto-song', '{chapterTitle}', 'odd', 'top-right', -(OUTER + 8)),
  head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };

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

الوصفة كاملة

Sandbox
// ═══ Postext Cookbook · Nº 164 · Songbook: melody, words under the notes, chords ═══════
// https://postext.dev/en/cookbook/songbook-melody-words-chords
// Code: MIT · Words and tunes: public domain (see the notes in each edition) · Prose: CC BY 4.0
// Fonts: Spectral, Spectral SC, Fraunces (SIL OFL 1.1); Leland (music) · Needs postext ≥ 1.54.0
import {
  buildDocumentWithFonts, renderPageToCanvas, initMusicEngine,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'songbook-melody-words-chords';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = { // every colour in the config links to one of these
  ink: '#211e1b', // text and notes: a warm near-black
  madder: '#8a3324', // the one accent: song numbers, the title page, credit lines
  tint: '#f1e7d8', // the subtitle on the madder ground (8.2:1)
  rule: '#cbbca6', // hairlines
  muted: '#675e55', // running heads, notes and the colophon (5.9:1 on the paper)
  paper: '#fbf8f1', // a cream stock
};
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' } })),
  // The engine's defaults link to 'main-color': point it at the accent, so nothing prints blue.
  { id: 'main-color', name: 'madder (defaults)', value: { hex: palette.madder, model: 'hex' } },
];
const [TEXT, LABEL, DISPLAY] = ['Spectral', 'Spectral SC', 'Fraunces'];
const LEAD = 14; // pt: the body's leading
const OUTER = 15; // mm: the outer margin, where the running heads and folios align

// #region answer: the score style: a 5 mm staff in Leland, the words in the book's face
// A song is an ```abc fence in the Markdown: the melody, its chords written "G" before the note
// they fall on, and the first verse on a w: line under it. The look is set here, once.
const scoreStyle = {
  staffSize: mm(5.5), // a songbook rastral; the words under it come out at about 8 pt
  musicFont: 'Leland', // lighter noteheads than Bravura, close to Spectral's colour
  textFont: TEXT, // words and chord names in the text face, not the engraver's Times
  spacing: 1, // the engraver's own: five or six bars of 3/4 to a system on this measure
  barNumbers: 'none', // a table of singers counts verses, not bars
  systemGap: mm(4.5), // room for the chord names between one system's words and the next
  marginTop: pt(4),
  marginBottom: pt(LEAD),
  color: col('ink'),
  minSystemsAtBreak: 2, // never a lone system at a page foot or head
};
// Two habits of Verovio's ABC reader shape the w: lines. Every sung note takes the next
// syllable in order: the `_` and `*` holds are read as nothing, so the second note of a

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

تنويعات

#انقش بخط Bravura

لخط Bravura رؤوس نوتات أثقل ومظهر لوح محفور، ويليق بكتاب ترانيم منضد بخط نص أغمق.

-  musicFont: 'Leland', // lighter noteheads than Bravura, close to Spectral's colour
+  musicFont: 'Bravura',

#رقّم المازورات

تتدرّب الجوقة بأرقام المازورات؛ اطبع رقمًا في بداية كل سطر موسيقي.

-  barNumbers: 'none', // a table of singers counts verses, not bars
+  barNumbers: 'system',

أخطاء شائعة

خطأ شائع

يرث نمط العنوان فاصل الصفحة من مستواه

يأخذ مُدخل headingStyles كل حقل يتركه من مستوى عنوانه، بما فيه breakBefore. فصفحة المحتويات أو صفحة بيانات النشر المنسّقة على H1 بعد :::pagebreak ترث الزوجية 'odd' وتقع بعد صفحة فارغة. أعطِ هذا النمط breakBefore: { enabled: false }. أنماط العناوين →

  • يتجاهل قارئ ABC في Verovio علامتي الإمساك _ و* في سطر w:: كل نوتة تأخذ المقطع اللفظي التالي. تحت النوتة الثانية من قوس اللحن (slur) اكتب مسافة غير قابلة للكسر (U+00A0) مقطعًا لفظيًا قائمًا بذاته، فلا يُطبع شيء. والنوتات الموصولة بقوس الإطالة (tie) لا تأخذ مقطعًا لفظيًا.
  • يجمع ~ مقطعين لفظيين تحت نوتة واحدة (de~a-trás)، لكن الناقش يطبعهما بمسافة عادية، لا بقوس وصل.
  • اكتب أسماء الأكوردات من غير ♭ أو ♯ ما استطعت: أكثر خطوط النص تخلو من هاتين العلامتين، فتلجأ الصفحة إلى خط من خطوط النظام. اختر مقامات أكورداتها طبيعية (G وC وD7 وEm)، أو اكتب «سي بيمول» بالحروف في النص.

الحقوق

الوصفة
Ignacio Ferro
النص
الخطوط
Spectral (SIL OFL 1.1) · Spectral SC (SIL OFL 1.1) · Fraunces (SIL OFL 1.1)
الشيفرة
MIT، مثل Postext
SandboxPDF