Με λίγα λόγια
Μικρό τραγουδιστάρι για τραγούδι γύρω από το τραπέζι. Κάθε τραγούδι γράφεται ως απλό κείμενο στη σημειογραφία ABC, και το Postext σχεδιάζει πεντάγραμμο, νότες, συγχορδίες κιθάρας και από κάτω τα λόγια. Οι άλλες στροφές πάνε σε δύο στήλες.
Τι θα στοιχειοθετήσετε
Το Songs for the Long Table, ένα τραγουδιστάρι τσέπης σε διάσταση σελίδας A5: μια σελίδα τίτλου σε κόκκινο του ριζαριού, ένα σημείωμα προς τους τραγουδιστές με τα περιεχόμενα, τρία τραγούδια και οι σημειώσεις για την προέλευση του καθενός. Κάθε τραγούδι ανοίγει κάτω από έναν μεγάλο αριθμό στο κόκκινο του ριζαριού, έναν τίτλο σε Fraunces και μια γραμμή με τους δημιουργούς σε μικρά κεφαλαία. Από κάτω η μελωδία τρέχει σε πεντάγραμμο 5,5 mm σε Leland, με τις συγχορδίες της κιθάρας πάνω από τα μέτρα και την πρώτη στροφή κάτω από τις νότες σε Spectral, τη γραμματοσειρά κειμένου του βιβλίου. Οι υπόλοιπες στροφές στέκονται σε δύο στήλες, έτσι ο τραγουδιστής διαβάζει κατευθείαν προς τα κάτω από το τελευταίο μέτρο. Το Amazing Grace, που οι μακριές του γραμμές θα γύριζαν σε μια στήλη, στοιχειοθετεί τις στροφές του τη μία κάτω από την άλλη, στοιχισμένες στο κέντρο. Η ισπανική έκδοση είναι ένα τραγουδιστάρι γενεθλίων με τρία πιο σύντομα τραγούδια, δύο σε κάθε σελίδα.
Αυτή η συνταγή απαντά
- Πώς στοιχειοθετώ ένα τραγουδολόγιο με τη μελωδία, τους στίχους κάτω από τις νότες και σύμβολα συγχορδιών;
Η σύντομη απάντηση
// 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".
Υλικά
- Λειτουργίες
- Μουσική σημειογραφίαΣτιλ παρτιτούραςΣτίχοι γραμμή προς γραμμήΣχεδιασμένες εναρκτήριες σελίδεςΙδιότητες επικεφαλίδωνΑριθμημένες επικεφαλίδεςΣτιλ επικεφαλίδωνΚεφάλαια χωρίς αρίθμησηΕξώφυλλα, σελίδες τίτλου και κολοφώνεςΜεταδεδομένα εγγράφουΠίνακας περιεχομένωνΤρέχουσες κεφαλίδες και αριθμοί σελίδαςΚεφαλίδες ανά ρόλο σελίδαςΣτιλ παραγράφωνΣυμμετρικά περιθώριαΣημασιολογική χρωματική παλέταΧρώμα χαρτιούΚείμενο, γραμμές και πλαίσια στις σχεδιάσεις σελίδαςΕξαγωγή PDF
- Χρησιμοποιεί επίσης
- Στήλες σε πλαίσιο ή στο κείμενοΜπλοκ κώδικαΓραμματοσειρές ενσωματωμένες στο PDFΤρέχουσες κεφαλίδες ανά ενότητα
- Γραμματοσειρές
- Spectral, Spectral SC, Fraunces (SIL OFL 1.1)
- Αρχεία
- Κανένα: κάθε εικόνα σχεδιάζεται με κώδικα
Προετοιμασία
#1 · Γράψτε το τραγούδι, δώστε στιλ στην παρτιτούρα μία φορά
Το στιλ της παρτιτούρας είναι η σύντομη απάντηση παραπάνω. Στο Markdown κάθε τραγούδι είναι ένας φράκτης ```abc: οι γραμμές της κεφαλίδας δίνουν το μέτρο, τη διάρκεια της νότας και την τονικότητα· ένα όνομα συγχορδίας σε διπλά εισαγωγικά ("D7"A) τυπώνεται πάνω από τη νότα πριν από την οποία στέκεται· μια γραμμή w: κάτω από τη μουσική βάζει μία συλλαβή κάτω από κάθε νότα, χωρισμένη με ενωτικά. Μια μελωδία με στροφή και ρεφρέν είναι δύο γραμμές μουσικής, η καθεμία με τη δική της γραμμή w:. Το μέγεθος του πενταγράμμου, η γραμματοσειρά της μουσικής, η γραμματοσειρά των στίχων, οι αριθμοί μέτρων και το κενό ανάμεσα στα συστήματα έρχονται από το scoreStyle, έτσι τα τρία τραγούδια ταιριάζουν και οι φράκτες περιέχουν μόνο μουσική.
#2 · Κάθε τραγούδι ανοίγει κάτω από τον αριθμό και τους δημιουργούς του
// # 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 · Οι άλλες στροφές σε δύο στήλες
// :::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 όχι, γι’ αυτό το Amazing Grace κρατά ένα μοναδικό μπλοκ :::verse στοιχισμένο στο κέντρο και αφήνει τις κενές γραμμές να χωρίζουν τις στροφές του.
#4 · Διακριτικά στοιχεία σελίδας
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 στα στιλ επικεφαλίδας τους.
Η πλήρης συνταγή
// ═══ 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 script οποιασδήποτε σελίδας ή ανοίξτε τη συνταγή στο 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 κληρονομεί parity 'odd' και καταλήγει πίσω από μια κενή σελίδα. Δώστε σε ένα τέτοιο στιλ breakBefore: { enabled: false }. Στιλ επικεφαλίδων →
- Ο αναγνώστης ABC του Verovio αγνοεί τα σημάδια κράτησης
_και*μιας γραμμήςw:: κάθε νότα παίρνει την επόμενη συλλαβή. Κάτω από τη δεύτερη νότα ενός λεγκάτο, γράψτε ένα αδιάσπαστο κενό (U+00A0) ως ξεχωριστή συλλαβή· δεν τυπώνει τίποτα. Οι δεμένες νότες δεν παίρνουν συλλαβή. - Το
~ενώνει δύο συλλαβές κάτω από μία νότα (de~a-trás), αλλά ο χαράκτης τις τυπώνει με ένα απλό κενό και όχι με σύνδεσμο. - Γράφετε τα ονόματα των συγχορδιών χωρίς ♭ ή ♯ όταν μπορείτε: οι περισσότερες γραμματοσειρές κειμένου δεν έχουν αυτά τα σύμβολα και η σελίδα καταφεύγει σε μια γραμματοσειρά του συστήματος. Διαλέξτε τονικότητες με φυσικές συγχορδίες (G, C, D7, Em) ή γράψτε το σι ύφεση ολογράφως στο κείμενο.
Ευχαριστίες
- Συνταγή
- Ignacio Ferro
- Κείμενο
- Amazing Grace: words (1779, five of the six stanzas, in the Olney Hymns spelling) · John Newton · κοινό κτήμα
- Amazing Grace: the tune New Britain (Southern Harmony, 1835), melody as in E. O. Excell's setting of 1900, chord symbols added · Traditional American; William Walker; Edwin O. Excell · κοινό κτήμα
- Oh My Darling, Clementine: words and tune (Oliver Ditson, Boston, 1884) · Percy Montrose · κοινό κτήμα
- Auld Lang Syne: words (1788) and the Scots tune of George Thomson's Select Songs of Scotland (1799) · Robert Burns; traditional · κοινό κτήμα
- Cumpleaños feliz: the tune of Good Morning to All (Song Stories for the Kindergarten, Chicago, 1893); Spanish words traditional · Mildred J. Hill; traditional · κοινό κτήμα
- Martinillo: the French tune of Frère Jacques (18th century) with the traditional Spanish words · Traditional · κοινό κτήμα
- La cucaracha: tune, chorus and verse as in the Spanish Wikipedia transcription; two traditional Mexican coplas · Traditional · κοινό κτήμα
- The preface, the notes on the songs and the chord symbols · Ignacio Ferro · CC BY 4.0
- Γραμματοσειρές
- Spectral (SIL OFL 1.1) · Spectral SC (SIL OFL 1.1) · Fraunces (SIL OFL 1.1)
- Κώδικας
- MIT, όπως το Postext
Επεξεργασία αυτού του κειμένου ↗ (ανοίγει σε νέα καρτέλα)Φάκελος της συνταγής στο GitHub ↗ (ανοίγει σε νέα καρτέλα)


