vexflow 5.5.0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +692 -309
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +551 -253
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/src/annotation.js +2 -1
- package/build/esm/src/continuouslayout.js +107 -16
- package/build/esm/src/continuousspan.js +6 -1
- package/build/esm/src/easyscore/composition.js +83 -18
- package/build/esm/src/factory.js +2 -9
- package/build/esm/src/formatter.js +1 -1
- package/build/esm/src/fretdiagram.js +6 -2
- package/build/esm/src/gracenotegroup.js +4 -3
- package/build/esm/src/guitarmodifiers.js +4 -1
- package/build/esm/src/metrics.js +24 -5
- package/build/esm/src/note.js +1 -0
- package/build/esm/src/notehead.js +21 -10
- package/build/esm/src/phraselayout.js +13 -5
- package/build/esm/src/publicationview.js +3 -2
- package/build/esm/src/stave.js +4 -2
- package/build/esm/src/stavenote.js +56 -13
- package/build/esm/src/stavesection.js +15 -10
- package/build/esm/src/stavetie.js +3 -2
- package/build/esm/src/strokes.js +1 -1
- package/build/esm/src/svgcontext.js +11 -3
- package/build/esm/src/tabnote.js +6 -8
- package/build/esm/src/tabtie.js +3 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/tests/chordsymbol_tests.js +4 -1
- package/build/esm/tests/demo_repertoire_tests.js +1 -1
- package/build/esm/tests/demos/electric.js +1 -3
- package/build/esm/tests/demos/greensleeves.js +1 -2
- package/build/esm/tests/demos/kesh.js +2 -3
- package/build/esm/tests/demos/saints.js +17 -5
- package/build/esm/tests/engraving/continuous-studies.mjs +24 -0
- package/build/esm/tests/engraving/publication-studies.mjs +30 -0
- package/build/esm/tests/font_tests.js +8 -0
- package/build/esm/tests/gracetabnote_tests.js +19 -3
- package/build/esm/tests/node/chord-kerning-tests.mjs +2 -2
- package/build/esm/tests/node/continuous-score-tests.mjs +157 -2
- package/build/esm/tests/node/easyscore-tests.mjs +38 -0
- package/build/esm/tests/node/engraving-layout-tests.mjs +33 -0
- package/build/esm/tests/node/instrument-profile-tests.mjs +40 -0
- package/build/esm/tests/node/local-engraving-tests.mjs +58 -0
- package/build/esm/tests/node/metrics-tests.mjs +2 -0
- package/build/esm/tests/node/phrase-layout-tests.mjs +58 -5
- package/build/esm/tests/node/publication-tests.mjs +146 -4
- package/build/esm/tests/node/svg-export-tests.mjs +50 -21
- package/build/esm/tests/scores/electric.js +3 -4
- package/build/esm/tests/scores/kesh.js +1 -1
- package/build/esm/tests/scores/saints.js +10 -8
- package/build/esm/tests/scores/sumer.js +3 -1
- package/build/esm/tests/tabnote_tests.js +43 -0
- package/build/esm/tests/vexflow_test_helpers.js +1 -0
- package/build/esm/tools/explorer/catalog/expression.mjs +16 -6
- package/build/esm/tools/explorer/catalog/guitar.mjs +2 -2
- package/build/types/src/continuouslayout.d.ts +4 -0
- package/build/types/src/continuousspan.d.ts +8 -2
- package/build/types/src/easyscore/composition.d.ts +19 -0
- package/build/types/src/fretdiagram.d.ts +2 -0
- package/build/types/src/instrumentprofile.d.ts +4 -0
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/notehead.d.ts +2 -0
- package/build/types/src/stave.d.ts +4 -2
- package/build/types/src/stavenote.d.ts +10 -0
- package/build/types/src/stavesection.d.ts +3 -0
- package/build/types/src/svgcontext.d.ts +2 -0
- package/build/types/src/typeguard.d.ts +1 -0
- package/changelog/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/tests/demos/electric.ts +1 -3
- package/tests/demos/electric.webp +0 -0
- package/tests/demos/greensleeves.ts +1 -3
- package/tests/demos/greensleeves.webp +0 -0
- package/tests/demos/kesh.ts +2 -4
- package/tests/demos/kesh.webp +0 -0
- package/tests/demos/saints.ts +20 -7
- package/tests/demos/saints.webp +0 -0
- package/tests/scores/electric.js +6 -4
- package/tests/scores/electric.webp +0 -0
- package/tests/scores/falseta.webp +0 -0
- package/tests/scores/kesh.js +1 -2
- package/tests/scores/kesh.webp +0 -0
- package/tests/scores/saints.js +11 -8
- package/tests/scores/saints.webp +0 -0
- package/tests/scores/sumer.js +8 -3
- package/tests/scores/sumer.webp +0 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Glyphs } from './glyphs.js';
|
|
1
2
|
import { Note } from './note.js';
|
|
2
3
|
import { Stem } from './stem.js';
|
|
3
4
|
import { defined, log, RuntimeError } from './util.js';
|
|
@@ -14,8 +15,8 @@ export class NoteHead extends Note {
|
|
|
14
15
|
super(noteStruct);
|
|
15
16
|
this.customGlyph = false;
|
|
16
17
|
this.ledger = {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
[Glyphs.restWhole]: Glyphs.restWholeLegerLine,
|
|
19
|
+
[Glyphs.restHalf]: Glyphs.restHalfLegerLine,
|
|
19
20
|
};
|
|
20
21
|
this.index = noteStruct.index;
|
|
21
22
|
this.x = noteStruct.x || 0;
|
|
@@ -30,18 +31,24 @@ export class NoteHead extends Note {
|
|
|
30
31
|
this.line = noteStruct.line || 0;
|
|
31
32
|
this.glyphProps = Note.getGlyphProps(this.duration, this.noteType);
|
|
32
33
|
defined(this.glyphProps, 'BadArguments', `No glyph found for duration '${this.duration}' and type '${this.noteType}'`);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.text = this.glyphProps.codeHead;
|
|
37
|
-
if (noteStruct.customGlyphCode) {
|
|
38
|
-
this.customGlyph = true;
|
|
39
|
-
this.text = noteStruct.customGlyphCode;
|
|
40
|
-
}
|
|
34
|
+
this.text = noteStruct.customGlyphCode || this.glyphProps.codeHead;
|
|
35
|
+
this.customGlyph = !!noteStruct.customGlyphCode;
|
|
36
|
+
this.updateRestGlyph();
|
|
41
37
|
this.setStyle((_b = noteStruct.style) !== null && _b !== void 0 ? _b : {});
|
|
42
38
|
this.slashed = noteStruct.slashed || false;
|
|
43
39
|
this.renderOptions = Object.assign({}, this.renderOptions);
|
|
44
40
|
}
|
|
41
|
+
updateRestGlyph() {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const plain = this.glyphProps.codeHead;
|
|
44
|
+
const ledger = this.ledger[plain];
|
|
45
|
+
if (!ledger || (this.text !== plain && this.text !== ledger))
|
|
46
|
+
return;
|
|
47
|
+
const bottomLine = 6 - ((_b = (_a = this.stave) === null || _a === void 0 ? void 0 : _a.getNumLines()) !== null && _b !== void 0 ? _b : 5);
|
|
48
|
+
const glyph = this.line > 5 || this.line < bottomLine ? ledger : plain;
|
|
49
|
+
if (this.text !== glyph)
|
|
50
|
+
this.setText(glyph);
|
|
51
|
+
}
|
|
45
52
|
getWidth() {
|
|
46
53
|
return this.width;
|
|
47
54
|
}
|
|
@@ -53,6 +60,9 @@ export class NoteHead extends Note {
|
|
|
53
60
|
}
|
|
54
61
|
setLine(line) {
|
|
55
62
|
this.line = line;
|
|
63
|
+
if (this.stave)
|
|
64
|
+
return this.setStave(this.stave);
|
|
65
|
+
this.updateRestGlyph();
|
|
56
66
|
return this;
|
|
57
67
|
}
|
|
58
68
|
getAbsoluteX() {
|
|
@@ -65,6 +75,7 @@ export class NoteHead extends Note {
|
|
|
65
75
|
setStave(stave) {
|
|
66
76
|
const line = this.getLine();
|
|
67
77
|
this.stave = stave;
|
|
78
|
+
this.updateRestGlyph();
|
|
68
79
|
if (this.stave) {
|
|
69
80
|
this.setY(this.stave.getYForNote(line));
|
|
70
81
|
this.setContext(this.stave.getContext());
|
|
@@ -5,6 +5,7 @@ import { Clef } from './clef.js';
|
|
|
5
5
|
import { measureEngraving } from './engravinggeometry.js';
|
|
6
6
|
import { GhostNote } from './ghostnote.js';
|
|
7
7
|
import { KeySignature } from './keysignature.js';
|
|
8
|
+
import { Metrics } from './metrics.js';
|
|
8
9
|
import { Modifier } from './modifier.js';
|
|
9
10
|
import { Ornament } from './ornament.js';
|
|
10
11
|
import { Barline } from './stavebarline.js';
|
|
@@ -82,6 +83,7 @@ export class PhraseLayout {
|
|
|
82
83
|
const marks = syllables.map((s, i) => {
|
|
83
84
|
var _a;
|
|
84
85
|
return new Annotation(s.text)
|
|
86
|
+
.setFont(Metrics.getFontInfo('Annotation.lyric'))
|
|
85
87
|
.setVerticalJustification(options.side === 'above' ? 'top' : 'bottom')
|
|
86
88
|
.setConnectorPadding(s.hyphenAfter || ((_a = syllables[i - 1]) === null || _a === void 0 ? void 0 : _a.hyphenAfter) ? stave.space(0.4) : 0);
|
|
87
89
|
});
|
|
@@ -96,9 +98,10 @@ export class PhraseLayout {
|
|
|
96
98
|
mark.setLayoutBaseline(undefined);
|
|
97
99
|
for (const route of this.routes)
|
|
98
100
|
route.setLayoutRise(0);
|
|
99
|
-
for (const [note, line] of this.restLines)
|
|
100
|
-
if (note.getKeyLine(0) === line.after)
|
|
101
|
+
for (const [note, line] of this.restLines) {
|
|
102
|
+
if (note.restLine === undefined && note.getKeyLine(0) === line.after)
|
|
101
103
|
note.setKeyLine(0, line.before);
|
|
104
|
+
}
|
|
102
105
|
this.restLines.clear();
|
|
103
106
|
}
|
|
104
107
|
report(code, ...owners) {
|
|
@@ -186,7 +189,11 @@ export class PhraseLayout {
|
|
|
186
189
|
if (!tuplets.has(owner))
|
|
187
190
|
this.measure(owner, stave);
|
|
188
191
|
for (const n of rests)
|
|
189
|
-
|
|
192
|
+
if (n.restLine !== undefined)
|
|
193
|
+
this.placeRest(n);
|
|
194
|
+
for (const n of rests)
|
|
195
|
+
if (n.restLine === undefined)
|
|
196
|
+
this.placeRest(n);
|
|
190
197
|
for (const m of marks)
|
|
191
198
|
this.placeAttachment(m);
|
|
192
199
|
for (const t of tuplets)
|
|
@@ -208,7 +215,8 @@ export class PhraseLayout {
|
|
|
208
215
|
this.report('UnsupportedGeometry', note);
|
|
209
216
|
let parts = original.parts;
|
|
210
217
|
const hits = this.hits(parts, stave, gap);
|
|
211
|
-
|
|
218
|
+
const pinned = note.restLine !== undefined || this.pins.has(note);
|
|
219
|
+
if (hits.length && !pinned) {
|
|
212
220
|
const sign = note.getStemDirection();
|
|
213
221
|
for (const step of [1, -1, 2, -2, 3, -3, 4, -4]) {
|
|
214
222
|
const delta = step * sign;
|
|
@@ -225,7 +233,7 @@ export class PhraseLayout {
|
|
|
225
233
|
}
|
|
226
234
|
const remaining = this.hits(parts, stave, gap);
|
|
227
235
|
if (remaining.length)
|
|
228
|
-
this.report(
|
|
236
|
+
this.report(pinned ? 'PinnedCollision' : 'UnresolvedCollision', note, remaining[0].owner);
|
|
229
237
|
this.addParts(note, stave, parts);
|
|
230
238
|
}
|
|
231
239
|
placeAttachment(mark) {
|
|
@@ -94,12 +94,13 @@ function homeStaff(staff, selected) {
|
|
|
94
94
|
}) }))) }))) });
|
|
95
95
|
}
|
|
96
96
|
export function insetStaff(staff, measure) {
|
|
97
|
-
var _a, _b, _c;
|
|
98
|
-
const state = { clef: staff.clef, key: staff.key, time: staff.time };
|
|
97
|
+
var _a, _b, _c, _d;
|
|
98
|
+
const state = { clef: staff.clef, key: staff.key, time: staff.time, showTimeSignature: staff.showTimeSignature };
|
|
99
99
|
for (const m of staff.measures.slice(0, measure - 1)) {
|
|
100
100
|
state.clef = (_a = m.clef) !== null && _a !== void 0 ? _a : state.clef;
|
|
101
101
|
state.key = (_b = m.key) !== null && _b !== void 0 ? _b : state.key;
|
|
102
102
|
state.time = (_c = m.time) !== null && _c !== void 0 ? _c : state.time;
|
|
103
|
+
state.showTimeSignature = (_d = m.showTimeSignature) !== null && _d !== void 0 ? _d : state.showTimeSignature;
|
|
103
104
|
for (const v of m.voices.slice(0, 1))
|
|
104
105
|
if (typeof v.notes !== 'string')
|
|
105
106
|
for (const item of v.notes)
|
package/build/esm/src/stave.js
CHANGED
|
@@ -30,7 +30,8 @@ export class Stave extends Element {
|
|
|
30
30
|
static get CATEGORY() {
|
|
31
31
|
return "Stave";
|
|
32
32
|
}
|
|
33
|
-
setBoundaryModifiers(modifiers) {
|
|
33
|
+
setBoundaryModifiers(modifiers, notePadding = 0) {
|
|
34
|
+
this.boundaryNotePadding = notePadding;
|
|
34
35
|
this.boundaryModifiers = modifiers;
|
|
35
36
|
for (const mark of modifiers)
|
|
36
37
|
mark.setStave(this);
|
|
@@ -46,6 +47,7 @@ export class Stave extends Element {
|
|
|
46
47
|
var _a;
|
|
47
48
|
super();
|
|
48
49
|
this.boundaryModifiers = [];
|
|
50
|
+
this.boundaryNotePadding = 0;
|
|
49
51
|
this.x = x;
|
|
50
52
|
this.y = y;
|
|
51
53
|
this.width = width;
|
|
@@ -429,7 +431,7 @@ export class Stave extends Element {
|
|
|
429
431
|
if (padding + width === 0)
|
|
430
432
|
offset--;
|
|
431
433
|
}
|
|
432
|
-
this.startX = x;
|
|
434
|
+
this.startX = x + this.boundaryNotePadding;
|
|
433
435
|
x = this.x + this.width;
|
|
434
436
|
const widths = {
|
|
435
437
|
left: 0,
|
|
@@ -9,6 +9,10 @@ import { Stem } from './stem.js';
|
|
|
9
9
|
import { StemmableNote } from './stemmablenote.js';
|
|
10
10
|
import { Tables } from './tables.js';
|
|
11
11
|
import { defined, log, midLine, RuntimeError } from './util.js';
|
|
12
|
+
const bravuraSlashAnchors = {
|
|
13
|
+
[Glyphs.noteheadSlashVerticalEnds]: { up: [1.46, 0.656], down: [0, -0.664] },
|
|
14
|
+
[Glyphs.noteheadSlashWhiteHalf]: { up: [3.12, 1], down: [0, -1] },
|
|
15
|
+
};
|
|
12
16
|
function L(...args) {
|
|
13
17
|
if (StaveNote.DEBUG)
|
|
14
18
|
log('VexFlow.StaveNote', args);
|
|
@@ -81,7 +85,18 @@ export class StaveNote extends StemmableNote {
|
|
|
81
85
|
const visible = notesList.filter((item) => item.note.renderOptions.draw !== false);
|
|
82
86
|
if (visible.length < 2)
|
|
83
87
|
return true;
|
|
84
|
-
|
|
88
|
+
const positioned = visible.some(({ note }) => note.restLine !== undefined);
|
|
89
|
+
if (positioned && visible.length <= 3) {
|
|
90
|
+
for (const rest of visible.filter((v) => v.isrest && v.note.restLine === undefined)) {
|
|
91
|
+
const direction = rest.note.getStemDirection();
|
|
92
|
+
const peers = visible.filter((v) => v !== rest).sort((a, b) => direction * (a.minLine - b.minLine));
|
|
93
|
+
for (const peer of peers) {
|
|
94
|
+
if (rest.minLine <= peer.maxLine && peer.minLine <= rest.maxLine)
|
|
95
|
+
shiftRestVertical(rest, peer, direction);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (visible.length > 3 || positioned) {
|
|
85
100
|
const columns = [];
|
|
86
101
|
for (const item of visible.sort((a, b) => b.maxLine - a.maxLine || b.line - a.line)) {
|
|
87
102
|
let column = columns.find((entry) => item.maxLine + 0.5 < entry.bottom);
|
|
@@ -276,6 +291,8 @@ export class StaveNote extends StemmableNote {
|
|
|
276
291
|
else {
|
|
277
292
|
this.setStemDirection((_e = noteStruct.stemDirection) !== null && _e !== void 0 ? _e : Stem.UP);
|
|
278
293
|
}
|
|
294
|
+
if (noteStruct.restLine !== undefined)
|
|
295
|
+
this.setRestLine(noteStruct.restLine);
|
|
279
296
|
if (this.notation.length)
|
|
280
297
|
attachGuitarGestures(this);
|
|
281
298
|
}
|
|
@@ -473,21 +490,31 @@ export class StaveNote extends StemmableNote {
|
|
|
473
490
|
hasFlag() {
|
|
474
491
|
return super.hasFlag() && !this.isRest();
|
|
475
492
|
}
|
|
476
|
-
|
|
493
|
+
stemAnchor(head, direction) {
|
|
477
494
|
var _a;
|
|
495
|
+
const family = head.fontInfo.family;
|
|
496
|
+
if (((_a = this.engraving) === null || _a === void 0 ? void 0 : _a.musicFont) === family) {
|
|
497
|
+
const anchor = this.engraving.stemAnchor(head.text, direction);
|
|
498
|
+
if (anchor)
|
|
499
|
+
return anchor;
|
|
500
|
+
}
|
|
501
|
+
const slash = bravuraSlashAnchors[head.text];
|
|
502
|
+
if (slash && /^\s*(?:Bravura|"Bravura"|'Bravura')\s*(?:,|$)/i.test(family))
|
|
503
|
+
return slash[direction];
|
|
504
|
+
}
|
|
505
|
+
getStemX() {
|
|
478
506
|
if (this.noteType === 'r') {
|
|
479
507
|
return this.getCenterGlyphX();
|
|
480
508
|
}
|
|
481
509
|
else {
|
|
482
510
|
const up = this.stemDirection === Stem.UP;
|
|
483
|
-
const head = this.
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
((up ? -1 : 1) * Stem.WIDTH) / 2);
|
|
511
|
+
const head = this._noteHeads.find((h) => !h.isDisplaced());
|
|
512
|
+
const anchor = head && this.stemAnchor(head, up ? 'up' : 'down');
|
|
513
|
+
if (head && anchor) {
|
|
514
|
+
return (this.getNoteHeadBeginX() +
|
|
515
|
+
head.getXShift() +
|
|
516
|
+
(anchor[0] * head.fontSizeInPixels) / 4 +
|
|
517
|
+
((up ? -1 : 1) * Stem.WIDTH) / 2);
|
|
491
518
|
}
|
|
492
519
|
return super.getStemX() + (this.stemDirection ? Stem.WIDTH / (2 * -this.stemDirection) : 0);
|
|
493
520
|
}
|
|
@@ -628,6 +655,24 @@ export class StaveNote extends StemmableNote {
|
|
|
628
655
|
this._noteHeads[index].setStyle(style);
|
|
629
656
|
return this;
|
|
630
657
|
}
|
|
658
|
+
get restLine() {
|
|
659
|
+
return this.lineBeforeRestPin === undefined ? undefined : this.getKeyLine(0);
|
|
660
|
+
}
|
|
661
|
+
setRestLine(line) {
|
|
662
|
+
var _a;
|
|
663
|
+
if (!this.isRest() || (line !== undefined && !Number.isFinite(line)))
|
|
664
|
+
throw new RuntimeError('BadArguments', 'Rest positioning requires a rest and a finite line.');
|
|
665
|
+
if (line !== undefined) {
|
|
666
|
+
(_a = this.lineBeforeRestPin) !== null && _a !== void 0 ? _a : (this.lineBeforeRestPin = this.getKeyLine(0));
|
|
667
|
+
return this.setKeyLine(0, line);
|
|
668
|
+
}
|
|
669
|
+
if (this.lineBeforeRestPin !== undefined) {
|
|
670
|
+
const previous = this.lineBeforeRestPin;
|
|
671
|
+
this.lineBeforeRestPin = undefined;
|
|
672
|
+
this.setKeyLine(0, previous);
|
|
673
|
+
}
|
|
674
|
+
return this;
|
|
675
|
+
}
|
|
631
676
|
setKeyLine(index, line) {
|
|
632
677
|
this.keyProps[index].line = line;
|
|
633
678
|
this.reset();
|
|
@@ -668,9 +713,7 @@ export class StaveNote extends StemmableNote {
|
|
|
668
713
|
this._noteHeads.forEach((nh) => {
|
|
669
714
|
const offset = Tables.noteHeadStemYOffsets[nh.text];
|
|
670
715
|
const anchor = offset ? offset[anchorKey] : 0;
|
|
671
|
-
const fontAnchor = this.
|
|
672
|
-
? this.engraving.stemAnchor(nh.text, anchorKey)
|
|
673
|
-
: undefined;
|
|
716
|
+
const fontAnchor = this.stemAnchor(nh, anchorKey);
|
|
674
717
|
const y = nh.getY() - (fontAnchor ? (fontAnchor[1] * nh.fontSizeInPixels) / 4 : anchor * Tables.STAVE_LINE_DISTANCE);
|
|
675
718
|
yTop = Math.min(y, yTop);
|
|
676
719
|
yBottom = Math.max(y, yBottom);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BoundingBox } from './boundingbox.js';
|
|
1
2
|
import { Metrics } from './metrics.js';
|
|
2
3
|
import { StaveModifier } from './stavemodifier.js';
|
|
3
4
|
export class StaveSection extends StaveModifier {
|
|
@@ -16,21 +17,25 @@ export class StaveSection extends StaveModifier {
|
|
|
16
17
|
this.drawRect = drawRect;
|
|
17
18
|
return this;
|
|
18
19
|
}
|
|
20
|
+
getBoundingBox() {
|
|
21
|
+
if (this.stave) {
|
|
22
|
+
this.x = this.stave.getX() + this.stave.getModifierXShift(this.getPosition()) + this.padding;
|
|
23
|
+
this.y = this.stave.getYForTopText(1.5) - this.padding;
|
|
24
|
+
}
|
|
25
|
+
const ink = this.getTextInk(this.x, this.y);
|
|
26
|
+
if (!this.drawRect)
|
|
27
|
+
return ink;
|
|
28
|
+
return new BoundingBox(ink.x - this.padding, ink.y - this.padding, ink.w + 2 * this.padding, ink.h + 2 * this.padding);
|
|
29
|
+
}
|
|
19
30
|
draw() {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
31
|
+
const ctx = this.checkStave().checkContext();
|
|
32
|
+
const bounds = this.getBoundingBox();
|
|
22
33
|
this.setRendered();
|
|
23
|
-
this.x = stave.getX() + stave.getModifierXShift(this.getPosition());
|
|
24
|
-
const headroom = -1 * this.textMetrics.actualBoundingBoxDescent;
|
|
25
|
-
const width = this.width + 2 * this.padding;
|
|
26
|
-
const height = this.height + 2 * this.padding;
|
|
27
|
-
const y = stave.getYForTopText(1.5) + this.yShift;
|
|
28
|
-
const x = this.x + this.xShift;
|
|
29
34
|
if (this.drawRect) {
|
|
30
35
|
ctx.beginPath();
|
|
31
|
-
ctx.rect(x, y
|
|
36
|
+
ctx.rect(bounds.x, bounds.y, bounds.w, bounds.h);
|
|
32
37
|
ctx.stroke();
|
|
33
38
|
}
|
|
34
|
-
this.renderText(ctx,
|
|
39
|
+
this.renderText(ctx, 0, 0);
|
|
35
40
|
}
|
|
36
41
|
}
|
|
@@ -155,12 +155,13 @@ export class StaveTie extends Element {
|
|
|
155
155
|
renderTieText(firstX, lastX) {
|
|
156
156
|
var _a, _b, _c;
|
|
157
157
|
const ctx = this.checkContext();
|
|
158
|
-
let centerX = (firstX + lastX) / 2;
|
|
159
|
-
centerX -= ctx.measureText(this.text).width / 2;
|
|
160
158
|
const stave = (_b = (_a = this.notes.firstNote) === null || _a === void 0 ? void 0 : _a.checkStave()) !== null && _b !== void 0 ? _b : (_c = this.notes.lastNote) === null || _c === void 0 ? void 0 : _c.checkStave();
|
|
161
159
|
if (stave) {
|
|
160
|
+
ctx.save();
|
|
162
161
|
ctx.setFont(this.fontInfo);
|
|
162
|
+
const centerX = (firstX + lastX - ctx.measureText(this.text).width) / 2;
|
|
163
163
|
ctx.fillText(this.text, centerX + this.renderOptions.textShiftX, stave.getYForTopText() - 1);
|
|
164
|
+
ctx.restore();
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
getNotes() {
|
package/build/esm/src/strokes.js
CHANGED
|
@@ -66,7 +66,7 @@ export class Stroke extends Modifier {
|
|
|
66
66
|
let yPositions = note.getYs();
|
|
67
67
|
let topY = start.y;
|
|
68
68
|
let botY = start.y;
|
|
69
|
-
const x = start.x - 5;
|
|
69
|
+
const x = start.x - 5 - (isTabNote(note) ? Metrics.get('NoteHead.minPadding') : 0);
|
|
70
70
|
const lineSpace = note.checkStave().getSpacingBetweenLines();
|
|
71
71
|
const notes = this.checkModifierContext().getMembers(note.getCategory());
|
|
72
72
|
for (let i = 0; i < notes.length; i++) {
|
|
@@ -358,17 +358,25 @@ export class SVGContext extends RenderContext {
|
|
|
358
358
|
}
|
|
359
359
|
save() {
|
|
360
360
|
this.stateStack.push({
|
|
361
|
+
font: this.fontCSSString,
|
|
361
362
|
state: structuredClone(this.state),
|
|
362
363
|
attributes: structuredClone(this.attributes),
|
|
363
364
|
});
|
|
364
365
|
return this;
|
|
365
366
|
}
|
|
366
367
|
restore() {
|
|
368
|
+
var _a;
|
|
367
369
|
const savedState = this.stateStack.pop();
|
|
368
370
|
if (savedState) {
|
|
369
|
-
|
|
370
|
-
this.
|
|
371
|
-
this.
|
|
371
|
+
this.state = structuredClone(savedState.state);
|
|
372
|
+
this.attributes = structuredClone(savedState.attributes);
|
|
373
|
+
this.fontCSSString =
|
|
374
|
+
(_a = savedState.font) !== null && _a !== void 0 ? _a : Font.toCSSString({
|
|
375
|
+
family: this.attributes['font-family'],
|
|
376
|
+
size: this.attributes['font-size'],
|
|
377
|
+
weight: this.attributes['font-weight'],
|
|
378
|
+
style: this.attributes['font-style'],
|
|
379
|
+
});
|
|
372
380
|
}
|
|
373
381
|
return this;
|
|
374
382
|
}
|
package/build/esm/src/tabnote.js
CHANGED
|
@@ -155,6 +155,8 @@ export class TabNote extends StemmableNote {
|
|
|
155
155
|
this.fretElement.push(el);
|
|
156
156
|
this.width = Math.max(el.getWidth(), this.width);
|
|
157
157
|
}
|
|
158
|
+
this.setLeftDisplacedHeadPx(this.width / 2);
|
|
159
|
+
this.setRightDisplacedHeadPx(this.width / 2);
|
|
158
160
|
}
|
|
159
161
|
setStave(stave) {
|
|
160
162
|
super.setStave(stave);
|
|
@@ -177,19 +179,15 @@ export class TabNote extends StemmableNote {
|
|
|
177
179
|
if (this.ys.length === 0) {
|
|
178
180
|
throw new RuntimeError('NoYValues', 'No Y-Values calculated for this note.');
|
|
179
181
|
}
|
|
180
|
-
let x =
|
|
182
|
+
let x = this.getAbsoluteX();
|
|
181
183
|
if (position === Modifier.Position.LEFT) {
|
|
182
|
-
x =
|
|
184
|
+
x = this.getTieLeftX();
|
|
183
185
|
}
|
|
184
186
|
else if (position === Modifier.Position.RIGHT) {
|
|
185
|
-
x = this.
|
|
186
|
-
}
|
|
187
|
-
else if (position === Modifier.Position.BELOW || position === Modifier.Position.ABOVE) {
|
|
188
|
-
const noteGlyphWidth = this.width;
|
|
189
|
-
x = noteGlyphWidth / 2;
|
|
187
|
+
x = this.getTieRightX();
|
|
190
188
|
}
|
|
191
189
|
return {
|
|
192
|
-
x
|
|
190
|
+
x,
|
|
193
191
|
y: this.ys[index],
|
|
194
192
|
};
|
|
195
193
|
}
|
package/build/esm/src/tabtie.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Metrics } from './metrics.js';
|
|
1
2
|
import { StaveTie } from './stavetie.js';
|
|
2
3
|
export class TabTie extends StaveTie {
|
|
3
4
|
static get CATEGORY() {
|
|
@@ -11,6 +12,8 @@ export class TabTie extends StaveTie {
|
|
|
11
12
|
}
|
|
12
13
|
constructor(notes, text) {
|
|
13
14
|
super(notes, text);
|
|
15
|
+
if (text && /^[a-z]$/i.test(text))
|
|
16
|
+
this.setFont(Metrics.getFontInfo('TabTie.techniqueLetter'));
|
|
14
17
|
this.renderOptions.cp1 = 9;
|
|
15
18
|
this.renderOptions.cp2 = 11;
|
|
16
19
|
this.renderOptions.yShift = 3;
|
package/build/esm/src/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const VERSION = '5.
|
|
2
|
-
export const ID = '
|
|
3
|
-
export const DATE = '2026-11-
|
|
1
|
+
export const VERSION = '5.6.0';
|
|
2
|
+
export const ID = '39cf287f300f0ef6bd9b63cbf1d01ef0bbbd1c10';
|
|
3
|
+
export const DATE = '2026-11-19T20:58:10.569Z';
|
|
@@ -377,7 +377,8 @@ function doubleBottom(options) {
|
|
|
377
377
|
options.assert.ok(true, '2 Bottom Chord Symbol');
|
|
378
378
|
}
|
|
379
379
|
function wide(options) {
|
|
380
|
-
const
|
|
380
|
+
const pageWidth = 370;
|
|
381
|
+
const f = VexFlowTests.makeFactory(options, pageWidth * 1.5, 680);
|
|
381
382
|
const ctx = f.getContext();
|
|
382
383
|
ctx.scale(1.5, 1.5);
|
|
383
384
|
function draw(chord1, chord2, y) {
|
|
@@ -387,6 +388,8 @@ function wide(options) {
|
|
|
387
388
|
note(f, ['c/4', 'e/4', 'B/4'], 'h', chord2),
|
|
388
389
|
];
|
|
389
390
|
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
391
|
+
const last = chord2.getBoundingBox();
|
|
392
|
+
options.assert.ok(last.x + last.w < pageWidth, 'The final chord and its extension fit on the page');
|
|
390
393
|
}
|
|
391
394
|
let chord1 = f.ChordSymbol().addText('FrogToad7').setHorizontal('left').addGlyphOrText('(#11b9)', superscript);
|
|
392
395
|
let chord2 = f.ChordSymbol({ hJustify: 'left' }).addText('CToShiningC').addGlyphSuperscript('majorSeventh');
|
|
@@ -10,7 +10,7 @@ import { prelude } from './demos/prelude.js';
|
|
|
10
10
|
import { quartertones } from './demos/quartertones.js';
|
|
11
11
|
import { saints } from './demos/saints.js';
|
|
12
12
|
const repertoire = [
|
|
13
|
-
{ title: 'When the Saints Go Marching In', render: saints, fonts: ['Petaluma'] },
|
|
13
|
+
{ title: 'When the Saints Go Marching In', render: saints, fonts: ['Petaluma with Academico'] },
|
|
14
14
|
{ title: 'Greensleeves', render: greensleeves },
|
|
15
15
|
{ title: 'Prelude in C major', render: prelude },
|
|
16
16
|
{ title: 'Fugue No. 6 in D minor', render: fugue },
|
|
@@ -26,9 +26,7 @@ export function electric(options) {
|
|
|
26
26
|
stave.addTimeSignature('4/4').setTempo({ duration: 'q', bpm: 96 }, -8);
|
|
27
27
|
if (i === 3)
|
|
28
28
|
stave.setEndBarType(BarlineType.END);
|
|
29
|
-
const legato = (start, label) => score.make
|
|
30
|
-
.tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label)
|
|
31
|
-
.setFont('Arial, Helvetica, sans-serif', 9, 'bold');
|
|
29
|
+
const legato = (start, label) => score.make.tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label);
|
|
32
30
|
if (i === 0) {
|
|
33
31
|
score.beam(notes.slice(1, 3));
|
|
34
32
|
legato(1, 'H');
|
|
@@ -22,7 +22,6 @@ const positions = {
|
|
|
22
22
|
export function greensleeves(options) {
|
|
23
23
|
const f = VexFlowTests.makeFactory(options, 900, 486);
|
|
24
24
|
const score = f.EasyScore({ throwOnError: true });
|
|
25
|
-
const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
|
|
26
25
|
const bars = [
|
|
27
26
|
['', 'A4/q'],
|
|
28
27
|
['Am', 'A3+E4+A4+C5/h D5/q'],
|
|
@@ -49,7 +48,7 @@ export function greensleeves(options) {
|
|
|
49
48
|
});
|
|
50
49
|
const notes = score.notes(music.join(', '));
|
|
51
50
|
if (chordName)
|
|
52
|
-
notes[0].addModifier(score.make.chordSymbol(
|
|
51
|
+
notes[0].addModifier(score.make.chordSymbol().addText(chordName));
|
|
53
52
|
const tab = events.map(({ pitches, duration }) => score.make.tabNote({
|
|
54
53
|
positions: pitches.map((pitch) => {
|
|
55
54
|
const [str, fret] = positions[pitch];
|
|
@@ -4,7 +4,6 @@ export function kesh(options) {
|
|
|
4
4
|
const f = VexFlowTests.makeFactory(options, 900, 580);
|
|
5
5
|
const score = f.EasyScore({ throwOnError: true });
|
|
6
6
|
score.set({ time: '6/8' });
|
|
7
|
-
const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
|
|
8
7
|
const strains = [
|
|
9
8
|
[
|
|
10
9
|
['G4/q, G4/8', 'G4/8, A4, B4', 'G'],
|
|
@@ -44,9 +43,9 @@ export function kesh(options) {
|
|
|
44
43
|
score.beam(beat);
|
|
45
44
|
}
|
|
46
45
|
if (chord)
|
|
47
|
-
beats[0][0].addModifier(score.make.chordSymbol(
|
|
46
|
+
beats[0][0].addModifier(score.make.chordSymbol().addText(chord));
|
|
48
47
|
if (nextChord)
|
|
49
|
-
beats[1][0].addModifier(score.make.chordSymbol(
|
|
48
|
+
beats[1][0].addModifier(score.make.chordSymbol().addText(nextChord));
|
|
50
49
|
if (i === 0 || i === 4) {
|
|
51
50
|
const grace = score.make.graceNote({ keys: [part ? 'd/5' : 'b/4'], duration: '8', slash: true });
|
|
52
51
|
notes[1].addModifier(score.make.graceNoteGroup({ notes: [grace], slur: true }));
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { VexFlowTests } from '../vexflow_test_helpers.js';
|
|
2
2
|
import { BarlineType, ChordSymbol } from '../../src/index.js';
|
|
3
|
+
import { Metrics } from '../../src/metrics.js';
|
|
3
4
|
export function saints(options) {
|
|
4
5
|
const factory = VexFlowTests.makeFactory(options, 900, 540);
|
|
5
6
|
const score = factory.EasyScore({ throwOnError: true });
|
|
7
|
+
const lyricFont = Metrics.getFontInfo('Annotation.lyric');
|
|
8
|
+
const word = (text, rowY) => factory
|
|
9
|
+
.Annotation({ text, font: lyricFont, vJustify: 'bottom' })
|
|
10
|
+
.setTextBaseline(rowY + 116)
|
|
11
|
+
.setConnectorPadding(2);
|
|
6
12
|
const bars = [
|
|
7
13
|
['G4/w', 'saints', 'C:6/9'],
|
|
8
14
|
['B4/q/r, C4/q, E4, F4', '|go|march-|ing', 'Am:7'],
|
|
@@ -23,18 +29,23 @@ export function saints(options) {
|
|
|
23
29
|
];
|
|
24
30
|
const pickup = score.notes('C4/q, E4, F4');
|
|
25
31
|
const pickupLabels = ['Oh', 'when', 'the'];
|
|
26
|
-
pickup.forEach((note, i) => note.addModifier(
|
|
32
|
+
pickup.forEach((note, i) => note.addModifier(word(pickupLabels[i], 16)));
|
|
33
|
+
const pickupWidth = 210;
|
|
27
34
|
factory
|
|
28
|
-
.System({ x: 10, y: 16, width:
|
|
35
|
+
.System({ x: 10, y: 16, width: pickupWidth })
|
|
29
36
|
.addStave({ voices: [score.voice(pickup, { time: '3/4' })] })
|
|
30
37
|
.addClef('treble')
|
|
31
38
|
.addTimeSignature('4/4');
|
|
39
|
+
const openingWidths = [120, 212, 122, 212];
|
|
40
|
+
let x = 10 + pickupWidth;
|
|
32
41
|
let sustained;
|
|
33
42
|
bars.forEach(([music, words, harmony], i) => {
|
|
34
43
|
const row = Math.floor(i / 4);
|
|
35
44
|
const column = i % 4;
|
|
36
45
|
const y = 16 + row * 130;
|
|
37
|
-
|
|
46
|
+
if (column === 0 && row > 0)
|
|
47
|
+
x = 10;
|
|
48
|
+
const width = row === 0 ? openingWidths[column] : 219;
|
|
38
49
|
const notes = score.notes(music);
|
|
39
50
|
if (i === 5 || i === 14)
|
|
40
51
|
sustained = notes[0];
|
|
@@ -42,7 +53,7 @@ export function saints(options) {
|
|
|
42
53
|
score.make.tie({ from: sustained, to: notes[0] });
|
|
43
54
|
words.split('|').forEach((text, n) => {
|
|
44
55
|
if (text)
|
|
45
|
-
notes[n].addModifier(
|
|
56
|
+
notes[n].addModifier(word(text, y));
|
|
46
57
|
});
|
|
47
58
|
if (harmony) {
|
|
48
59
|
const [root, extension] = harmony.split(':');
|
|
@@ -53,8 +64,9 @@ export function saints(options) {
|
|
|
53
64
|
notes[0].addModifier(chord);
|
|
54
65
|
}
|
|
55
66
|
const stave = factory
|
|
56
|
-
.System({ x
|
|
67
|
+
.System({ x, y, width })
|
|
57
68
|
.addStave({ voices: [score.voice(notes, { time: i === 15 ? '1/4' : '4/4' })] });
|
|
69
|
+
x += width;
|
|
58
70
|
if (column === 0 && row > 0)
|
|
59
71
|
stave.addClef('treble');
|
|
60
72
|
if (i === bars.length - 1)
|
|
@@ -138,3 +138,27 @@ export function makeContinuousStudy(VF, factory, kind, width, mode = 'balanced')
|
|
|
138
138
|
result.getNote('v00').addModifier(factory.Annotation({ text: 'Sing' }), 0);
|
|
139
139
|
return result;
|
|
140
140
|
}
|
|
141
|
+
export function tabEndingStudy() {
|
|
142
|
+
const positions = [
|
|
143
|
+
{ str: 1, fret: 12 },
|
|
144
|
+
{ str: 2, fret: 10 },
|
|
145
|
+
];
|
|
146
|
+
return {
|
|
147
|
+
staves: [
|
|
148
|
+
{
|
|
149
|
+
id: 'guitar',
|
|
150
|
+
kind: 'tab',
|
|
151
|
+
time: '1/4',
|
|
152
|
+
measures: [positions, [...positions].reverse()].map((chord, i) => ({
|
|
153
|
+
voices: [{ notes: [{ id: 'tab' + i, tab: { duration: 'q', positions: chord } }] }],
|
|
154
|
+
})),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
continuous: {
|
|
158
|
+
spans: [
|
|
159
|
+
{ id: 'hold', kind: 'tie', from: 'tab0', to: 'tab1', fromHead: 1 },
|
|
160
|
+
{ id: 'ending', kind: 'volta', from: 'tab0', to: 'tab1', text: '1.' },
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -85,3 +85,33 @@ export function publicationStudy(part, paper) {
|
|
|
85
85
|
: {}));
|
|
86
86
|
return { source, options };
|
|
87
87
|
}
|
|
88
|
+
export function leadSheetStudy() {
|
|
89
|
+
const measure = (id, pitches) => ({
|
|
90
|
+
voices: [
|
|
91
|
+
{
|
|
92
|
+
notes: pitches.map((key, i) => ({ id: id + i, note: { keys: [key], duration: '8' } })),
|
|
93
|
+
autoBeam: true,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
});
|
|
97
|
+
const first = measure('a', ['c/4', 'd/4', 'e/4', 'g/4', 'a/4', 'g/4']);
|
|
98
|
+
const second = measure('b', ['e/4', 'f/4', 'g/4', 'f/4', 'e/4', 'c/4']);
|
|
99
|
+
first.chords = [{ note: 'a0', text: 'Cmaj7' }];
|
|
100
|
+
first.verses = [
|
|
101
|
+
[
|
|
102
|
+
{ note: 'a0', text: 'Day', hyphenAfter: true },
|
|
103
|
+
{ note: 'a3', text: 'light', extendTo: 'a5' },
|
|
104
|
+
],
|
|
105
|
+
];
|
|
106
|
+
first.endBarline = VexFlow.Barline.type.DOUBLE;
|
|
107
|
+
second.endBarline = VexFlow.Barline.type.END;
|
|
108
|
+
const lead = { id: 'lead', time: '6/8', showTimeSignature: false, measures: [first, second] };
|
|
109
|
+
const bass = {
|
|
110
|
+
id: 'bass',
|
|
111
|
+
clef: 'bass',
|
|
112
|
+
time: '6/8',
|
|
113
|
+
showTimeSignature: false,
|
|
114
|
+
measures: [0, 1].map(() => ({ voices: [{ notes: 'C3/q., G3/q.' }] })),
|
|
115
|
+
};
|
|
116
|
+
return { staves: [lead, bass], continuous: {} };
|
|
117
|
+
}
|