vexflow 5.4.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.
Files changed (127) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +1740 -372
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +565 -258
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow.js +2 -2
  10. package/build/cjs/vexflow.js.map +1 -1
  11. package/build/esm/src/annotation.js +2 -1
  12. package/build/esm/src/continuouslayout.js +107 -16
  13. package/build/esm/src/continuousspan.js +9 -1
  14. package/build/esm/src/easyscore/composition.js +83 -18
  15. package/build/esm/src/factory.js +2 -9
  16. package/build/esm/src/formatter.js +1 -1
  17. package/build/esm/src/fretdiagram.js +6 -2
  18. package/build/esm/src/gracenotegroup.js +4 -3
  19. package/build/esm/src/guitarmodifiers.js +4 -1
  20. package/build/esm/src/metrics.js +24 -5
  21. package/build/esm/src/note.js +1 -0
  22. package/build/esm/src/notehead.js +21 -10
  23. package/build/esm/src/phraselayout.js +13 -5
  24. package/build/esm/src/publication.js +10 -5
  25. package/build/esm/src/publicationview.js +3 -2
  26. package/build/esm/src/stave.js +4 -2
  27. package/build/esm/src/stavenote.js +56 -13
  28. package/build/esm/src/stavesection.js +15 -10
  29. package/build/esm/src/stavetie.js +3 -2
  30. package/build/esm/src/strokes.js +1 -1
  31. package/build/esm/src/svgcontext.js +11 -3
  32. package/build/esm/src/tabnote.js +6 -8
  33. package/build/esm/src/tabtie.js +3 -0
  34. package/build/esm/src/version.js +3 -3
  35. package/build/esm/tests/chordsymbol_tests.js +4 -1
  36. package/build/esm/tests/demo_petzold_tests.js +26 -14
  37. package/build/esm/tests/demo_repertoire_tests.js +5 -1
  38. package/build/esm/tests/demos/ballade.js +15 -0
  39. package/build/esm/tests/demos/electric.js +1 -3
  40. package/build/esm/tests/demos/fugue.js +19 -0
  41. package/build/esm/tests/demos/greensleeves.js +1 -2
  42. package/build/esm/tests/demos/kesh.js +2 -3
  43. package/build/esm/tests/demos/saints.js +17 -5
  44. package/build/esm/tests/engraving/continuous-studies.mjs +24 -0
  45. package/build/esm/tests/engraving/publication-studies.mjs +30 -0
  46. package/build/esm/tests/font_tests.js +8 -0
  47. package/build/esm/tests/gracenote_tests.js +1 -1
  48. package/build/esm/tests/gracetabnote_tests.js +19 -3
  49. package/build/esm/tests/node/chord-kerning-tests.mjs +2 -2
  50. package/build/esm/tests/node/continuous-score-tests.mjs +157 -2
  51. package/build/esm/tests/node/easyscore-tests.mjs +38 -0
  52. package/build/esm/tests/node/engraving-layout-tests.mjs +33 -0
  53. package/build/esm/tests/node/instrument-profile-tests.mjs +40 -0
  54. package/build/esm/tests/node/local-engraving-tests.mjs +58 -0
  55. package/build/esm/tests/node/metrics-tests.mjs +2 -0
  56. package/build/esm/tests/node/phrase-layout-tests.mjs +58 -5
  57. package/build/esm/tests/node/publication-tests.mjs +158 -2
  58. package/build/esm/tests/node/svg-export-tests.mjs +50 -21
  59. package/build/esm/tests/scores/ballade.js +399 -0
  60. package/build/esm/tests/scores/drums.js +93 -0
  61. package/build/esm/tests/scores/electric.js +83 -0
  62. package/build/esm/tests/scores/falseta.js +46 -0
  63. package/build/esm/tests/scores/fugue.js +366 -0
  64. package/build/esm/tests/scores/guitar.js +32 -0
  65. package/build/esm/tests/scores/kesh.js +146 -0
  66. package/build/esm/tests/scores/prelude.js +84 -0
  67. package/build/esm/tests/scores/quartertones.js +78 -0
  68. package/build/esm/tests/scores/saints.js +70 -0
  69. package/build/esm/tests/scores/sumer.js +126 -0
  70. package/build/esm/tests/scores/viewer.js +162 -0
  71. package/build/esm/tests/tabnote_tests.js +43 -0
  72. package/build/esm/tests/vexflow_test_helpers.js +1 -0
  73. package/build/esm/tools/explorer/catalog/expression.mjs +16 -6
  74. package/build/esm/tools/explorer/catalog/guitar.mjs +2 -2
  75. package/build/types/src/continuouslayout.d.ts +4 -0
  76. package/build/types/src/continuousspan.d.ts +10 -2
  77. package/build/types/src/easyscore/composition.d.ts +19 -0
  78. package/build/types/src/fretdiagram.d.ts +2 -0
  79. package/build/types/src/instrumentprofile.d.ts +4 -0
  80. package/build/types/src/note.d.ts +2 -0
  81. package/build/types/src/notehead.d.ts +2 -0
  82. package/build/types/src/publication.d.ts +3 -1
  83. package/build/types/src/stave.d.ts +4 -2
  84. package/build/types/src/stavenote.d.ts +10 -0
  85. package/build/types/src/stavesection.d.ts +3 -0
  86. package/build/types/src/svgcontext.d.ts +2 -0
  87. package/build/types/src/typeguard.d.ts +1 -0
  88. package/changelog/CHANGELOG.md +16 -0
  89. package/package.json +4 -1
  90. package/tests/all.html +9 -0
  91. package/tests/demo_petzold_tests.ts +30 -16
  92. package/tests/demos/ballade.ts +36 -0
  93. package/tests/demos/ballade.webp +0 -0
  94. package/tests/demos/electric.ts +1 -3
  95. package/tests/demos/electric.webp +0 -0
  96. package/tests/demos/fugue.ts +27 -0
  97. package/tests/demos/fugue.webp +0 -0
  98. package/tests/demos/greensleeves.ts +1 -3
  99. package/tests/demos/greensleeves.webp +0 -0
  100. package/tests/demos/kesh.ts +2 -4
  101. package/tests/demos/kesh.webp +0 -0
  102. package/tests/demos/saints.ts +20 -7
  103. package/tests/demos/saints.webp +0 -0
  104. package/tests/flow.html +165 -52
  105. package/tests/minuet.webp +0 -0
  106. package/tests/scores/ballade.js +445 -0
  107. package/tests/scores/drums.js +101 -0
  108. package/tests/scores/drums.webp +0 -0
  109. package/tests/scores/electric.js +93 -0
  110. package/tests/scores/electric.webp +0 -0
  111. package/tests/scores/falseta.js +53 -0
  112. package/tests/scores/falseta.webp +0 -0
  113. package/tests/scores/fugue.js +433 -0
  114. package/tests/scores/guitar.js +34 -0
  115. package/tests/scores/index.html +48 -0
  116. package/tests/scores/kesh.js +171 -0
  117. package/tests/scores/kesh.webp +0 -0
  118. package/tests/scores/prelude.js +90 -0
  119. package/tests/scores/prelude.webp +0 -0
  120. package/tests/scores/quartertones.js +83 -0
  121. package/tests/scores/quartertones.webp +0 -0
  122. package/tests/scores/saints.js +85 -0
  123. package/tests/scores/saints.webp +0 -0
  124. package/tests/scores/sumer.js +139 -0
  125. package/tests/scores/sumer.webp +0 -0
  126. package/tests/scores/viewer.css +132 -0
  127. package/tests/scores/viewer.js +150 -0
@@ -6,6 +6,7 @@ import { GraceNoteStruct } from '../gracenote';
6
6
  import { Note } from '../note';
7
7
  import { Sheet, SheetOptions } from '../sheet';
8
8
  import { Stave, StaveOptions } from '../stave';
9
+ import { BarlineType } from '../stavebarline';
9
10
  import { StaveNoteStruct } from '../stavenote';
10
11
  import { System, SystemOptions } from '../system';
11
12
  import { TabNoteStruct } from '../tabnote';
@@ -18,6 +19,8 @@ export interface EasyScoreStaffState {
18
19
  clef?: string;
19
20
  key?: string;
20
21
  time?: string;
22
+ /** Hide or reveal the meter sign while preserving the meter used for timing and beaming. */
23
+ showTimeSignature?: boolean;
21
24
  }
22
25
  /** Explicit signs survive key-aware generation, including cautionaries and microtones. */
23
26
  interface GracePitchSpec extends GraceNoteStruct {
@@ -59,6 +62,16 @@ export interface EasyScoreVoiceSpec {
59
62
  }[];
60
63
  autoBeam?: boolean | EasyScoreAutoBeamOptions;
61
64
  }
65
+ /** A written mark anchored by note ID on its owning staff and measure. */
66
+ interface LeadMark {
67
+ note: string;
68
+ text: string;
69
+ }
70
+ /** A lyric connector stays within its verse and measure. */
71
+ interface LyricMark extends LeadMark {
72
+ hyphenAfter?: boolean;
73
+ extendTo?: string;
74
+ }
62
75
  /** span is the actual duration of a pickup; time remains its displayed meter. */
63
76
  export interface EasyScoreMeasureSpec extends EasyScoreStaffState {
64
77
  instrument?: {
@@ -67,6 +80,12 @@ export interface EasyScoreMeasureSpec extends EasyScoreStaffState {
67
80
  };
68
81
  voices: readonly EasyScoreVoiceSpec[];
69
82
  span?: VoiceTime | string;
83
+ /** The barline drawn at this measure's right edge. */
84
+ endBarline?: BarlineType;
85
+ /** Literal chord names sharing a lane above their notes. */
86
+ chords?: readonly LeadMark[];
87
+ /** Each ordered list of syllables forms a separate lyric lane. */
88
+ verses?: readonly (readonly LyricMark[])[];
70
89
  }
71
90
  /** Staves have aligned measure arrays. Missing or uneven measures are errors. */
72
91
  export interface EasyScoreStaveSpec extends EasyScoreStaffState {
@@ -12,6 +12,8 @@ export interface FretDiagramSpec {
12
12
  };
13
13
  }
14
14
  export declare class FretDiagram extends Element {
15
+ /** The registry and font metrics both use the diagram category. */
16
+ static get CATEGORY(): string;
15
17
  private readonly frets;
16
18
  private readonly first;
17
19
  private readonly rows;
@@ -34,6 +34,7 @@ export declare class FrettedInstrument {
34
34
  offset: Fraction;
35
35
  note: {
36
36
  notation: NotationIdentity[];
37
+ restLine?: number;
37
38
  musicFont?: string;
38
39
  engraving?: import("./engravingprofile").EngravingProfile;
39
40
  stemDirection?: number;
@@ -52,6 +53,7 @@ export declare class FrettedInstrument {
52
53
  tab: {
53
54
  notation: NotationIdentity[];
54
55
  positions: import("./tabnote").TabNotePosition[];
56
+ restLine?: number;
55
57
  musicFont?: string;
56
58
  engraving?: import("./engravingprofile").EngravingProfile;
57
59
  stemDirection?: number;
@@ -75,6 +77,7 @@ export declare class FrettedInstrument {
75
77
  }[], duration: string, spec: TimedStringBend): {
76
78
  note: {
77
79
  notation: NotationIdentity[];
80
+ restLine?: number;
78
81
  musicFont?: string;
79
82
  engraving?: import("./engravingprofile").EngravingProfile;
80
83
  stemDirection?: number;
@@ -93,6 +96,7 @@ export declare class FrettedInstrument {
93
96
  tab: {
94
97
  notation: NotationIdentity[];
95
98
  positions: import("./tabnote").TabNotePosition[];
99
+ restLine?: number;
96
100
  musicFont?: string;
97
101
  engraving?: import("./engravingprofile").EngravingProfile;
98
102
  stemDirection?: number;
@@ -95,6 +95,8 @@ export declare abstract class Note extends Tickable {
95
95
  protected static parseNoteStruct(noteStruct: NoteStruct): ParsedNote | undefined;
96
96
  /** Source identities survive native drawing, Canvas inspection and print export. */
97
97
  readonly notation: readonly NotationIdentity[];
98
+ /** Augmentation dots in the written duration, independent of tick overrides or modifiers. */
99
+ readonly writtenDots: number;
98
100
  glyphProps: GlyphProps;
99
101
  keys: string[];
100
102
  keyProps: KeyProps[];
@@ -34,6 +34,8 @@ export declare class NoteHead extends Note {
34
34
  protected slashed: boolean;
35
35
  protected ledger: Record<string, string>;
36
36
  constructor(noteStruct: NoteHeadStruct);
37
+ /** Select the supporting ledger at the actual note position, preserving custom head glyphs. */
38
+ private updateRestGlyph;
37
39
  /** Get the width of the notehead. */
38
40
  getWidth(): number;
39
41
  /** Determine if the notehead is displaced. */
@@ -1,9 +1,11 @@
1
- import type { EasyScoreCompositionSpec } from './easyscore';
1
+ import type { CommitHook, EasyScoreCompositionSpec } from './easyscore';
2
2
  import { PublicationView } from './publicationview';
3
3
  import type { SVGFont } from './svgexport';
4
4
  export type { PublicationRegion, PublicationView } from './publicationview';
5
5
  /** Paper, staff height (four spaces), margins, and inter-system gaps are measured in millimeters. */
6
6
  export interface PublicationOptions extends PublicationView {
7
+ /** Apply the source's EasyScore note decorations to every independently built part and cue. */
8
+ noteHooks?: readonly CommitHook[];
7
9
  paper?: 'A4' | 'Letter' | {
8
10
  width: number;
9
11
  height: number;
@@ -34,8 +34,10 @@ export declare class Stave extends Element {
34
34
  protected endClef?: string;
35
35
  protected formatted: boolean;
36
36
  private boundaryModifiers;
37
- /** Replace only the derived row-start and courtesy signs on a responsive sheet. */
38
- setBoundaryModifiers(modifiers: StaveModifier[]): void;
37
+ /** Space after the row-start signs for a continuation arriving at the first note. */
38
+ private boundaryNotePadding;
39
+ /** Replace the derived row-start and courtesy signs and their note clearance. */
40
+ setBoundaryModifiers(modifiers: StaveModifier[], notePadding?: number): void;
39
41
  protected measure: number;
40
42
  protected bounds: Bounds;
41
43
  protected readonly modifiers: StaveModifier[];
@@ -33,6 +33,8 @@ export interface StaveNoteFormatSettings {
33
33
  note: StaveNote;
34
34
  }
35
35
  export interface StaveNoteStruct extends NoteStruct {
36
+ /** Fixed rest position in key-line coordinates. On a five-line stave, 1 is the bottom line. */
37
+ restLine?: number;
36
38
  /** Override the music glyph family for this note, its heads and its flag. */
37
39
  musicFont?: string;
38
40
  engraving?: EngravingProfile;
@@ -55,6 +57,8 @@ export declare class StaveNote extends StemmableNote {
55
57
  maxLine: number;
56
58
  protected readonly clef: string;
57
59
  protected readonly octaveShift?: number;
60
+ /** Preserve the previous line so releasing an explicit position restores automatic placement. */
61
+ private lineBeforeRestPin?;
58
62
  protected displaced: boolean;
59
63
  protected dotShiftY: number;
60
64
  protected useDefaultHeadX: boolean;
@@ -86,6 +90,8 @@ export declare class StaveNote extends StemmableNote {
86
90
  isChord(): boolean;
87
91
  hasStem(): boolean;
88
92
  hasFlag(): boolean;
93
+ /** Use explicit font metadata first, then the bundled anchors for Bravura rhythm slashes. */
94
+ private stemAnchor;
89
95
  getStemX(): number;
90
96
  getYForTopText(textLine: number): number;
91
97
  getYForBottomText(textLine: number): number;
@@ -111,6 +117,10 @@ export declare class StaveNote extends StemmableNote {
111
117
  /** Get the glyph width. */
112
118
  getGlyphWidth(): number;
113
119
  setKeyStyle(index: number, style: ElementStyle): this;
120
+ /** The explicit key line, or undefined when rest placement is automatic. */
121
+ get restLine(): number | undefined;
122
+ /** Pin this rest to a line. Passing undefined releases it for automatic placement. */
123
+ setRestLine(line: number | undefined): this;
114
124
  setKeyLine(index: number, line: number): this;
115
125
  getKeyLine(index: number): number;
116
126
  getVoiceShiftWidth(): number;
@@ -1,8 +1,11 @@
1
+ import { BoundingBox } from './boundingbox';
1
2
  import { StaveModifier } from './stavemodifier';
2
3
  export declare class StaveSection extends StaveModifier {
3
4
  static get CATEGORY(): string;
4
5
  protected drawRect: boolean;
5
6
  constructor(section: string, x?: number, yShift?: number, drawRect?: boolean);
6
7
  setDrawRect(drawRect: boolean): this;
8
+ /** Report the same ink and padding before drawing as after a stave has moved. */
9
+ getBoundingBox(): BoundingBox;
7
10
  draw(): void;
8
11
  }
@@ -12,6 +12,8 @@ export type Attributes = {
12
12
  scaleY?: number;
13
13
  };
14
14
  export interface State {
15
+ /** Font shorthand returned by getFont() at the matching save(). */
16
+ font?: string;
15
17
  state: Attributes;
16
18
  attributes: Attributes;
17
19
  }
@@ -46,6 +46,7 @@ export declare const enum Category {
46
46
  Element = "Element",
47
47
  Flag = "Flag",
48
48
  Fraction = "Fraction",
49
+ FretDiagram = "FretDiagram",
49
50
  FretHandFinger = "FretHandFinger",
50
51
  GhostNote = "GhostNote",
51
52
  Glyph = "Glyph",
@@ -1,3 +1,19 @@
1
+ # 5.6.0
2
+
3
+ - Chord roots use 14 pt Academico, lyrics use 12 pt, and tab frets use 11 pt. Grace frets, stroke arrows, and technique labels have room around two-digit frets. See both arrow conventions in [Patio al alba](https://github.com/vexflow/vexflow/blob/5.6.0/tests/scores/falseta.js).
4
+ - EasyScore can tie a fret on a specific string across a system break and carry repeat endings into an extracted guitar part. Structured notes and rhythmic tab now engrave their written augmentation dots.
5
+ - Lead sheets preserve authored barlines and time-signature visibility in print. Rest ledger lines follow explicit rest positions, and rhythm slashes use Bravura’s stem anchors.
6
+ - Explore the [user guide](https://vexflow.com/guide/), [notation Explorer](https://vexflow.com/explorer/), [test gallery](https://vexflow.com/tests/), and [PDF score library](https://vexflow.com/pdfs/).
7
+ - See the [illustrated AI 2026 report](https://vexflow.com/reports/ai2026/) and the [5.6.0 code quality report](https://vexflow.com/reports/5.6.0/).
8
+
9
+ # 5.5.0
10
+
11
+ - Preserve EasyScore note decorations in printed scores, parts, and cues with `PublicationOptions.noteHooks`. Invisible pointer targets no longer affect page breaks.
12
+ - Set the size of lyrics and other text on continuous spans with `labelFontSize`. The layout measures the label before choosing system breaks.
13
+ - Explore interactive guitar, jazz, percussion, and microtonal arrangements in the [test gallery](https://vexflow.com/tests/). The opening score features the first 24 bars of Chopin’s Ballade No. 3.
14
+ - Generate print editions of Petzold’s Minuet, Bach’s Fugue, and Chopin’s Ballade with `npm run pdf`. The generated PDF index links each score to its source.
15
+ - Read the [5.5.0 code quality report](https://vexflow.com/reports/5.5.0/).
16
+
1
17
  # 5.4.0
2
18
 
3
19
  - Lay out lyrics, curves, and markings across a system. Break continuous scores into systems, then paginate full scores and individual parts for print.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vexflow",
3
- "version": "5.4.0",
3
+ "version": "5.6.0",
4
4
  "description": "A JavaScript library for rendering music notation and guitar tablature.",
5
5
  "exports": {
6
6
  ".": {
@@ -44,6 +44,7 @@
44
44
  "tests/all.html",
45
45
  "tests/minuet.webp",
46
46
  "tests/demos",
47
+ "tests/scores",
47
48
  "tests/demo_petzold_tests.ts",
48
49
  "tests/fonts.css",
49
50
  "tests/qunit/qunit.css",
@@ -139,6 +140,8 @@
139
140
  "explorer:build": "node tools/explorer/cli.mjs build",
140
141
  "explorer:test": "node tools/explorer/test.mjs",
141
142
  "explorer:upload": "node tools/explorer/upload.mjs",
143
+ "pdf": "grunt webpack:debugLibrary && node tools/pdf.mjs",
144
+ "pdf:upload": "npm run pdf -- --upload",
142
145
  "tests:build": "node tools/tests-site.mjs build",
143
146
  "tests:upload": "node tools/tests-site.mjs upload",
144
147
  "tests:test": "node tools/tests-site.test.mjs",
package/tests/all.html CHANGED
@@ -181,6 +181,15 @@
181
181
  let loadVexFlow;
182
182
 
183
183
  if (useESM && !isFileProtocol) {
184
+ // Browsers need a URL for the bare package import in a local ESM build.
185
+ if (!useCDN) {
186
+ const map = document.createElement('script');
187
+ map.type = 'importmap';
188
+ map.textContent = JSON.stringify({
189
+ imports: { 'structured-clone-es': '../node_modules/structured-clone-es/dist/index.mjs' },
190
+ });
191
+ document.head.append(map);
192
+ }
184
193
  console.log('LOADING ESM: ' + vexPlusTestsURL);
185
194
  loadVexFlow = async () => {
186
195
  const module = await import(vexPlusTestsURL);
@@ -1,11 +1,11 @@
1
1
  // Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
2
2
  // MIT License
3
3
  //
4
- // Demo - Petzold
4
+ // Petzold’s Minuet in G, an 18-bar keyboard excerpt with editorial performance markings.
5
5
 
6
6
  import { concat, TestOptions, VexFlowTests } from './vexflow_test_helpers';
7
7
 
8
- import { BarlineType, Factory, Registry, StaveNote } from '../src/index';
8
+ import { BarlineType, Factory, Registry, StaveHairpin, StaveNote } from '../src/index';
9
9
 
10
10
  const DemoPetzoldTests = {
11
11
  Start(): void {
@@ -53,10 +53,10 @@ function minuetInG(options: TestOptions): void {
53
53
  .addClef('treble')
54
54
  .addKeySignature('G')
55
55
  .addTimeSignature('3/4')
56
- .setTempo({ name: 'Allegretto', duration: 'h', dots: 1, bpm: 66 }, -30);
56
+ .setTempo({ name: 'Allegretto', duration: 'q', bpm: 132 }, -30);
57
57
 
58
58
  system
59
- .addStave({ voices: [voice(notes('(G3 B3 D4)/h, A3/q', { clef: 'bass' }))] })
59
+ .addStave({ voices: [voice(notes('(G3 B3 D4)/h[id="ped1"], A3/q[id="lift1"]', { clef: 'bass' }))] })
60
60
  .addClef('bass')
61
61
  .addKeySignature('G')
62
62
  .addTimeSignature('3/4');
@@ -64,6 +64,8 @@ function minuetInG(options: TestOptions): void {
64
64
  system.addConnector('singleRight');
65
65
  system.addConnector('singleLeft');
66
66
 
67
+ // Release the pedal as the bass moves off G.
68
+ f.PedalMarking({ notes: [id('ped1'), id('lift1')] });
67
69
  id('m1a').addModifier(f.Fingering({ number: '5' }), 0);
68
70
 
69
71
  /* Measure 2 */
@@ -90,8 +92,11 @@ function minuetInG(options: TestOptions): void {
90
92
  /* Measure 3 */
91
93
  system = appendSystem(150);
92
94
  system.addStave({
93
- voices: [voice([notes('E5/q[id="m3a"]'), beam(notes('C5/8, D5, E5, F5', { stem: 'down' }))].reduce(concat))],
95
+ voices: [
96
+ voice([notes('E5/q[id="m3a"]'), beam(notes('C5/8[id="m3cut"], D5, E5, F5', { stem: 'down' }))].reduce(concat)),
97
+ ],
94
98
  });
99
+ id('m3cut').addModifier(f.Ornament('mordent'));
95
100
  id('m3a').addModifier(f.Fingering({ number: '3', position: 'above' }), 0);
96
101
 
97
102
  system.addStave({ voices: [voice(notes('C4/h.', { clef: 'bass' }))] });
@@ -113,8 +118,8 @@ function minuetInG(options: TestOptions): void {
113
118
  to: id('m4a'),
114
119
  options: {
115
120
  cps: [
116
- { x: 0, y: 20 },
117
- { x: 0, y: 20 },
121
+ { x: 0, y: 39 },
122
+ { x: 0, y: 39 },
118
123
  ],
119
124
  },
120
125
  });
@@ -160,6 +165,7 @@ function minuetInG(options: TestOptions): void {
160
165
  system
161
166
  .addStave({
162
167
  voices: [
168
+ voice([f.TextDynamics({ text: 'mf', duration: 'h', dots: 1, line: 10 })]),
163
169
  voice([notes('F4/q[id="m7a"]'), beam(notes('G4/8[id="m7b"], A4, B4, G4', { stem: 'up' }))].reduce(concat)),
164
170
  ],
165
171
  })
@@ -174,13 +180,14 @@ function minuetInG(options: TestOptions): void {
174
180
  system.addConnector('singleRight');
175
181
  system.addConnector('singleLeft');
176
182
 
183
+ id('m7a').addModifier(f.Articulation({ type: 'a-', position: 'above' }));
177
184
  id('m7a').addModifier(f.Fingering({ number: '2', position: 'below' }), 0);
178
185
  id('m7b').addModifier(f.Fingering({ number: '1' }), 0);
179
186
  id('m7c').addModifier(f.Fingering({ number: '3', position: 'above' }), 0);
180
187
 
181
188
  /* Measure 8 */
182
189
  system = appendSystem(180);
183
- const grace = f.GraceNote({ keys: ['d/3'], clef: 'bass', duration: '4', slash: false });
190
+ const grace = f.GraceNote({ keys: ['b/4'], duration: '8', slash: true });
184
191
 
185
192
  system.addStave({ voices: [voice(notes('A4/h.[id="m8c"]'))] });
186
193
  system.addStave({
@@ -193,7 +200,7 @@ function minuetInG(options: TestOptions): void {
193
200
  system.addConnector('singleRight');
194
201
 
195
202
  id('m8b').addModifier(f.Fingering({ number: '1', position: 'above' }), 0);
196
- id('m8c').addModifier(f.GraceNoteGroup({ notes: [grace] }), 0);
203
+ id('m8c').addModifier(f.GraceNoteGroup({ notes: [grace], slur: true }), 0);
197
204
 
198
205
  f.Curve({
199
206
  from: id('m7a'),
@@ -209,12 +216,11 @@ function minuetInG(options: TestOptions): void {
209
216
  },
210
217
  });
211
218
 
212
- f.StaveTie({ from: grace, to: id('m8c') });
213
-
214
219
  /* Measure 9 */
215
220
  system = appendSystem(180);
216
221
  system.addStave({
217
222
  voices: [
223
+ voice([f.TextDynamics({ text: 'pp', duration: 'h', dots: 1, line: 9 })]),
218
224
  score
219
225
  .set({ clef: 'treble' })
220
226
  .voice([notes('D5/q[id="m9a"]'), beam(notes('G4/8, A4, B4, C5', { stem: 'up' }))].reduce(concat)),
@@ -251,8 +257,11 @@ function minuetInG(options: TestOptions): void {
251
257
  /* Measure 11 */
252
258
  system = appendSystem(150);
253
259
  system.addStave({
254
- voices: [voice([notes('E5/q[id="m11a"]'), beam(notes('C5/8, D5, E5, F5', { stem: 'down' }))].reduce(concat))],
260
+ voices: [
261
+ voice([notes('E5/q[id="m11a"]'), beam(notes('C5/8[id="m11cut"], D5, E5, F5', { stem: 'down' }))].reduce(concat)),
262
+ ],
255
263
  });
264
+ id('m11cut').addModifier(f.Ornament('mordent'));
256
265
  id('m11a').addModifier(f.Fingering({ number: '3', position: 'above' }), 0);
257
266
 
258
267
  system.addStave({ voices: [voice(notes('C4/h.', { clef: 'bass' }))] });
@@ -283,8 +292,8 @@ function minuetInG(options: TestOptions): void {
283
292
  to: id('m12a'),
284
293
  options: {
285
294
  cps: [
286
- { x: 0, y: 20 },
287
- { x: 0, y: 20 },
295
+ { x: 0, y: 39 },
296
+ { x: 0, y: 39 },
288
297
  ],
289
298
  },
290
299
  });
@@ -324,7 +333,7 @@ function minuetInG(options: TestOptions): void {
324
333
  voices: [
325
334
  score
326
335
  .set({ clef: 'treble' })
327
- .voice([notes('B4/q'), beam(notes('C5/8, b4, a4, g4', { stem: 'up' }))].reduce(concat)),
336
+ .voice([notes('B4/q'), beam(notes('C5/8, b4, a4, g4[id="m14end"]', { stem: 'up' }))].reduce(concat)),
328
337
  ],
329
338
  });
330
339
 
@@ -359,7 +368,7 @@ function minuetInG(options: TestOptions): void {
359
368
  .setEndBarType(BarlineType.REPEAT_END);
360
369
 
361
370
  system
362
- .addStave({ voices: [voice(notes('g3/h[id="m16b"], g2/q', { clef: 'bass' }))] })
371
+ .addStave({ voices: [voice(notes('g3/h[id="m16b"], g2/q[id="lift16"]', { clef: 'bass' }))] })
363
372
  .setEndBarType(BarlineType.REPEAT_END);
364
373
  system.addConnector('boldDoubleRight');
365
374
 
@@ -425,6 +434,11 @@ function minuetInG(options: TestOptions): void {
425
434
  },
426
435
  });
427
436
 
437
+ // Shape the two descents differently and clear the pedal before the repeat.
438
+ f.StaveHairpin({ from: id('m5a'), to: id('m6a'), type: StaveHairpin.type.CRESC });
439
+ f.StaveHairpin({ from: id('m13a'), to: id('m14end'), type: StaveHairpin.type.DECRESC });
440
+ f.PedalMarking({ notes: [id('m16b'), id('lift16')] });
441
+
428
442
  /* Done */
429
443
  f.draw();
430
444
  Registry.disableDefaultRegistry();
@@ -0,0 +1,36 @@
1
+ // Run the first printed page of Chopin's third Ballade on every visual test backend.
2
+ import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
3
+
4
+ import {
5
+ Accidental,
6
+ Factory,
7
+ Fraction,
8
+ PedalMarking,
9
+ StaveHairpin,
10
+ Stroke,
11
+ TextDynamics,
12
+ Tuplet,
13
+ } from '../../src/index';
14
+
15
+ import '../scores/ballade';
16
+
17
+ /** The reference turns the page after bar 24, with six bars in each of the first two systems. */
18
+ export function ballade(options: TestOptions): void {
19
+ const { draw, width, height } = globalThis.ChopinBallade;
20
+ const factory = VexFlowTests.makeFactory(options, width, Math.ceil(height));
21
+ const systems = draw(
22
+ { Accidental, Factory, Fraction, PedalMarking, StaveHairpin, Stroke, TextDynamics, Tuplet },
23
+ factory
24
+ );
25
+ options.assert.deepEqual(
26
+ systems.map((system) => system.measures),
27
+ [
28
+ [1, 2, 3, 4, 5, 6],
29
+ [7, 8, 9, 10, 11, 12],
30
+ [13, 14, 15, 16],
31
+ [17, 18, 19, 20],
32
+ [21, 22, 23, 24],
33
+ ],
34
+ 'All five systems retain the breaks of the printed page'
35
+ );
36
+ }
Binary file
@@ -33,9 +33,7 @@ export function electric(options: TestOptions): void {
33
33
  if (i === 0) stave.addTimeSignature('4/4').setTempo({ duration: 'q', bpm: 96 }, -8);
34
34
  if (i === 3) stave.setEndBarType(BarlineType.END);
35
35
  const legato = (start: number, label: string) =>
36
- score.make
37
- .tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label)
38
- .setFont('Arial, Helvetica, sans-serif', 9, 'bold');
36
+ score.make.tabTie({ firstNote: notes[start], lastNote: notes[start + 1] }, label);
39
37
  if (i === 0) {
40
38
  score.beam(notes.slice(1, 3));
41
39
  legato(1, 'H');
Binary file
@@ -0,0 +1,27 @@
1
+ // Engrave Bach's opening eight bars on each backend using the print edition's source.
2
+ import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
3
+
4
+ import { Fraction, TextDynamics } from '../../src/index';
5
+
6
+ import '../scores/fugue';
7
+
8
+ /** The excerpt includes the subject, answer, and third entrance in the bass. */
9
+ export function fugue(options: TestOptions): void {
10
+ const width = 1300;
11
+ const factory = VexFlowTests.makeFactory(options, width, 640);
12
+ const score = factory.EasyScore({ throwOnError: true, extensions: ['spacer', 'ornament', 'dynamic'] });
13
+ const notation = { Fraction, TextDynamics };
14
+ score.addCommitHook(globalThis.BachFugue.noteMarks(notation));
15
+ const music = globalThis.BachFugue.music(notation, 8);
16
+ music.system = { ...music.system, spaceBetweenStaves: 6 };
17
+ music.sheet = { x: 18, y: 18, width: width - 36, measurePadding: 18, rowGap: 18 };
18
+ const { sheet, systems, staves } = score.compose(music);
19
+ sheet.format();
20
+ factory.getContext().resize(width, Math.ceil(sheet.getHeight() + 24));
21
+ factory.draw();
22
+ options.assert.equal(systems.length, 8, 'Eight complete measures');
23
+ options.assert.ok(
24
+ staves.every((pair) => pair.length === 2),
25
+ 'Both hands share the grand staff throughout'
26
+ );
27
+ }
Binary file
@@ -28,8 +28,6 @@ const positions: Record<string, [number, number]> = {
28
28
  export function greensleeves(options: TestOptions): void {
29
29
  const f = VexFlowTests.makeFactory(options, 900, 486);
30
30
  const score = f.EasyScore({ throwOnError: true });
31
- // Upright sans-serif chord names sit above the melody, including the slash bass in Dm/F.
32
- const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
33
31
  const bars = [
34
32
  ['', 'A4/q'],
35
33
  ['Am', 'A3+E4+A4+C5/h D5/q'],
@@ -56,7 +54,7 @@ export function greensleeves(options: TestOptions): void {
56
54
  return `${chord}/${duration}`;
57
55
  });
58
56
  const notes = score.notes(music.join(', '));
59
- if (chordName) notes[0].addModifier(score.make.chordSymbol(chordFont).addText(chordName));
57
+ if (chordName) notes[0].addModifier(score.make.chordSymbol().addText(chordName));
60
58
  const tab = events.map(({ pitches, duration }) =>
61
59
  score.make.tabNote({
62
60
  positions: pitches.map((pitch) => {
Binary file
@@ -11,8 +11,6 @@ export function kesh(options: TestOptions): void {
11
11
  const f = VexFlowTests.makeFactory(options, 900, 580);
12
12
  const score = f.EasyScore({ throwOnError: true });
13
13
  score.set({ time: '6/8' });
14
- // Use the same upright lettering for a change on either beat of the bar.
15
- const chordFont = { fontFamily: 'Arial, Helvetica, sans-serif', fontSize: 12 };
16
14
  // The McNeela chart suggests two changes within some bars and different pickups at the repeats.
17
15
  const strains: JigBar[][] = [
18
16
  [
@@ -54,8 +52,8 @@ export function kesh(options: TestOptions): void {
54
52
  for (const beat of beats) {
55
53
  if (beat.length === 3) score.beam(beat);
56
54
  }
57
- if (chord) beats[0][0].addModifier(score.make.chordSymbol(chordFont).addText(chord));
58
- if (nextChord) beats[1][0].addModifier(score.make.chordSymbol(chordFont).addText(nextChord));
55
+ if (chord) beats[0][0].addModifier(score.make.chordSymbol().addText(chord));
56
+ if (nextChord) beats[1][0].addModifier(score.make.chordSymbol().addText(nextChord));
59
57
  if (i === 0 || i === 4) {
60
58
  const grace = score.make.graceNote({ keys: [part ? 'd/5' : 'b/4'], duration: '8', slash: true });
61
59
  notes[1].addModifier(score.make.graceNoteGroup({ notes: [grace], slur: true }));
Binary file
@@ -3,10 +3,19 @@ import { TestOptions, VexFlowTests } from '../vexflow_test_helpers';
3
3
 
4
4
  import { BarlineType, ChordSymbol, StemmableNote } from '../../src/index';
5
5
 
6
+ import { Metrics } from '../../src/metrics';
7
+
6
8
  /** Render a compact, sixteen-bar setting of the traditional refrain, with its three-note pickup. */
7
9
  export function saints(options: TestOptions): void {
8
10
  const factory = VexFlowTests.makeFactory(options, 900, 540);
9
11
  const score = factory.EasyScore({ throwOnError: true });
12
+ const lyricFont = Metrics.getFontInfo('Annotation.lyric');
13
+ // Use the same baseline throughout each row, below the pickup's low C.
14
+ const word = (text: string, rowY: number) =>
15
+ factory
16
+ .Annotation({ text, font: lyricFont, vJustify: 'bottom' })
17
+ .setTextBaseline(rowY + 116)
18
+ .setConnectorPadding(2);
10
19
  const bars = [
11
20
  ['G4/w', 'saints', 'C:6/9'],
12
21
  ['B4/q/r, C4/q, E4, F4', '|go|march-|ing', 'Am:7'],
@@ -28,27 +37,30 @@ export function saints(options: TestOptions): void {
28
37
  // The first system includes a short anacrusis before its four complete measures.
29
38
  const pickup = score.notes('C4/q, E4, F4');
30
39
  const pickupLabels = ['Oh', 'when', 'the'];
31
- pickup.forEach((note, i) =>
32
- note.addModifier(factory.Annotation({ text: pickupLabels[i], vJustify: 'bottom' }).setTextBaseline(123))
33
- );
40
+ pickup.forEach((note, i) => note.addModifier(word(pickupLabels[i], 16)));
41
+ const pickupWidth = 210;
34
42
  factory
35
- .System({ x: 10, y: 16, width: 180 })
43
+ .System({ x: 10, y: 16, width: pickupWidth })
36
44
  .addStave({ voices: [score.voice(pickup, { time: '3/4' })] })
37
45
  .addClef('treble')
38
46
  .addTimeSignature('4/4');
39
47
 
48
+ // The first row shares space between the pickup, two single-word bars and two busier bars.
49
+ const openingWidths = [120, 212, 122, 212];
50
+ let x = 10 + pickupWidth;
40
51
  let sustained: StemmableNote | undefined;
41
52
  bars.forEach(([music, words, harmony], i) => {
42
53
  const row = Math.floor(i / 4);
43
54
  const column = i % 4;
44
55
  const y = 16 + row * 130;
45
- const width = row === 0 ? 174 : 219;
56
+ if (column === 0 && row > 0) x = 10;
57
+ const width = row === 0 ? openingWidths[column] : 219;
46
58
  const notes = score.notes(music);
47
59
  // Carry the sustained D and the final tonic across the barline without repeating a syllable.
48
60
  if (i === 5 || i === 14) sustained = notes[0];
49
61
  if ((i === 6 || i === 15) && sustained) score.make.tie({ from: sustained, to: notes[0] });
50
62
  words.split('|').forEach((text, n) => {
51
- if (text) notes[n].addModifier(factory.Annotation({ text, vJustify: 'bottom' }).setTextBaseline(y + 107));
63
+ if (text) notes[n].addModifier(word(text, y));
52
64
  });
53
65
  // Split the chord into root and extension so Petaluma supplies proper accidental glyphs.
54
66
  if (harmony) {
@@ -60,8 +72,9 @@ export function saints(options: TestOptions): void {
60
72
  notes[0].addModifier(chord);
61
73
  }
62
74
  const stave = factory
63
- .System({ x: (row === 0 ? 190 : 10) + column * width, y, width })
75
+ .System({ x, y, width })
64
76
  .addStave({ voices: [score.voice(notes, { time: i === 15 ? '1/4' : '4/4' })] });
77
+ x += width;
65
78
  if (column === 0 && row > 0) stave.addClef('treble');
66
79
  if (i === bars.length - 1) stave.setEndBarType(BarlineType.END);
67
80
  });
Binary file