@mcqj/vexflow 0.0.1-alpha.1

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 (300) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +208 -0
  3. package/build/cjs/vexflow-bravura.js +2 -0
  4. package/build/cjs/vexflow-bravura.js.map +1 -0
  5. package/build/cjs/vexflow-core.js +2 -0
  6. package/build/cjs/vexflow-core.js.map +1 -0
  7. package/build/cjs/vexflow-debug-with-tests.js +43475 -0
  8. package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
  9. package/build/cjs/vexflow-debug.js +19194 -0
  10. package/build/cjs/vexflow-debug.js.map +1 -0
  11. package/build/cjs/vexflow.js +2 -0
  12. package/build/cjs/vexflow.js.map +1 -0
  13. package/build/esm/entry/vexflow-bravura.js +17 -0
  14. package/build/esm/entry/vexflow-core.js +4 -0
  15. package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
  16. package/build/esm/entry/vexflow-debug.js +31 -0
  17. package/build/esm/entry/vexflow.js +31 -0
  18. package/build/esm/package.json +3 -0
  19. package/build/esm/src/accidental.js +330 -0
  20. package/build/esm/src/annotation.js +231 -0
  21. package/build/esm/src/articulation.js +281 -0
  22. package/build/esm/src/barnote.js +56 -0
  23. package/build/esm/src/beam.js +644 -0
  24. package/build/esm/src/bend.js +186 -0
  25. package/build/esm/src/boundingbox.js +59 -0
  26. package/build/esm/src/canvascontext.js +216 -0
  27. package/build/esm/src/chordsymbol.js +325 -0
  28. package/build/esm/src/clef.js +120 -0
  29. package/build/esm/src/clefnote.js +35 -0
  30. package/build/esm/src/crescendo.js +78 -0
  31. package/build/esm/src/curve.js +126 -0
  32. package/build/esm/src/dot.js +129 -0
  33. package/build/esm/src/easyscore.js +374 -0
  34. package/build/esm/src/element.js +409 -0
  35. package/build/esm/src/factory.js +463 -0
  36. package/build/esm/src/flag.js +22 -0
  37. package/build/esm/src/font.js +237 -0
  38. package/build/esm/src/fonts/academico.js +1 -0
  39. package/build/esm/src/fonts/academicobold.js +1 -0
  40. package/build/esm/src/fonts/bravura.js +1 -0
  41. package/build/esm/src/fonts/gonville.js +1 -0
  42. package/build/esm/src/fonts/petaluma.js +1 -0
  43. package/build/esm/src/fonts/petalumascript.js +1 -0
  44. package/build/esm/src/formatter.js +610 -0
  45. package/build/esm/src/fraction.js +170 -0
  46. package/build/esm/src/frethandfinger.js +141 -0
  47. package/build/esm/src/ghostnote.js +50 -0
  48. package/build/esm/src/glyphnote.js +44 -0
  49. package/build/esm/src/glyphs.js +2936 -0
  50. package/build/esm/src/gracenote.js +106 -0
  51. package/build/esm/src/gracenotegroup.js +138 -0
  52. package/build/esm/src/gracetabnote.js +11 -0
  53. package/build/esm/src/index.js +86 -0
  54. package/build/esm/src/keymanager.js +99 -0
  55. package/build/esm/src/keysignature.js +220 -0
  56. package/build/esm/src/keysignote.js +28 -0
  57. package/build/esm/src/metrics.js +237 -0
  58. package/build/esm/src/modifier.js +121 -0
  59. package/build/esm/src/modifiercontext.js +110 -0
  60. package/build/esm/src/multimeasurerest.js +127 -0
  61. package/build/esm/src/music.js +322 -0
  62. package/build/esm/src/note.js +383 -0
  63. package/build/esm/src/notehead.js +89 -0
  64. package/build/esm/src/notesubgroup.js +59 -0
  65. package/build/esm/src/ornament.js +192 -0
  66. package/build/esm/src/parenthesis.js +61 -0
  67. package/build/esm/src/parser.js +164 -0
  68. package/build/esm/src/pedalmarking.js +168 -0
  69. package/build/esm/src/registry.js +81 -0
  70. package/build/esm/src/rendercontext.js +20 -0
  71. package/build/esm/src/renderer.js +112 -0
  72. package/build/esm/src/repeatnote.js +17 -0
  73. package/build/esm/src/stave.js +579 -0
  74. package/build/esm/src/stavebarline.js +237 -0
  75. package/build/esm/src/staveconnector.js +180 -0
  76. package/build/esm/src/stavehairpin.js +115 -0
  77. package/build/esm/src/staveline.js +199 -0
  78. package/build/esm/src/stavemodifier.js +56 -0
  79. package/build/esm/src/stavenote.js +861 -0
  80. package/build/esm/src/staverepetition.js +120 -0
  81. package/build/esm/src/stavesection.js +36 -0
  82. package/build/esm/src/stavetempo.js +110 -0
  83. package/build/esm/src/stavetext.js +55 -0
  84. package/build/esm/src/stavetie.js +186 -0
  85. package/build/esm/src/stavevolta.js +53 -0
  86. package/build/esm/src/stem.js +133 -0
  87. package/build/esm/src/stemmablenote.js +193 -0
  88. package/build/esm/src/stringnumber.js +228 -0
  89. package/build/esm/src/strokes.js +164 -0
  90. package/build/esm/src/svgcontext.js +402 -0
  91. package/build/esm/src/system.js +166 -0
  92. package/build/esm/src/tables.js +696 -0
  93. package/build/esm/src/tabnote.js +278 -0
  94. package/build/esm/src/tabslide.js +68 -0
  95. package/build/esm/src/tabstave.js +17 -0
  96. package/build/esm/src/tabtie.js +19 -0
  97. package/build/esm/src/textbracket.js +128 -0
  98. package/build/esm/src/textdynamics.js +53 -0
  99. package/build/esm/src/textnote.js +116 -0
  100. package/build/esm/src/tickable.js +224 -0
  101. package/build/esm/src/tickcontext.js +189 -0
  102. package/build/esm/src/timesignature.js +169 -0
  103. package/build/esm/src/timesignote.js +30 -0
  104. package/build/esm/src/tremolo.js +30 -0
  105. package/build/esm/src/tuning.js +55 -0
  106. package/build/esm/src/tuplet.js +258 -0
  107. package/build/esm/src/typeguard.js +30 -0
  108. package/build/esm/src/util.js +67 -0
  109. package/build/esm/src/version.js +3 -0
  110. package/build/esm/src/vexflow.js +309 -0
  111. package/build/esm/src/vibrato.js +68 -0
  112. package/build/esm/src/vibratobracket.js +44 -0
  113. package/build/esm/src/voice.js +178 -0
  114. package/build/esm/src/web.js +15 -0
  115. package/build/esm/tests/accidental_tests.js +1055 -0
  116. package/build/esm/tests/annotation_tests.js +381 -0
  117. package/build/esm/tests/articulation_tests.js +432 -0
  118. package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
  119. package/build/esm/tests/barline_tests.js +52 -0
  120. package/build/esm/tests/beam_tests.js +669 -0
  121. package/build/esm/tests/bend_tests.js +223 -0
  122. package/build/esm/tests/boundingbox_tests.js +53 -0
  123. package/build/esm/tests/browser_test_runner.js +128 -0
  124. package/build/esm/tests/chordsymbol_tests.js +405 -0
  125. package/build/esm/tests/clef_tests.js +141 -0
  126. package/build/esm/tests/crossbeam_tests.js +306 -0
  127. package/build/esm/tests/curve_tests.js +152 -0
  128. package/build/esm/tests/demo_petzold_tests.js +335 -0
  129. package/build/esm/tests/dot_tests.js +119 -0
  130. package/build/esm/tests/easyscore_tests.js +488 -0
  131. package/build/esm/tests/factory_tests.js +44 -0
  132. package/build/esm/tests/font_tests.js +134 -0
  133. package/build/esm/tests/formatter/framestack.js +61 -0
  134. package/build/esm/tests/formatter/tests.js +251 -0
  135. package/build/esm/tests/formatter_tests.js +759 -0
  136. package/build/esm/tests/fraction_tests.js +72 -0
  137. package/build/esm/tests/ghostnote_tests.js +77 -0
  138. package/build/esm/tests/glyphnote_tests.js +119 -0
  139. package/build/esm/tests/gracenote_tests.js +414 -0
  140. package/build/esm/tests/gracetabnote_tests.js +79 -0
  141. package/build/esm/tests/index.js +68 -0
  142. package/build/esm/tests/key_clef_tests.js +106 -0
  143. package/build/esm/tests/keymanager_tests.js +68 -0
  144. package/build/esm/tests/keysignature_tests.js +322 -0
  145. package/build/esm/tests/mocks.js +70 -0
  146. package/build/esm/tests/modifier_tests.js +24 -0
  147. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  148. package/build/esm/tests/music_tests.js +161 -0
  149. package/build/esm/tests/node_test_runner.js +31 -0
  150. package/build/esm/tests/notehead_tests.js +224 -0
  151. package/build/esm/tests/notesubgroup_tests.js +149 -0
  152. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  153. package/build/esm/tests/ornament_tests.js +333 -0
  154. package/build/esm/tests/parser_tests.js +122 -0
  155. package/build/esm/tests/pedalmarking_tests.js +91 -0
  156. package/build/esm/tests/percussion_tests.js +184 -0
  157. package/build/esm/tests/playwright/flow.spec.js +127 -0
  158. package/build/esm/tests/playwright/visual_helpers.js +30 -0
  159. package/build/esm/tests/registry_tests.js +64 -0
  160. package/build/esm/tests/renderer_tests.js +113 -0
  161. package/build/esm/tests/rests_tests.js +266 -0
  162. package/build/esm/tests/rhythm_tests.js +357 -0
  163. package/build/esm/tests/stave_tests.js +570 -0
  164. package/build/esm/tests/staveconnector_tests.js +402 -0
  165. package/build/esm/tests/stavehairpin_tests.js +90 -0
  166. package/build/esm/tests/staveline_tests.js +123 -0
  167. package/build/esm/tests/stavemodifier_tests.js +51 -0
  168. package/build/esm/tests/stavenote_tests.js +936 -0
  169. package/build/esm/tests/stavetie_tests.js +137 -0
  170. package/build/esm/tests/stringnumber_tests.js +283 -0
  171. package/build/esm/tests/strokes_tests.js +289 -0
  172. package/build/esm/tests/style_tests.js +96 -0
  173. package/build/esm/tests/tabnote_tests.js +462 -0
  174. package/build/esm/tests/tabslide_tests.js +133 -0
  175. package/build/esm/tests/tabstave_tests.js +24 -0
  176. package/build/esm/tests/tabtie_tests.js +171 -0
  177. package/build/esm/tests/test_runner.js +23 -0
  178. package/build/esm/tests/textbracket_tests.js +100 -0
  179. package/build/esm/tests/textnote_tests.js +216 -0
  180. package/build/esm/tests/threevoice_tests.js +132 -0
  181. package/build/esm/tests/tickcontext_tests.js +36 -0
  182. package/build/esm/tests/timesignature_tests.js +173 -0
  183. package/build/esm/tests/tremolo_tests.js +34 -0
  184. package/build/esm/tests/tuning_tests.js +56 -0
  185. package/build/esm/tests/tuplet_tests.js +711 -0
  186. package/build/esm/tests/typeguard_tests.js +82 -0
  187. package/build/esm/tests/unison_tests.js +74 -0
  188. package/build/esm/tests/vexflow_test_helpers.js +318 -0
  189. package/build/esm/tests/vf_prefix_tests.js +101 -0
  190. package/build/esm/tests/vibrato_tests.js +93 -0
  191. package/build/esm/tests/vibratobracket_tests.js +45 -0
  192. package/build/esm/tests/vitest/job-0.test.js +2 -0
  193. package/build/esm/tests/vitest/job-1.test.js +2 -0
  194. package/build/esm/tests/vitest/job-2.test.js +2 -0
  195. package/build/esm/tests/vitest/job-3.test.js +2 -0
  196. package/build/esm/tests/vitest/run.js +5 -0
  197. package/build/esm/tests/vitest.setup.js +44 -0
  198. package/build/esm/tests/voice_tests.js +69 -0
  199. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  200. package/build/types/entry/vexflow-core.d.ts +3 -0
  201. package/build/types/entry/vexflow-debug.d.ts +3 -0
  202. package/build/types/entry/vexflow.d.ts +3 -0
  203. package/build/types/src/accidental.d.ts +60 -0
  204. package/build/types/src/annotation.d.ts +58 -0
  205. package/build/types/src/articulation.d.ts +78 -0
  206. package/build/types/src/barnote.d.ts +29 -0
  207. package/build/types/src/beam.d.ts +158 -0
  208. package/build/types/src/bend.d.ts +67 -0
  209. package/build/types/src/boundingbox.d.ts +42 -0
  210. package/build/types/src/canvascontext.d.ts +93 -0
  211. package/build/types/src/chordsymbol.d.ts +109 -0
  212. package/build/types/src/clef.d.ts +38 -0
  213. package/build/types/src/clefnote.d.ts +17 -0
  214. package/build/types/src/crescendo.d.ts +26 -0
  215. package/build/types/src/curve.d.ts +42 -0
  216. package/build/types/src/dot.d.ts +19 -0
  217. package/build/types/src/easyscore.d.ts +152 -0
  218. package/build/types/src/element.d.ts +278 -0
  219. package/build/types/src/factory.d.ts +273 -0
  220. package/build/types/src/flag.d.ts +12 -0
  221. package/build/types/src/font.d.ts +96 -0
  222. package/build/types/src/fonts/academico.d.ts +1 -0
  223. package/build/types/src/fonts/academicobold.d.ts +1 -0
  224. package/build/types/src/fonts/bravura.d.ts +1 -0
  225. package/build/types/src/fonts/gonville.d.ts +1 -0
  226. package/build/types/src/fonts/petaluma.d.ts +1 -0
  227. package/build/types/src/fonts/petalumascript.d.ts +1 -0
  228. package/build/types/src/formatter.d.ts +226 -0
  229. package/build/types/src/fraction.d.ts +65 -0
  230. package/build/types/src/frethandfinger.d.ts +19 -0
  231. package/build/types/src/ghostnote.d.ts +16 -0
  232. package/build/types/src/glyphnote.d.ts +14 -0
  233. package/build/types/src/glyphs.d.ts +2935 -0
  234. package/build/types/src/gracenote.d.ts +17 -0
  235. package/build/types/src/gracenotegroup.d.ts +33 -0
  236. package/build/types/src/gracetabnote.d.ts +5 -0
  237. package/build/types/src/index.d.ts +86 -0
  238. package/build/types/src/keymanager.d.ts +25 -0
  239. package/build/types/src/keysignature.d.ts +50 -0
  240. package/build/types/src/keysignote.d.ts +11 -0
  241. package/build/types/src/metrics.d.ts +25 -0
  242. package/build/types/src/modifier.d.ts +90 -0
  243. package/build/types/src/modifiercontext.d.ts +48 -0
  244. package/build/types/src/multimeasurerest.d.ts +61 -0
  245. package/build/types/src/music.d.ts +91 -0
  246. package/build/types/src/note.d.ts +232 -0
  247. package/build/types/src/notehead.d.ts +50 -0
  248. package/build/types/src/notesubgroup.d.ts +18 -0
  249. package/build/types/src/ornament.d.ts +71 -0
  250. package/build/types/src/parenthesis.d.ts +21 -0
  251. package/build/types/src/parser.d.ts +45 -0
  252. package/build/types/src/pedalmarking.d.ts +63 -0
  253. package/build/types/src/registry.d.ts +40 -0
  254. package/build/types/src/rendercontext.d.ts +59 -0
  255. package/build/types/src/renderer.d.ts +35 -0
  256. package/build/types/src/repeatnote.d.ts +6 -0
  257. package/build/types/src/stave.d.ts +181 -0
  258. package/build/types/src/stavebarline.d.ts +38 -0
  259. package/build/types/src/staveconnector.d.ts +53 -0
  260. package/build/types/src/stavehairpin.d.ts +56 -0
  261. package/build/types/src/staveline.d.ts +49 -0
  262. package/build/types/src/stavemodifier.d.ts +35 -0
  263. package/build/types/src/stavenote.d.ts +150 -0
  264. package/build/types/src/staverepetition.d.ts +30 -0
  265. package/build/types/src/stavesection.d.ts +8 -0
  266. package/build/types/src/stavetempo.d.ts +43 -0
  267. package/build/types/src/stavetext.d.ts +11 -0
  268. package/build/types/src/stavetie.d.ts +104 -0
  269. package/build/types/src/stavevolta.d.ts +15 -0
  270. package/build/types/src/stem.d.ts +58 -0
  271. package/build/types/src/stemmablenote.d.ts +39 -0
  272. package/build/types/src/stringnumber.d.ts +26 -0
  273. package/build/types/src/strokes.d.ts +35 -0
  274. package/build/types/src/svgcontext.d.ts +135 -0
  275. package/build/types/src/system.d.ts +121 -0
  276. package/build/types/src/tables.d.ts +86 -0
  277. package/build/types/src/tabnote.d.ts +45 -0
  278. package/build/types/src/tabslide.d.ts +36 -0
  279. package/build/types/src/tabstave.d.ts +7 -0
  280. package/build/types/src/tabtie.d.ts +18 -0
  281. package/build/types/src/textbracket.d.ts +45 -0
  282. package/build/types/src/textdynamics.d.ts +34 -0
  283. package/build/types/src/textnote.d.ts +48 -0
  284. package/build/types/src/tickable.d.ts +149 -0
  285. package/build/types/src/tickcontext.d.ts +112 -0
  286. package/build/types/src/timesignature.d.ts +75 -0
  287. package/build/types/src/timesignote.d.ts +11 -0
  288. package/build/types/src/tremolo.d.ts +12 -0
  289. package/build/types/src/tuning.d.ts +23 -0
  290. package/build/types/src/tuplet.d.ts +98 -0
  291. package/build/types/src/typeguard.d.ts +100 -0
  292. package/build/types/src/util.d.ts +42 -0
  293. package/build/types/src/version.d.ts +3 -0
  294. package/build/types/src/vexflow.d.ts +261 -0
  295. package/build/types/src/vibrato.d.ts +20 -0
  296. package/build/types/src/vibratobracket.d.ts +28 -0
  297. package/build/types/src/voice.d.ts +109 -0
  298. package/build/types/src/web.d.ts +2 -0
  299. package/package.json +145 -0
  300. package/tests/flow.html +256 -0
@@ -0,0 +1,488 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { Articulation } from '../src/articulation.js';
3
+ import { EasyScore } from '../src/easyscore.js';
4
+ import { FretHandFinger } from '../src/frethandfinger.js';
5
+ import { Modifier } from '../src/modifier.js';
6
+ import { Parenthesis } from '../src/parenthesis.js';
7
+ import { StaveConnector } from '../src/staveconnector.js';
8
+ import { Stem } from '../src/stem.js';
9
+ import { Tuplet } from '../src/tuplet.js';
10
+ const EasyScoreTests = {
11
+ Start() {
12
+ VexFlowTests.module('EasyScore');
13
+ VexFlowTests.test('Basic', basic);
14
+ VexFlowTests.test('Accidentals', accidentals);
15
+ VexFlowTests.test('Durations', durations);
16
+ VexFlowTests.test('Chords', chords);
17
+ VexFlowTests.test('Dots', dots);
18
+ VexFlowTests.test('Types', types);
19
+ VexFlowTests.test('Options', options);
20
+ const run = VexFlowTests.runTests;
21
+ run('Draw Basic', drawBasicTest);
22
+ run('Draw Different KeySignature', drawDiffKeysig);
23
+ run('Draw Basic Muted', drawBasicMutedTest);
24
+ run('Draw Basic Harmonic', drawBasicHarmonicTest);
25
+ run('Draw Basic Slash', drawBasicSlashTest);
26
+ run('Draw Ghostnote Basic', drawGhostBasicTest);
27
+ run('Draw Ghostnote Dotted', drawGhostDottedTest);
28
+ run('Draw Parenthesised', drawParenthesisedTest);
29
+ run('Draw Accidentals', drawAccidentalsTest);
30
+ run('Draw Beams', drawBeamsTest);
31
+ run('Draw Tuplets', drawTupletsTest);
32
+ run('Draw Dots', drawDotsTest);
33
+ run('Draw Options', drawOptionsTest);
34
+ run('Draw Fingerings', drawFingeringsTest);
35
+ run('Keys', keys);
36
+ },
37
+ };
38
+ function createShortcuts(score) {
39
+ return {
40
+ voice: score.voice.bind(score),
41
+ notes: score.notes.bind(score),
42
+ beam: score.beam.bind(score),
43
+ tuplet: score.tuplet.bind(score),
44
+ };
45
+ }
46
+ function basic(assert) {
47
+ const score = new EasyScore();
48
+ const mustPass = ['c4', 'c#4', 'c4/r', 'c#5', 'c3/m', 'c3//m', 'c3//h', 'c3/s', 'c3//s', 'c3/g', 'c3//g'];
49
+ const mustFail = ['', '()', '7', '(c#4 e5 g6'];
50
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
51
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
52
+ }
53
+ function accidentals(assert) {
54
+ const score = new EasyScore();
55
+ const mustPass = [
56
+ 'c3',
57
+ 'c##3, cb3',
58
+ 'Cn3',
59
+ 'f3//m',
60
+ '(c##3 cbb3 cn3), cb3',
61
+ 'cbbs7',
62
+ 'cbb7',
63
+ 'cbss7',
64
+ 'cbs7',
65
+ 'cb7',
66
+ 'cdb7',
67
+ 'cd7',
68
+ 'c##7',
69
+ 'c#7',
70
+ 'cn7',
71
+ 'c++-7',
72
+ 'c++7',
73
+ 'c+-7',
74
+ 'c+7',
75
+ '(cbs3 bbs3 dbs3), ebs3',
76
+ '(cd7 cbb3 cn3), cb3',
77
+ 'co7',
78
+ 'ck7',
79
+ ];
80
+ const mustFail = [
81
+ 'ct3',
82
+ 'cdbb7',
83
+ '(cq cbb3 cn3), cb3',
84
+ '(cdd7 cbb3 cn3), cb3',
85
+ 'cbbbs7',
86
+ 'cbbss7',
87
+ 'cbsss7',
88
+ 'csbs7',
89
+ 'cddb7',
90
+ 'cddbb7',
91
+ 'cdd7',
92
+ 'c##b7',
93
+ 'c#bs7',
94
+ 'cnb#7',
95
+ 'c+#+b-d7',
96
+ 'c+--7',
97
+ 'c++--7',
98
+ 'c+++7',
99
+ 'cbk7',
100
+ 'cok7',
101
+ 'cko7',
102
+ 'c#s7',
103
+ ];
104
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
105
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
106
+ }
107
+ function durations(assert) {
108
+ const score = new EasyScore();
109
+ const mustPass = ['c3/4', 'c##3/w, cb3', 'c##3/w, cb3/q', 'c##3/q, cb3/32', '(c##3 cbb3 cn3), cb3'];
110
+ const mustFail = ['Cn3/]', '/', '(cq cbb3 cn3), cb3', '(cdd7 cbb3 cn3), cb3'];
111
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
112
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
113
+ }
114
+ function chords(assert) {
115
+ const score = new EasyScore();
116
+ const mustPass = [
117
+ '(c5)',
118
+ '(c3 e0 g9)',
119
+ '(c##4 cbb4 cn4)/w, (c#5 cb2 a3)/32',
120
+ '(d##4 cbb4 cn4)/w/r, (c#5 cb2 a3)',
121
+ '(c##4 cbb4 cn4)/4, (c#5 cb2 a3)',
122
+ '(c##4 cbb4 cn4)/m, (c#5 cb2 a3)',
123
+ ];
124
+ const mustFail = ['(c)'];
125
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
126
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
127
+ }
128
+ function dots(assert) {
129
+ const score = new EasyScore();
130
+ const mustPass = [
131
+ 'c3/4.',
132
+ 'c##3/w.., cb3',
133
+ 'f##3/s, cb3/q...',
134
+ 'c##3/q, cb3/32',
135
+ '(c##3 cbb3 cn3)., cb3',
136
+ '(c5).',
137
+ '(c##4 cbb4 cn4)/w.., (c#5 cb2 a3)/32',
138
+ ];
139
+ const mustFail = ['.', 'c.#', 'c#4./4'];
140
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
141
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
142
+ }
143
+ function types(assert) {
144
+ const score = new EasyScore();
145
+ const mustPass = ['c3/4/m.', 'c##3//r.., cb3', 'c##3/m.., cb3', 'c##3/r.., cb3', 'd##3/w/s, cb3/q...', 'Fb4'];
146
+ const mustFail = ['c4/q/U', '(c##4, cbb4 cn4)/w.., (c#5 cb2 a3)/32', 'z#3'];
147
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
148
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
149
+ }
150
+ function options(assert) {
151
+ const score = new EasyScore();
152
+ const mustPass = [
153
+ 'c3/4.[foo="bar"]',
154
+ 'c##3/w.., cb3[id="blah"]',
155
+ 'c##3/q, cb3/32',
156
+ '(c##3 cbb3 cn3).[blah="bod4o"], cb3',
157
+ '(c5)[fooooo="booo"]',
158
+ 'c#5[id="foobar"]',
159
+ ];
160
+ const mustFail = ['.[', 'f##3/w[], cb3/q...'];
161
+ mustPass.forEach((line) => assert.equal(score.parse(line).success, true, line));
162
+ mustFail.forEach((line) => assert.equal(score.parse(line).success, false, line));
163
+ }
164
+ function drawBasicTest(options) {
165
+ const f = VexFlowTests.makeFactory(options, 600, 350);
166
+ const score = f.EasyScore();
167
+ const system = f.System();
168
+ const { voice, notes } = createShortcuts(score);
169
+ system
170
+ .addStave({
171
+ voices: [
172
+ voice(notes('(d4 e4 g4)/q, c4/q, c4/q/r, c4/q', { stem: 'down' })),
173
+ voice(notes('c#5/h., c5/q', { stem: 'up' })),
174
+ ],
175
+ })
176
+ .addClef('treble');
177
+ system
178
+ .addStave({
179
+ voices: [voice(notes('c#3/q, cn3/q, bb3/q, d##3/q', { clef: 'bass' }))],
180
+ })
181
+ .addClef('bass');
182
+ system.addConnector().setType(StaveConnector.type.BRACKET);
183
+ f.draw();
184
+ options.assert.expect(0);
185
+ }
186
+ function drawDiffKeysig(options) {
187
+ const f = VexFlowTests.makeFactory(options, 600, 350);
188
+ const score = f.EasyScore();
189
+ const system = f.System();
190
+ const { voice, notes } = createShortcuts(score);
191
+ system
192
+ .addStave({
193
+ voices: [
194
+ voice(notes('(d4 e4 g4)/q, c4/q, c4/q/r, c4/q', { stem: 'down' })),
195
+ voice(notes('c5/h., c5/q', { stem: 'up' })),
196
+ ],
197
+ })
198
+ .addClef('treble')
199
+ .addTimeSignature('4/4')
200
+ .addKeySignature('D');
201
+ system
202
+ .addStave({
203
+ voices: [voice(notes('c#3/q, cn3/q, bb3/q, d##3/q', { clef: 'bass' }))],
204
+ })
205
+ .addClef('bass')
206
+ .addTimeSignature('4/4');
207
+ system.addConnector().setType(StaveConnector.type.BRACKET);
208
+ f.draw();
209
+ options.assert.expect(0);
210
+ }
211
+ function drawBasicMutedTest(options) {
212
+ const f = VexFlowTests.makeFactory(options, 600, 350);
213
+ const score = f.EasyScore();
214
+ const system = f.System();
215
+ const { voice, notes } = createShortcuts(score);
216
+ system
217
+ .addStave({
218
+ voices: [
219
+ voice(notes('(d4 e4 g4)/q/m, c4/q/m, c4/q/r, c4/q/m', { stem: 'down' })),
220
+ voice(notes('c#5/h/m., c5/q/m', { stem: 'up' })),
221
+ ],
222
+ })
223
+ .addClef('treble');
224
+ system
225
+ .addStave({
226
+ voices: [voice(notes('c#3/q/m, cn3/q/m, bb3/q/m, d##3/q/m', { clef: 'bass' }))],
227
+ })
228
+ .addClef('bass');
229
+ system.addConnector().setType(StaveConnector.type.BRACKET);
230
+ f.draw();
231
+ options.assert.expect(0);
232
+ }
233
+ function drawBasicHarmonicTest(options) {
234
+ const f = VexFlowTests.makeFactory(options, 600, 350);
235
+ const score = f.EasyScore();
236
+ const system = f.System();
237
+ const { voice, notes } = createShortcuts(score);
238
+ system
239
+ .addStave({
240
+ voices: [
241
+ voice(notes('(d4 e4 g4)/q/h, c4/q/h, c4/q/r, c4/q/h', { stem: 'down' })),
242
+ voice(notes('c#5/h/h., c5/q/h', { stem: 'up' })),
243
+ ],
244
+ })
245
+ .addClef('treble');
246
+ system
247
+ .addStave({
248
+ voices: [voice(notes('c#3/q/h, cn3/q/h, bb3/q/h, d##3/q/h', { clef: 'bass' }))],
249
+ })
250
+ .addClef('bass');
251
+ system.addConnector().setType(StaveConnector.type.BRACKET);
252
+ f.draw();
253
+ options.assert.expect(0);
254
+ }
255
+ function drawBasicSlashTest(options) {
256
+ const f = VexFlowTests.makeFactory(options, 600, 350);
257
+ const score = f.EasyScore();
258
+ const system = f.System();
259
+ const { voice, notes } = createShortcuts(score);
260
+ system
261
+ .addStave({
262
+ voices: [
263
+ voice(notes('(d4 e4 g4)/q/s, c4/q/s, c4/q/r, c4/q/s', { stem: 'down' })),
264
+ voice(notes('c#5/h/s., c5/q/s', { stem: 'up' })),
265
+ ],
266
+ })
267
+ .addClef('treble');
268
+ system
269
+ .addStave({
270
+ voices: [voice(notes('c#3/q/s, cn3/q/s, bb3/q/s, d##3/q/s', { clef: 'bass' }))],
271
+ })
272
+ .addClef('bass');
273
+ system.addConnector().setType(StaveConnector.type.BRACKET);
274
+ f.draw();
275
+ options.assert.expect(0);
276
+ }
277
+ function drawGhostBasicTest(options) {
278
+ const f = VexFlowTests.makeFactory(options, 550);
279
+ const score = f.EasyScore();
280
+ const system = f.System();
281
+ system.addStave({
282
+ voices: [
283
+ score.voice([
284
+ ...score.notes('f#5/4, f5, db5, c5', { stem: 'up' }),
285
+ ...score.beam(score.notes('c5/8, d5, fn5, e5', { stem: 'up' })),
286
+ ...score.beam(score.notes('d5, c5', { stem: 'up' })),
287
+ ], { time: '7/4' }),
288
+ score.voice(score.notes('c4/h/g, f4/4, c4/4/g, e4/4, c4/8/g, d##4/8, c4/8, c4/8', { stem: 'down' }), {
289
+ time: '7/4',
290
+ }),
291
+ ],
292
+ });
293
+ f.draw();
294
+ options.assert.expect(0);
295
+ }
296
+ function drawGhostDottedTest(options) {
297
+ const f = VexFlowTests.makeFactory(options, 550);
298
+ const score = f.EasyScore();
299
+ const system = f.System();
300
+ system.addStave({
301
+ voices: [
302
+ score.voice([
303
+ ...score.notes('c4/4/g., fbb5/8, d5/4', { stem: 'up' }),
304
+ ...score.beam(score.notes('c5/8, c#5/16, d5/16', { stem: 'up' })),
305
+ ...score.notes('c4/2/g.., fn5/8', { stem: 'up' }),
306
+ ], { time: '8/4' }),
307
+ score.voice([
308
+ ...score.notes('f#4/4', { stem: 'down' }),
309
+ ...score.beam(score.notes('e4/8, d4/8', { stem: 'down' })),
310
+ ...score.notes('c4/4/g.., cb4/16, c#4/h, d4/4', { stem: 'down' }),
311
+ ...score.beam(score.notes('fn4/8, e4/8', { stem: 'down' })),
312
+ ], { time: '8/4' }),
313
+ ],
314
+ });
315
+ f.draw();
316
+ options.assert.expect(0);
317
+ }
318
+ function drawParenthesisedTest(options) {
319
+ const f = VexFlowTests.makeFactory(options, 600, 350);
320
+ const score = f.EasyScore();
321
+ const system = f.System();
322
+ const { voice, notes } = createShortcuts(score);
323
+ const notes1 = notes('(d4 e4 g4)/q, c4/q, c4/q/r, c4/q', { stem: 'down' });
324
+ Parenthesis.buildAndAttach([notes1[0], notes1[3]]);
325
+ const notes2 = notes('c#5/h., c5/q', { stem: 'down' });
326
+ Parenthesis.buildAndAttach([notes2[0], notes2[1]]);
327
+ system
328
+ .addStave({
329
+ voices: [voice(notes1), voice(notes2)],
330
+ })
331
+ .addClef('treble');
332
+ const notes3 = notes('c#3/q, cn3/q, bb3/q, d##3/q', { stem: 'down' });
333
+ Parenthesis.buildAndAttach(notes3);
334
+ system
335
+ .addStave({
336
+ voices: [voice(notes3)],
337
+ })
338
+ .addClef('bass');
339
+ system.addConnector().setType(StaveConnector.type.BRACKET);
340
+ f.draw();
341
+ options.assert.expect(0);
342
+ }
343
+ function drawAccidentalsTest(options) {
344
+ const f = VexFlowTests.makeFactory(options, 600, 350);
345
+ const score = f.EasyScore();
346
+ const system = f.System();
347
+ const { voice, notes } = createShortcuts(score);
348
+ system
349
+ .addStave({
350
+ voices: [
351
+ voice(notes('(cbbs4 ebb4 gbss4)/q, cbs4/q, cdb4/q/r, cd4/q', { stem: 'down' })),
352
+ voice(notes('c++-5/h., c++5/q', { stem: 'up' })),
353
+ ],
354
+ })
355
+ .addClef('treble');
356
+ system
357
+ .addStave({
358
+ voices: [voice(notes('c+-3/q, c+3/q, bb3/q, d##3/q', { clef: 'bass' }))],
359
+ })
360
+ .addClef('bass');
361
+ system.addConnector().setType(StaveConnector.type.BRACKET);
362
+ f.draw();
363
+ options.assert.expect(0);
364
+ }
365
+ function drawBeamsTest(options) {
366
+ const f = VexFlowTests.makeFactory(options, 600, 250);
367
+ const score = f.EasyScore();
368
+ const system = f.System();
369
+ const { voice, notes, beam } = createShortcuts(score);
370
+ system
371
+ .addStave({
372
+ voices: [
373
+ voice(notes('(c4 e4 g4)/q, c4/q, c4/q/r, c4/q', { stem: 'down' })),
374
+ voice([...notes('c#5/h.', { stem: 'up' }), ...beam(notes('c5/8, c5/8', { stem: 'up' }))]),
375
+ ],
376
+ })
377
+ .addClef('treble');
378
+ f.draw();
379
+ options.assert.expect(0);
380
+ }
381
+ function drawTupletsTest(options) {
382
+ const f = VexFlowTests.makeFactory(options, 600, 250);
383
+ const score = f.EasyScore();
384
+ const system = f.System();
385
+ const { voice, notes, tuplet, beam } = createShortcuts(score);
386
+ const v1Tuplet = tuplet(notes('(c4 e4 g4)/q, cbb4/q, c4/q', { stem: 'down' }), {
387
+ location: Tuplet.LOCATION_BOTTOM,
388
+ });
389
+ const v1HalfNote = notes('c4/h', { stem: 'down' });
390
+ const v1 = voice([...v1Tuplet, ...v1HalfNote]);
391
+ const v2HalfNote = notes('c#5/h.', { stem: 'up' });
392
+ const v2Tuplet = tuplet(beam(notes('cb5/8, cn5/8, c5/8', { stem: 'up' })));
393
+ const v2 = voice([...v2HalfNote, ...v2Tuplet]);
394
+ system.addStave({ voices: [v1, v2] }).addClef('treble');
395
+ f.draw();
396
+ options.assert.expect(0);
397
+ }
398
+ function drawDotsTest(options) {
399
+ const f = VexFlowTests.makeFactory(options, 600, 250);
400
+ const score = f.EasyScore();
401
+ const system = f.System();
402
+ const { voice, notes } = createShortcuts(score);
403
+ system
404
+ .addStave({
405
+ voices: [voice(notes('(c4 e4 g4)/8., (c4 e4 g4)/8.., (c4 e4 g4)/8..., (c4 e4 g4)/8...., (c4 e4 g4)/16...'))],
406
+ })
407
+ .addClef('treble');
408
+ f.draw();
409
+ options.assert.expect(0);
410
+ }
411
+ function drawOptionsTest(options) {
412
+ const f = VexFlowTests.makeFactory(options, 500, 200);
413
+ const score = f.EasyScore();
414
+ const system = f.System();
415
+ const notes = score.notes('B4/h[id="foobar", class="red,bold", stem="up", articulations="staccato.below,tenuto"], B4/q[articulations="accent.above"], B4/q[stem="down"]');
416
+ system.addStave({ voices: [score.voice(notes)] });
417
+ f.draw();
418
+ const note0 = notes[0];
419
+ const note1 = notes[1];
420
+ const note0Modifier0 = note0.getModifiers()[0];
421
+ const note0Modifier1 = note0.getModifiers()[1];
422
+ const note1Modifier0 = note1.getModifiers()[0];
423
+ options.assert.equal(note0.getAttribute('id'), 'foobar');
424
+ options.assert.ok(note0.hasClass('red'));
425
+ options.assert.ok(note0.hasClass('bold'));
426
+ options.assert.equal(note0Modifier0.getCategory(), Articulation.CATEGORY);
427
+ options.assert.equal(note0Modifier0.type, 'a.');
428
+ options.assert.equal(note0Modifier0.getPosition(), Modifier.Position.BELOW);
429
+ options.assert.equal(note0Modifier1.getCategory(), Articulation.CATEGORY);
430
+ options.assert.equal(note0Modifier1.type, 'a-');
431
+ options.assert.equal(note0Modifier1.getPosition(), Modifier.Position.ABOVE);
432
+ options.assert.equal(note0.getStemDirection(), Stem.UP);
433
+ options.assert.equal(note1Modifier0.getCategory(), Articulation.CATEGORY);
434
+ options.assert.equal(note1Modifier0.type, 'a>');
435
+ options.assert.equal(note1Modifier0.getPosition(), Modifier.Position.ABOVE);
436
+ options.assert.equal(notes[2].getStemDirection(), Stem.DOWN);
437
+ }
438
+ function drawFingeringsTest(options) {
439
+ const f = VexFlowTests.makeFactory(options, 500, 200);
440
+ const score = f.EasyScore();
441
+ const system = f.System();
442
+ const notes = score.notes('C4/q[fingerings="1"], E4[fingerings="3.above"], G4[fingerings="5.below"], (C4 E4 G4)[fingerings="1,3,5"]');
443
+ system.addStave({ voices: [score.voice(notes)] });
444
+ f.draw();
445
+ const note0Modifier0 = notes[0].getModifiers()[0];
446
+ options.assert.equal(note0Modifier0.getCategory(), FretHandFinger.CATEGORY);
447
+ options.assert.equal(note0Modifier0.getFretHandFinger(), '1');
448
+ options.assert.equal(note0Modifier0.getPosition(), Modifier.Position.LEFT);
449
+ const note1Modifier0 = notes[1].getModifiers()[0];
450
+ options.assert.equal(note1Modifier0.getCategory(), FretHandFinger.CATEGORY);
451
+ options.assert.equal(note1Modifier0.getFretHandFinger(), '3');
452
+ options.assert.equal(note1Modifier0.getPosition(), Modifier.Position.ABOVE);
453
+ const note2Modifier0 = notes[2].getModifiers()[0];
454
+ options.assert.equal(note2Modifier0.getCategory(), FretHandFinger.CATEGORY);
455
+ options.assert.equal(note2Modifier0.getFretHandFinger(), '5');
456
+ options.assert.equal(note2Modifier0.getPosition(), Modifier.Position.BELOW);
457
+ const note3Modifiers = notes[3].getModifiers();
458
+ const note3Modifier0 = note3Modifiers[0];
459
+ const note3Modifier1 = note3Modifiers[1];
460
+ const note3Modifier2 = note3Modifiers[2];
461
+ options.assert.equal(note3Modifier0.getCategory(), FretHandFinger.CATEGORY);
462
+ options.assert.equal(note3Modifier0.getFretHandFinger(), '1');
463
+ options.assert.equal(note3Modifier0.getPosition(), Modifier.Position.LEFT);
464
+ options.assert.equal(note3Modifier1.getCategory(), FretHandFinger.CATEGORY);
465
+ options.assert.equal(note3Modifier1.getFretHandFinger(), '3');
466
+ options.assert.equal(note3Modifier1.getPosition(), Modifier.Position.LEFT);
467
+ options.assert.equal(note3Modifier2.getCategory(), FretHandFinger.CATEGORY);
468
+ options.assert.equal(note3Modifier2.getFretHandFinger(), '5');
469
+ options.assert.equal(note3Modifier2.getPosition(), Modifier.Position.LEFT);
470
+ }
471
+ function keys(options) {
472
+ const f = VexFlowTests.makeFactory(options, 700, 200);
473
+ const score = f.EasyScore();
474
+ const system = f.System();
475
+ const notes = score.notes('c#3/q, c##3, cb3, cbb3, cn3, c3, cbbs3, cbss3, cbs3, cdb3, cd3, c++-3, c++3, c+-3, c+3, co3, ck3', { clef: 'bass' });
476
+ system.addStave({ voices: [f.Voice().setStrict(false).addTickables(notes)] }).addClef('bass');
477
+ f.draw();
478
+ options.assert.equal(notes[0].keys, 'c#/3');
479
+ options.assert.equal(notes[1].keys, 'c##/3');
480
+ options.assert.equal(notes[2].keys, 'cb/3');
481
+ options.assert.equal(notes[3].keys, 'cbb/3');
482
+ options.assert.equal(notes[4].keys, 'cn/3');
483
+ for (let i = 5; i < notes.length; i++) {
484
+ options.assert.equal(notes[i].keys, 'c/3');
485
+ }
486
+ }
487
+ VexFlowTests.register(EasyScoreTests);
488
+ export { EasyScoreTests };
@@ -0,0 +1,44 @@
1
+ import { VexFlowTests } from './vexflow_test_helpers.js';
2
+ import { Factory } from '../src/factory.js';
3
+ import { Barline } from '../src/stavebarline.js';
4
+ const FactoryTests = {
5
+ Start() {
6
+ VexFlowTests.module('Factory');
7
+ VexFlowTests.test('Defaults', defaults);
8
+ const run = VexFlowTests.runTests;
9
+ run('Draw', draw);
10
+ run('Draw Tab (repeat barlines must be aligned)', drawTab);
11
+ },
12
+ };
13
+ function defaults(assert) {
14
+ assert.throws(() => new Factory({ renderer: { elementId: '', width: 700, height: 500 } }), 'Empty string for elementId throws an exception.');
15
+ const factory = new Factory({
16
+ renderer: { elementId: null, width: 700, height: 500 },
17
+ });
18
+ const options = factory.options;
19
+ assert.equal(options.renderer.width, 700);
20
+ assert.equal(options.renderer.height, 500);
21
+ assert.equal(options.renderer.elementId, null);
22
+ assert.equal(options.stave.space, 10);
23
+ }
24
+ function draw(options) {
25
+ const f = Factory.newFromElementId(options.elementId);
26
+ f.Stave().setClef('treble');
27
+ f.draw();
28
+ options.assert.expect(0);
29
+ }
30
+ function drawTab(options) {
31
+ const factory = VexFlowTests.makeFactory(options, 500, 400);
32
+ const system = factory.System({ width: 500 });
33
+ const stave = factory.Stave().setClef('treble').setKeySignature('C#').setBegBarType(Barline.type.REPEAT_BEGIN);
34
+ const voices = [factory.Voice().addTickables([factory.GhostNote({ duration: 'w' })])];
35
+ system.addStave({ stave, voices });
36
+ const tabStave = factory.TabStave().setClef('tab').setBegBarType(Barline.type.REPEAT_BEGIN);
37
+ const tabVoices = [factory.Voice().addTickables([factory.GhostNote({ duration: 'w' })])];
38
+ system.addStave({ stave: tabStave, voices: tabVoices });
39
+ factory.draw();
40
+ options.assert.equal(stave.getModifiers()[0].getX(), tabStave.getModifiers()[0].getX());
41
+ options.assert.expect(1);
42
+ }
43
+ VexFlowTests.register(FactoryTests);
44
+ export { FactoryTests };
@@ -0,0 +1,134 @@
1
+ import { VexFlow } from '../src/vexflow.js';
2
+ import { VexFlowTests } from './vexflow_test_helpers.js';
3
+ import { Accidental } from '../src/accidental.js';
4
+ import { Bend } from '../src/bend.js';
5
+ import { CanvasContext } from '../src/canvascontext.js';
6
+ import { Font, FontStyle, FontWeight } from '../src/font.js';
7
+ import { PedalMarking } from '../src/pedalmarking.js';
8
+ import { StaveNote } from '../src/stavenote.js';
9
+ import { TextBracket } from '../src/textbracket.js';
10
+ import { TextNote } from '../src/textnote.js';
11
+ import { Voice } from '../src/voice.js';
12
+ const FontTests = {
13
+ Start() {
14
+ VexFlowTests.module('Font');
15
+ VexFlowTests.test('setFont', setFont);
16
+ VexFlowTests.test('Parsing', fontParsing);
17
+ VexFlowTests.test('Sizes', fontSizes);
18
+ const run = VexFlowTests.runTests;
19
+ run('Set Text Font to Georgia', setTextFontToGeorgia);
20
+ run('Set Music Font to Petaluma', setMusicFontToPetaluma);
21
+ },
22
+ };
23
+ function setFont(assert) {
24
+ const canvas = document.createElement('canvas');
25
+ canvas.width = 800;
26
+ canvas.height = 400;
27
+ const ctx = new CanvasContext(canvas.getContext('2d'));
28
+ ctx.setFont('PetalumaScript', '100px', 'normal', 'italic');
29
+ assert.equal(ctx.font, 'italic 100px PetalumaScript');
30
+ const voice = new Voice();
31
+ voice.setFont('bold 32pt Arial');
32
+ const fontInfo = voice.fontInfo;
33
+ assert.equal(fontInfo === null || fontInfo === void 0 ? void 0 : fontInfo.size, '32pt');
34
+ const flat = new Accidental('b');
35
+ flat.setFont(undefined, undefined, undefined, 'italic');
36
+ assert.equal(flat.getFont(), 'italic 30pt Bravura,Academico');
37
+ flat.setFont(undefined, undefined, 'bold', undefined);
38
+ assert.equal(flat.getFont(), 'bold 30pt Bravura,Academico');
39
+ flat.setFont(undefined, undefined, 'bold', 'italic');
40
+ assert.equal(flat.getFont(), 'italic bold 30pt Bravura,Academico');
41
+ flat.setFont(undefined, undefined, 'bold', 'oblique');
42
+ assert.equal(flat.getFont(), 'oblique bold 30pt Bravura,Academico');
43
+ flat.setFont(undefined, undefined, 'normal', '');
44
+ assert.equal(flat.getFont(), '30pt Bravura,Academico');
45
+ }
46
+ function fontParsing(assert) {
47
+ const b = new Bend([
48
+ { type: Bend.UP, text: '1/2' },
49
+ { type: Bend.DOWN, text: '' },
50
+ ]);
51
+ const bFont = b.fontInfo;
52
+ assert.equal(bFont === null || bFont === void 0 ? void 0 : bFont.family, 'Bravura,Academico');
53
+ assert.equal(bFont === null || bFont === void 0 ? void 0 : bFont.size, 10);
54
+ assert.equal(bFont === null || bFont === void 0 ? void 0 : bFont.weight, FontWeight.NORMAL);
55
+ assert.equal(bFont === null || bFont === void 0 ? void 0 : bFont.style, FontStyle.NORMAL);
56
+ const f1 = 'Roboto Slab, serif';
57
+ const t = new TextNote({ duration: '4', font: { family: f1 } });
58
+ assert.equal(f1, t.fontInfo.family);
59
+ const n1 = new StaveNote({ keys: ['e/5'], duration: '4' });
60
+ const n2 = new StaveNote({ keys: ['c/5'], duration: '4' });
61
+ const tb = new TextBracket({ start: n1, stop: n2 });
62
+ const f2 = tb.fontInfo;
63
+ assert.equal(f2 === null || f2 === void 0 ? void 0 : f2.size, 15);
64
+ assert.equal(f2 === null || f2 === void 0 ? void 0 : f2.style, FontStyle.ITALIC);
65
+ const f3 = Font.fromCSSString(`bold 1.5em/3 "Lucida Sans Typewriter", "Lucida Console", Consolas, monospace`);
66
+ const f3SizeInPx = Font.convertSizeToPixelValue(f3.size);
67
+ assert.equal(f3SizeInPx, 24);
68
+ }
69
+ function fontSizes(assert) {
70
+ {
71
+ const size = '17px';
72
+ const sizeInEm = Font.convertSizeToPixelValue(size) / Font.scaleToPxFrom.em;
73
+ assert.equal(sizeInEm, 1.0625);
74
+ }
75
+ {
76
+ const size = '2em';
77
+ const sizeInPx = Font.convertSizeToPixelValue(size);
78
+ assert.equal(sizeInPx, 32);
79
+ }
80
+ {
81
+ const pedal = new PedalMarking([]);
82
+ assert.equal(pedal.getFont(), '30pt Bravura,Academico');
83
+ assert.equal(pedal.fontSizeInPoints, 30);
84
+ assert.equal(pedal.fontSizeInPixels, 40);
85
+ const doubledSizePx = pedal.fontSizeInPixels * 2;
86
+ assert.equal(doubledSizePx, 80);
87
+ const doubledSizePt = Font.scaleSize(pedal.fontSizeInPoints, 2);
88
+ assert.equal(doubledSizePt, 60);
89
+ assert.equal(Font.scaleSize('1.5em', 3), '4.5em');
90
+ }
91
+ }
92
+ function setTextFontToGeorgia(options) {
93
+ const factory = VexFlowTests.makeFactory(options, 400, 200);
94
+ const stave = factory.Stave({ y: 40 });
95
+ const score = factory.EasyScore();
96
+ const voice1 = score.voice([
97
+ factory.StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: -1, duration: 'h' }),
98
+ factory.StaveNote({ keys: ['d/4', 'f/4'], stemDirection: -1, duration: 'q' }),
99
+ factory.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: 'q' }),
100
+ ]);
101
+ const georgiaFont = {
102
+ family: 'Georgia, Courier New, serif',
103
+ size: 14,
104
+ weight: 'bold',
105
+ style: 'italic',
106
+ };
107
+ const voice2 = score.voice([
108
+ factory
109
+ .TextNote({ text: 'Here are some fun lyrics...', duration: 'w' })
110
+ .setJustification(TextNote.Justification.LEFT)
111
+ .setFont(georgiaFont),
112
+ ]);
113
+ const formatter = factory.Formatter();
114
+ formatter.joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
115
+ factory.draw();
116
+ options.assert.ok(true);
117
+ }
118
+ function setMusicFontToPetaluma(options) {
119
+ VexFlow.setFonts('Petaluma');
120
+ const factory = VexFlowTests.makeFactory(options, 400, 200);
121
+ const stave = factory.Stave({ y: 40 });
122
+ const score = factory.EasyScore();
123
+ const voice = score.voice([
124
+ factory.StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stemDirection: -1, duration: 'h' }),
125
+ factory.StaveNote({ keys: ['d/4', 'f/4'], stemDirection: -1, duration: 'q' }),
126
+ factory.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stemDirection: -1, duration: 'q' }),
127
+ ]);
128
+ const formatter = factory.Formatter();
129
+ formatter.joinVoices([voice]).formatToStave([voice], stave);
130
+ factory.draw();
131
+ options.assert.ok(true);
132
+ }
133
+ VexFlowTests.register(FontTests);
134
+ export { FontTests };