vexflow 4.0.1-beta.1 → 4.0.1-beta.2

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 (331) 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 +92 -24
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +38 -16
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-font-gonville.js +1 -1
  10. package/build/cjs/vexflow-font-gonville.js.map +1 -1
  11. package/build/cjs/vexflow-gonville.js +2 -2
  12. package/build/cjs/vexflow-gonville.js.map +1 -1
  13. package/build/cjs/vexflow-petaluma.js +2 -2
  14. package/build/cjs/vexflow-petaluma.js.map +1 -1
  15. package/build/cjs/vexflow.js +2 -2
  16. package/build/cjs/vexflow.js.map +1 -1
  17. package/build/esm/entry/vexflow-bravura.js +11 -0
  18. package/build/esm/entry/vexflow-core.js +54 -0
  19. package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
  20. package/build/esm/entry/vexflow-debug.js +3 -0
  21. package/build/esm/entry/vexflow-font-bravura.js +7 -0
  22. package/build/esm/entry/vexflow-font-custom.js +7 -0
  23. package/build/esm/entry/vexflow-font-gonville.js +7 -0
  24. package/build/esm/entry/vexflow-font-petaluma.js +7 -0
  25. package/build/esm/entry/vexflow-gonville.js +11 -0
  26. package/build/esm/entry/vexflow-petaluma.js +11 -0
  27. package/build/esm/entry/vexflow.js +9 -0
  28. package/build/esm/src/accidental.js +348 -0
  29. package/build/esm/src/annotation.js +232 -0
  30. package/build/esm/src/articulation.js +267 -0
  31. package/build/esm/src/barnote.js +58 -0
  32. package/build/esm/src/beam.js +632 -0
  33. package/build/esm/src/bend.js +202 -0
  34. package/build/esm/src/boundingbox.js +59 -0
  35. package/build/esm/src/boundingboxcomputation.js +107 -0
  36. package/build/esm/src/canvascontext.js +202 -0
  37. package/build/esm/src/chordsymbol.js +578 -0
  38. package/build/esm/src/clef.js +153 -0
  39. package/build/esm/src/clefnote.js +65 -0
  40. package/build/esm/src/crescendo.js +77 -0
  41. package/build/esm/src/curve.js +118 -0
  42. package/build/esm/src/dot.js +137 -0
  43. package/build/esm/src/easyscore.js +374 -0
  44. package/build/esm/src/element.js +216 -0
  45. package/build/esm/src/factory.js +440 -0
  46. package/build/esm/src/flow.js +275 -0
  47. package/build/esm/src/font.js +264 -0
  48. package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
  49. package/build/esm/src/fonts/bravura_metrics.js +507 -0
  50. package/build/esm/src/fonts/custom_glyphs.js +78 -0
  51. package/build/esm/src/fonts/custom_metrics.js +5 -0
  52. package/build/esm/src/fonts/gonville_glyphs.js +828 -0
  53. package/build/esm/src/fonts/gonville_metrics.js +421 -0
  54. package/build/esm/src/fonts/load_all.js +10 -0
  55. package/build/esm/src/fonts/load_bravura.js +6 -0
  56. package/build/esm/src/fonts/load_custom.js +6 -0
  57. package/build/esm/src/fonts/load_gonville.js +6 -0
  58. package/build/esm/src/fonts/load_petaluma.js +6 -0
  59. package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
  60. package/build/esm/src/fonts/petaluma_metrics.js +536 -0
  61. package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
  62. package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
  63. package/build/esm/src/fonts/textfonts.js +44 -0
  64. package/build/esm/src/formatter.js +568 -0
  65. package/build/esm/src/fraction.js +171 -0
  66. package/build/esm/src/frethandfinger.js +156 -0
  67. package/build/esm/src/ghostnote.js +50 -0
  68. package/build/esm/src/glyph.js +331 -0
  69. package/build/esm/src/glyphnote.js +55 -0
  70. package/build/esm/src/gracenote.js +133 -0
  71. package/build/esm/src/gracenotegroup.js +128 -0
  72. package/build/esm/src/gracetabnote.js +12 -0
  73. package/build/esm/src/index.js +91 -0
  74. package/build/esm/src/keymanager.js +99 -0
  75. package/build/esm/src/keysignature.js +250 -0
  76. package/build/esm/src/keysignote.js +28 -0
  77. package/build/esm/src/modifier.js +128 -0
  78. package/build/esm/src/modifiercontext.js +110 -0
  79. package/build/esm/src/multimeasurerest.js +173 -0
  80. package/build/esm/src/music.js +322 -0
  81. package/build/esm/src/note.js +371 -0
  82. package/build/esm/src/notehead.js +169 -0
  83. package/build/esm/src/notesubgroup.js +59 -0
  84. package/build/esm/src/ornament.js +206 -0
  85. package/build/esm/src/parenthesis.js +76 -0
  86. package/build/esm/src/parser.js +164 -0
  87. package/build/esm/src/pedalmarking.js +192 -0
  88. package/build/esm/src/registry.js +81 -0
  89. package/build/esm/src/rendercontext.js +24 -0
  90. package/build/esm/src/renderer.js +112 -0
  91. package/build/esm/src/repeatnote.js +22 -0
  92. package/build/esm/src/stave.js +547 -0
  93. package/build/esm/src/stavebarline.js +182 -0
  94. package/build/esm/src/staveconnector.js +196 -0
  95. package/build/esm/src/stavehairpin.js +120 -0
  96. package/build/esm/src/staveline.js +218 -0
  97. package/build/esm/src/stavemodifier.js +77 -0
  98. package/build/esm/src/stavenote.js +855 -0
  99. package/build/esm/src/staverepetition.js +155 -0
  100. package/build/esm/src/stavesection.js +58 -0
  101. package/build/esm/src/stavetempo.js +91 -0
  102. package/build/esm/src/stavetext.js +82 -0
  103. package/build/esm/src/stavetie.js +141 -0
  104. package/build/esm/src/stavevolta.js +67 -0
  105. package/build/esm/src/stem.js +131 -0
  106. package/build/esm/src/stemmablenote.js +193 -0
  107. package/build/esm/src/stringnumber.js +231 -0
  108. package/build/esm/src/strokes.js +200 -0
  109. package/build/esm/src/svgcontext.js +414 -0
  110. package/build/esm/src/system.js +116 -0
  111. package/build/esm/src/tables.js +1102 -0
  112. package/build/esm/src/tabnote.js +299 -0
  113. package/build/esm/src/tabslide.js +76 -0
  114. package/build/esm/src/tabstave.js +17 -0
  115. package/build/esm/src/tabtie.js +19 -0
  116. package/build/esm/src/textbracket.js +144 -0
  117. package/build/esm/src/textdynamics.js +81 -0
  118. package/build/esm/src/textformatter.js +177 -0
  119. package/build/esm/src/textnote.js +176 -0
  120. package/build/esm/src/tickable.js +214 -0
  121. package/build/esm/src/tickcontext.js +170 -0
  122. package/build/esm/src/timesigglyph.js +85 -0
  123. package/build/esm/src/timesignature.js +89 -0
  124. package/build/esm/src/timesignote.js +32 -0
  125. package/build/esm/src/tremolo.js +47 -0
  126. package/build/esm/src/tuning.js +54 -0
  127. package/build/esm/src/tuplet.js +240 -0
  128. package/build/esm/src/typeguard.js +30 -0
  129. package/build/esm/src/util.js +58 -0
  130. package/build/esm/src/version.js +3 -3
  131. package/build/esm/src/vex.js +51 -0
  132. package/build/esm/src/vibrato.js +100 -0
  133. package/build/esm/src/vibratobracket.js +50 -0
  134. package/build/esm/src/voice.js +187 -0
  135. package/build/esm/src/web.js +15 -0
  136. package/build/esm/tests/accidental_tests.js +974 -0
  137. package/build/esm/tests/annotation_tests.js +377 -0
  138. package/build/esm/tests/articulation_tests.js +365 -0
  139. package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
  140. package/build/esm/tests/bach_tests.js +335 -0
  141. package/build/esm/tests/barline_tests.js +52 -0
  142. package/build/esm/tests/beam_tests.js +595 -0
  143. package/build/esm/tests/bend_tests.js +215 -0
  144. package/build/esm/tests/boundingbox_tests.js +53 -0
  145. package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
  146. package/build/esm/tests/chordsymbol_tests.js +320 -0
  147. package/build/esm/tests/clef_tests.js +131 -0
  148. package/build/esm/tests/curve_tests.js +118 -0
  149. package/build/esm/tests/dot_tests.js +123 -0
  150. package/build/esm/tests/easyscore_tests.js +459 -0
  151. package/build/esm/tests/factory_tests.js +44 -0
  152. package/build/esm/tests/font_tests.js +135 -0
  153. package/build/esm/tests/formatter/framestack.js +61 -0
  154. package/build/esm/tests/formatter/tests.js +203 -0
  155. package/build/esm/tests/formatter_tests.js +669 -0
  156. package/build/esm/tests/fraction_tests.js +72 -0
  157. package/build/esm/tests/ghostnote_tests.js +77 -0
  158. package/build/esm/tests/glyphnote_tests.js +113 -0
  159. package/build/esm/tests/gracenote_tests.js +413 -0
  160. package/build/esm/tests/gracetabnote_tests.js +79 -0
  161. package/build/esm/tests/index.js +68 -0
  162. package/build/esm/tests/key_clef_tests.js +103 -0
  163. package/build/esm/tests/keymanager_tests.js +68 -0
  164. package/build/esm/tests/keysignature_tests.js +308 -0
  165. package/build/esm/tests/mocks.js +71 -0
  166. package/build/esm/tests/modifier_tests.js +24 -0
  167. package/build/esm/tests/multimeasurerest_tests.js +141 -0
  168. package/build/esm/tests/music_tests.js +161 -0
  169. package/build/esm/tests/notehead_tests.js +137 -0
  170. package/build/esm/tests/notesubgroup_tests.js +149 -0
  171. package/build/esm/tests/offscreencanvas_tests.js +47 -0
  172. package/build/esm/tests/ornament_tests.js +298 -0
  173. package/build/esm/tests/parser_tests.js +122 -0
  174. package/build/esm/tests/pedalmarking_tests.js +64 -0
  175. package/build/esm/tests/percussion_tests.js +180 -0
  176. package/build/esm/tests/registry_tests.js +64 -0
  177. package/build/esm/tests/renderer_tests.js +113 -0
  178. package/build/esm/tests/rests_tests.js +248 -0
  179. package/build/esm/tests/rhythm_tests.js +357 -0
  180. package/build/esm/tests/stave_tests.js +560 -0
  181. package/build/esm/tests/staveconnector_tests.js +402 -0
  182. package/build/esm/tests/stavehairpin_tests.js +90 -0
  183. package/build/esm/tests/staveline_tests.js +122 -0
  184. package/build/esm/tests/stavemodifier_tests.js +51 -0
  185. package/build/esm/tests/stavenote_tests.js +867 -0
  186. package/build/esm/tests/stavetie_tests.js +108 -0
  187. package/build/esm/tests/stringnumber_tests.js +259 -0
  188. package/build/esm/tests/strokes_tests.js +275 -0
  189. package/build/esm/tests/style_tests.js +98 -0
  190. package/build/esm/tests/support/qunit.js +2765 -0
  191. package/build/esm/tests/tabnote_tests.js +474 -0
  192. package/build/esm/tests/tabslide_tests.js +135 -0
  193. package/build/esm/tests/tabstave_tests.js +23 -0
  194. package/build/esm/tests/tabtie_tests.js +173 -0
  195. package/build/esm/tests/textbracket_tests.js +100 -0
  196. package/build/esm/tests/textformatter_tests.js +24 -0
  197. package/build/esm/tests/textnote_tests.js +215 -0
  198. package/build/esm/tests/threevoice_tests.js +132 -0
  199. package/build/esm/tests/tickcontext_tests.js +36 -0
  200. package/build/esm/tests/timesignature_tests.js +134 -0
  201. package/build/esm/tests/tremolo_tests.js +75 -0
  202. package/build/esm/tests/tuning_tests.js +56 -0
  203. package/build/esm/tests/tuplet_tests.js +450 -0
  204. package/build/esm/tests/typeguard_tests.js +82 -0
  205. package/build/esm/tests/vexflow_test_helpers.js +266 -0
  206. package/build/esm/tests/vf_prefix_tests.js +115 -0
  207. package/build/esm/tests/vibrato_tests.js +92 -0
  208. package/build/esm/tests/vibratobracket_tests.js +45 -0
  209. package/build/esm/tests/voice_tests.js +69 -0
  210. package/build/types/entry/vexflow-bravura.d.ts +3 -0
  211. package/build/types/entry/vexflow-core.d.ts +3 -0
  212. package/build/types/entry/vexflow-debug.d.ts +3 -0
  213. package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
  214. package/build/types/entry/vexflow-font-custom.d.ts +86 -0
  215. package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
  216. package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
  217. package/build/types/entry/vexflow-gonville.d.ts +3 -0
  218. package/build/types/entry/vexflow-petaluma.d.ts +3 -0
  219. package/build/types/entry/vexflow.d.ts +3 -0
  220. package/build/types/src/accidental.d.ts +66 -0
  221. package/build/types/src/annotation.d.ts +60 -0
  222. package/build/types/src/articulation.d.ts +62 -0
  223. package/build/types/src/barnote.d.ts +29 -0
  224. package/build/types/src/beam.d.ts +124 -0
  225. package/build/types/src/bend.d.ts +73 -0
  226. package/build/types/src/boundingbox.d.ts +42 -0
  227. package/build/types/src/boundingboxcomputation.d.ts +33 -0
  228. package/build/types/src/canvascontext.d.ts +89 -0
  229. package/build/types/src/chordsymbol.d.ts +149 -0
  230. package/build/types/src/clef.d.ts +48 -0
  231. package/build/types/src/clefnote.d.ts +25 -0
  232. package/build/types/src/crescendo.d.ts +27 -0
  233. package/build/types/src/curve.d.ts +41 -0
  234. package/build/types/src/dot.d.ts +20 -0
  235. package/build/types/src/easyscore.d.ts +148 -0
  236. package/build/types/src/element.d.ts +202 -0
  237. package/build/types/src/factory.d.ts +271 -0
  238. package/build/types/src/flow.d.ts +245 -0
  239. package/build/types/src/font.d.ts +181 -0
  240. package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
  241. package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
  242. package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
  243. package/build/types/src/fonts/custom_metrics.d.ts +5 -0
  244. package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
  245. package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
  246. package/build/types/src/fonts/load_all.d.ts +1 -0
  247. package/build/types/src/fonts/load_bravura.d.ts +1 -0
  248. package/build/types/src/fonts/load_custom.d.ts +1 -0
  249. package/build/types/src/fonts/load_gonville.d.ts +1 -0
  250. package/build/types/src/fonts/load_petaluma.d.ts +1 -0
  251. package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
  252. package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
  253. package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
  254. package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
  255. package/build/types/src/fonts/textfonts.d.ts +1 -0
  256. package/build/types/src/formatter.d.ts +203 -0
  257. package/build/types/src/fraction.d.ts +62 -0
  258. package/build/types/src/frethandfinger.d.ts +22 -0
  259. package/build/types/src/ghostnote.d.ts +16 -0
  260. package/build/types/src/glyph.d.ts +139 -0
  261. package/build/types/src/glyphnote.d.ts +17 -0
  262. package/build/types/src/gracenote.d.ts +19 -0
  263. package/build/types/src/gracenotegroup.d.ts +33 -0
  264. package/build/types/src/gracetabnote.d.ts +5 -0
  265. package/build/types/src/index.d.ts +91 -0
  266. package/build/types/src/keymanager.d.ts +25 -0
  267. package/build/types/src/keysignature.d.ts +50 -0
  268. package/build/types/src/keysignote.d.ts +11 -0
  269. package/build/types/src/modifier.d.ts +97 -0
  270. package/build/types/src/modifiercontext.d.ts +45 -0
  271. package/build/types/src/multimeasurerest.d.ts +61 -0
  272. package/build/types/src/music.d.ts +91 -0
  273. package/build/types/src/note.d.ts +231 -0
  274. package/build/types/src/notehead.d.ts +70 -0
  275. package/build/types/src/notesubgroup.d.ts +18 -0
  276. package/build/types/src/ornament.d.ts +76 -0
  277. package/build/types/src/parenthesis.d.ts +22 -0
  278. package/build/types/src/parser.d.ts +45 -0
  279. package/build/types/src/pedalmarking.d.ts +69 -0
  280. package/build/types/src/registry.d.ts +40 -0
  281. package/build/types/src/rendercontext.d.ts +64 -0
  282. package/build/types/src/renderer.d.ts +35 -0
  283. package/build/types/src/repeatnote.d.ts +6 -0
  284. package/build/types/src/stave.d.ts +186 -0
  285. package/build/types/src/stavebarline.d.ts +28 -0
  286. package/build/types/src/staveconnector.d.ts +67 -0
  287. package/build/types/src/stavehairpin.d.ts +56 -0
  288. package/build/types/src/staveline.d.ts +57 -0
  289. package/build/types/src/stavemodifier.d.ts +44 -0
  290. package/build/types/src/stavenote.d.ts +154 -0
  291. package/build/types/src/staverepetition.d.ts +32 -0
  292. package/build/types/src/stavesection.d.ts +15 -0
  293. package/build/types/src/stavetempo.d.ts +25 -0
  294. package/build/types/src/stavetext.d.ts +25 -0
  295. package/build/types/src/stavetie.d.ts +59 -0
  296. package/build/types/src/stavevolta.d.ts +21 -0
  297. package/build/types/src/stem.d.ts +58 -0
  298. package/build/types/src/stemmablenote.d.ts +39 -0
  299. package/build/types/src/stringnumber.d.ts +27 -0
  300. package/build/types/src/strokes.d.ts +33 -0
  301. package/build/types/src/svgcontext.d.ts +131 -0
  302. package/build/types/src/system.d.ts +92 -0
  303. package/build/types/src/tables.d.ts +96 -0
  304. package/build/types/src/tabnote.d.ts +44 -0
  305. package/build/types/src/tabslide.d.ts +34 -0
  306. package/build/types/src/tabstave.d.ts +7 -0
  307. package/build/types/src/tabtie.d.ts +18 -0
  308. package/build/types/src/textbracket.d.ts +55 -0
  309. package/build/types/src/textdynamics.d.ts +39 -0
  310. package/build/types/src/textformatter.d.ts +109 -0
  311. package/build/types/src/textnote.d.ts +49 -0
  312. package/build/types/src/tickable.d.ts +140 -0
  313. package/build/types/src/tickcontext.d.ts +82 -0
  314. package/build/types/src/timesigglyph.d.ts +14 -0
  315. package/build/types/src/timesignature.d.ts +26 -0
  316. package/build/types/src/timesignote.d.ts +11 -0
  317. package/build/types/src/tremolo.d.ts +17 -0
  318. package/build/types/src/tuning.d.ts +23 -0
  319. package/build/types/src/tuplet.d.ts +105 -0
  320. package/build/types/src/typeguard.d.ts +99 -0
  321. package/build/types/src/util.d.ts +27 -0
  322. package/build/types/src/version.d.ts +3 -0
  323. package/build/types/src/vex.d.ts +18 -0
  324. package/build/types/src/vibrato.d.ts +29 -0
  325. package/build/types/src/vibratobracket.d.ts +33 -0
  326. package/build/types/src/voice.d.ts +108 -0
  327. package/build/types/src/web.d.ts +2 -0
  328. package/package.json +1 -1
  329. package/src/annotation.ts +27 -6
  330. package/src/articulation.ts +8 -2
  331. package/src/fonts/gonville_glyphs.ts +4 -4
@@ -0,0 +1,578 @@
1
+ import { Font, FontStyle, FontWeight } from './font.js';
2
+ import { Glyph } from './glyph.js';
3
+ import { Modifier } from './modifier.js';
4
+ import { Tables } from './tables.js';
5
+ import { TextFormatter } from './textformatter.js';
6
+ import { log } from './util.js';
7
+ function L(...args) {
8
+ if (ChordSymbol.DEBUG)
9
+ log('Vex.Flow.ChordSymbol', args);
10
+ }
11
+ export var ChordSymbolHorizontalJustify;
12
+ (function (ChordSymbolHorizontalJustify) {
13
+ ChordSymbolHorizontalJustify[ChordSymbolHorizontalJustify["LEFT"] = 1] = "LEFT";
14
+ ChordSymbolHorizontalJustify[ChordSymbolHorizontalJustify["CENTER"] = 2] = "CENTER";
15
+ ChordSymbolHorizontalJustify[ChordSymbolHorizontalJustify["RIGHT"] = 3] = "RIGHT";
16
+ ChordSymbolHorizontalJustify[ChordSymbolHorizontalJustify["CENTER_STEM"] = 4] = "CENTER_STEM";
17
+ })(ChordSymbolHorizontalJustify || (ChordSymbolHorizontalJustify = {}));
18
+ export var ChordSymbolVerticalJustify;
19
+ (function (ChordSymbolVerticalJustify) {
20
+ ChordSymbolVerticalJustify[ChordSymbolVerticalJustify["TOP"] = 1] = "TOP";
21
+ ChordSymbolVerticalJustify[ChordSymbolVerticalJustify["BOTTOM"] = 2] = "BOTTOM";
22
+ })(ChordSymbolVerticalJustify || (ChordSymbolVerticalJustify = {}));
23
+ export var SymbolTypes;
24
+ (function (SymbolTypes) {
25
+ SymbolTypes[SymbolTypes["GLYPH"] = 1] = "GLYPH";
26
+ SymbolTypes[SymbolTypes["TEXT"] = 2] = "TEXT";
27
+ SymbolTypes[SymbolTypes["LINE"] = 3] = "LINE";
28
+ })(SymbolTypes || (SymbolTypes = {}));
29
+ export var SymbolModifiers;
30
+ (function (SymbolModifiers) {
31
+ SymbolModifiers[SymbolModifiers["NONE"] = 1] = "NONE";
32
+ SymbolModifiers[SymbolModifiers["SUBSCRIPT"] = 2] = "SUBSCRIPT";
33
+ SymbolModifiers[SymbolModifiers["SUPERSCRIPT"] = 3] = "SUPERSCRIPT";
34
+ })(SymbolModifiers || (SymbolModifiers = {}));
35
+ export class ChordSymbol extends Modifier {
36
+ constructor() {
37
+ super();
38
+ this.symbolBlocks = [];
39
+ this.horizontal = ChordSymbolHorizontalJustify.LEFT;
40
+ this.vertical = ChordSymbolVerticalJustify.TOP;
41
+ this.useKerning = true;
42
+ this.reportWidth = true;
43
+ this.resetFont();
44
+ }
45
+ static get CATEGORY() {
46
+ return "ChordSymbol";
47
+ }
48
+ static get superSubRatio() {
49
+ return ChordSymbol.metrics.global.superSubRatio;
50
+ }
51
+ static set NO_TEXT_FORMAT(val) {
52
+ ChordSymbol.noFormat = val;
53
+ }
54
+ static get NO_TEXT_FORMAT() {
55
+ return ChordSymbol.noFormat;
56
+ }
57
+ static getMetricForGlyph(glyphCode) {
58
+ if (ChordSymbol.metrics[glyphCode]) {
59
+ return ChordSymbol.metrics[glyphCode];
60
+ }
61
+ return undefined;
62
+ }
63
+ static get engravingFontResolution() {
64
+ return Tables.currentMusicFont().getResolution();
65
+ }
66
+ static get spacingBetweenBlocks() {
67
+ return ChordSymbol.metrics.global.spacing / ChordSymbol.engravingFontResolution;
68
+ }
69
+ static getWidthForGlyph(glyph) {
70
+ const metric = ChordSymbol.getMetricForGlyph(glyph.code);
71
+ if (!metric) {
72
+ return 0.65;
73
+ }
74
+ return metric.advanceWidth / ChordSymbol.engravingFontResolution;
75
+ }
76
+ static getYShiftForGlyph(glyph) {
77
+ const metric = ChordSymbol.getMetricForGlyph(glyph.code);
78
+ if (!metric) {
79
+ return 0;
80
+ }
81
+ return metric.yOffset / ChordSymbol.engravingFontResolution;
82
+ }
83
+ static getXShiftForGlyph(glyph) {
84
+ const metric = ChordSymbol.getMetricForGlyph(glyph.code);
85
+ if (!metric) {
86
+ return 0;
87
+ }
88
+ return (-1 * metric.leftSideBearing) / ChordSymbol.engravingFontResolution;
89
+ }
90
+ static get superscriptOffset() {
91
+ return ChordSymbol.metrics.global.superscriptOffset / ChordSymbol.engravingFontResolution;
92
+ }
93
+ static get subscriptOffset() {
94
+ return ChordSymbol.metrics.global.subscriptOffset / ChordSymbol.engravingFontResolution;
95
+ }
96
+ static get kerningOffset() {
97
+ return ChordSymbol.metrics.global.kerningOffset / ChordSymbol.engravingFontResolution;
98
+ }
99
+ static get metrics() {
100
+ return Tables.currentMusicFont().getMetrics().glyphs.chordSymbol;
101
+ }
102
+ static get lowerKerningText() {
103
+ return ChordSymbol.metrics.global.lowerKerningText;
104
+ }
105
+ static get upperKerningText() {
106
+ return ChordSymbol.metrics.global.upperKerningText;
107
+ }
108
+ static isSuperscript(block) {
109
+ return block.symbolModifier !== undefined && block.symbolModifier === SymbolModifiers.SUPERSCRIPT;
110
+ }
111
+ static isSubscript(block) {
112
+ return block.symbolModifier !== undefined && block.symbolModifier === SymbolModifiers.SUBSCRIPT;
113
+ }
114
+ static format(symbols, state) {
115
+ var _a;
116
+ if (!symbols || symbols.length === 0)
117
+ return false;
118
+ let width = 0;
119
+ let nonSuperWidth = 0;
120
+ const reportedWidths = [];
121
+ for (const symbol of symbols) {
122
+ const fontSize = Font.convertSizeToPointValue((_a = symbol.textFont) === null || _a === void 0 ? void 0 : _a.size);
123
+ const fontAdj = Font.scaleSize(fontSize, 0.05);
124
+ const glyphAdj = fontAdj * 2;
125
+ let lineSpaces = 1;
126
+ let vAlign = false;
127
+ for (let j = 0; j < symbol.symbolBlocks.length; ++j) {
128
+ const block = symbol.symbolBlocks[j];
129
+ const sup = ChordSymbol.isSuperscript(block);
130
+ const sub = ChordSymbol.isSubscript(block);
131
+ const superSubScale = sup || sub ? ChordSymbol.superSubRatio : 1;
132
+ const adj = block.symbolType === SymbolTypes.GLYPH ? glyphAdj * superSubScale : fontAdj * superSubScale;
133
+ if (sup || sub) {
134
+ lineSpaces = 2;
135
+ }
136
+ const fontSize = symbol.textFormatter.fontSizeInPixels;
137
+ const superSubFontSize = fontSize * superSubScale;
138
+ if (block.symbolType === SymbolTypes.GLYPH && block.glyph !== undefined) {
139
+ block.width = ChordSymbol.getWidthForGlyph(block.glyph) * superSubFontSize;
140
+ block.yShift += ChordSymbol.getYShiftForGlyph(block.glyph) * superSubFontSize;
141
+ block.xShift += ChordSymbol.getXShiftForGlyph(block.glyph) * superSubFontSize;
142
+ block.glyph.scale = block.glyph.scale * adj;
143
+ }
144
+ else if (block.symbolType === SymbolTypes.TEXT) {
145
+ block.width = block.width * superSubFontSize;
146
+ block.yShift += symbol.getYOffsetForText(block.text) * adj;
147
+ }
148
+ if (block.symbolType === SymbolTypes.GLYPH &&
149
+ block.glyph !== undefined &&
150
+ block.glyph.code === ChordSymbol.glyphs.over.code) {
151
+ lineSpaces = 2;
152
+ }
153
+ block.width += ChordSymbol.spacingBetweenBlocks * fontSize * superSubScale;
154
+ if (sup && j > 0) {
155
+ const prev = symbol.symbolBlocks[j - 1];
156
+ if (!ChordSymbol.isSuperscript(prev)) {
157
+ nonSuperWidth = width;
158
+ }
159
+ }
160
+ if (sub && nonSuperWidth > 0) {
161
+ vAlign = true;
162
+ block.xShift = block.xShift + (nonSuperWidth - width);
163
+ width = nonSuperWidth;
164
+ nonSuperWidth = 0;
165
+ symbol.setEnableKerning(false);
166
+ }
167
+ if (!sup && !sub) {
168
+ nonSuperWidth = 0;
169
+ }
170
+ block.vAlign = vAlign;
171
+ width += block.width;
172
+ }
173
+ symbol.updateKerningAdjustments();
174
+ symbol.updateOverBarAdjustments();
175
+ if (symbol.getVertical() === ChordSymbolVerticalJustify.TOP) {
176
+ symbol.setTextLine(state.top_text_line);
177
+ state.top_text_line += lineSpaces;
178
+ }
179
+ else {
180
+ symbol.setTextLine(state.text_line + 1);
181
+ state.text_line += lineSpaces + 1;
182
+ }
183
+ if (symbol.getReportWidth()) {
184
+ reportedWidths.push(width);
185
+ }
186
+ else {
187
+ reportedWidths.push(0);
188
+ }
189
+ }
190
+ width = reportedWidths.reduce((a, b) => a + b, 0);
191
+ state.left_shift += width / 2;
192
+ state.right_shift += width / 2;
193
+ return true;
194
+ }
195
+ static get TEXT_FONT() {
196
+ let family = 'Roboto Slab, Times, serif';
197
+ if (Tables.currentMusicFont().getName() === 'Petaluma') {
198
+ family = 'PetalumaScript, Arial, sans-serif';
199
+ }
200
+ return {
201
+ family,
202
+ size: 12,
203
+ weight: FontWeight.NORMAL,
204
+ style: FontStyle.NORMAL,
205
+ };
206
+ }
207
+ get superscriptOffset() {
208
+ return ChordSymbol.superscriptOffset * this.textFormatter.fontSizeInPixels;
209
+ }
210
+ get subscriptOffset() {
211
+ return ChordSymbol.subscriptOffset * this.textFormatter.fontSizeInPixels;
212
+ }
213
+ setReportWidth(value) {
214
+ this.reportWidth = value;
215
+ return this;
216
+ }
217
+ getReportWidth() {
218
+ return this.reportWidth;
219
+ }
220
+ updateOverBarAdjustments() {
221
+ const barIndex = this.symbolBlocks.findIndex(({ symbolType, glyph }) => symbolType === SymbolTypes.GLYPH && glyph !== undefined && glyph.code === 'csymDiagonalArrangementSlash');
222
+ if (barIndex < 0) {
223
+ return;
224
+ }
225
+ const bar = this.symbolBlocks[barIndex];
226
+ const xoff = bar.width / 4;
227
+ const yoff = 0.25 * this.textFormatter.fontSizeInPixels;
228
+ let symIndex = 0;
229
+ for (symIndex === 0; symIndex < barIndex; ++symIndex) {
230
+ const symbol = this.symbolBlocks[symIndex];
231
+ symbol.xShift = symbol.xShift + xoff;
232
+ symbol.yShift = symbol.yShift - yoff;
233
+ }
234
+ for (symIndex = barIndex + 1; symIndex < this.symbolBlocks.length; ++symIndex) {
235
+ const symbol = this.symbolBlocks[symIndex];
236
+ symbol.xShift = symbol.xShift - xoff;
237
+ symbol.yShift = symbol.yShift + yoff;
238
+ }
239
+ }
240
+ updateKerningAdjustments() {
241
+ let accum = 0;
242
+ for (let j = 0; j < this.symbolBlocks.length; ++j) {
243
+ const symbol = this.symbolBlocks[j];
244
+ accum += this.getKerningAdjustment(j);
245
+ symbol.xShift += accum;
246
+ }
247
+ }
248
+ getKerningAdjustment(j) {
249
+ if (!this.useKerning) {
250
+ return 0;
251
+ }
252
+ const currSymbol = this.symbolBlocks[j];
253
+ const prevSymbol = j > 0 ? this.symbolBlocks[j - 1] : undefined;
254
+ let adjustment = 0;
255
+ if (currSymbol.symbolType === SymbolTypes.GLYPH &&
256
+ currSymbol.glyph !== undefined &&
257
+ currSymbol.glyph.code === ChordSymbol.glyphs.over.code) {
258
+ adjustment += currSymbol.glyph.metrics.x_shift;
259
+ }
260
+ if (prevSymbol !== undefined &&
261
+ prevSymbol.symbolType === SymbolTypes.GLYPH &&
262
+ prevSymbol.glyph !== undefined &&
263
+ prevSymbol.glyph.code === ChordSymbol.glyphs.over.code) {
264
+ adjustment += prevSymbol.glyph.metrics.x_shift;
265
+ }
266
+ let preKernUpper = false;
267
+ let preKernLower = false;
268
+ if (prevSymbol !== undefined && prevSymbol.symbolType === SymbolTypes.TEXT) {
269
+ preKernUpper = ChordSymbol.upperKerningText.some((xx) => xx === prevSymbol.text[prevSymbol.text.length - 1]);
270
+ preKernLower = ChordSymbol.lowerKerningText.some((xx) => xx === prevSymbol.text[prevSymbol.text.length - 1]);
271
+ }
272
+ const kerningOffsetPixels = ChordSymbol.kerningOffset * this.textFormatter.fontSizeInPixels;
273
+ if (preKernUpper && currSymbol.symbolModifier === SymbolModifiers.SUPERSCRIPT) {
274
+ adjustment += kerningOffsetPixels;
275
+ }
276
+ if (preKernLower && currSymbol.symbolType === SymbolTypes.TEXT) {
277
+ if (currSymbol.text[0] >= 'a' && currSymbol.text[0] <= 'z') {
278
+ adjustment += kerningOffsetPixels / 2;
279
+ }
280
+ if (ChordSymbol.upperKerningText.some((xx) => xx === (prevSymbol === null || prevSymbol === void 0 ? void 0 : prevSymbol.text[prevSymbol.text.length - 1]))) {
281
+ adjustment += kerningOffsetPixels / 2;
282
+ }
283
+ }
284
+ return adjustment;
285
+ }
286
+ getSymbolBlock(params = {}) {
287
+ var _a, _b, _c;
288
+ const symbolType = (_a = params.symbolType) !== null && _a !== void 0 ? _a : SymbolTypes.TEXT;
289
+ const symbolBlock = {
290
+ text: (_b = params.text) !== null && _b !== void 0 ? _b : '',
291
+ symbolType,
292
+ symbolModifier: (_c = params.symbolModifier) !== null && _c !== void 0 ? _c : SymbolModifiers.NONE,
293
+ xShift: 0,
294
+ yShift: 0,
295
+ vAlign: false,
296
+ width: 0,
297
+ };
298
+ if (symbolType === SymbolTypes.GLYPH && typeof params.glyph === 'string') {
299
+ const glyphArgs = ChordSymbol.glyphs[params.glyph];
300
+ const glyphPoints = 20;
301
+ symbolBlock.glyph = new Glyph(glyphArgs.code, glyphPoints, { category: 'chordSymbol' });
302
+ }
303
+ else if (symbolType === SymbolTypes.TEXT) {
304
+ symbolBlock.width = this.textFormatter.getWidthForTextInEm(symbolBlock.text);
305
+ }
306
+ else if (symbolType === SymbolTypes.LINE) {
307
+ symbolBlock.width = params.width;
308
+ }
309
+ return symbolBlock;
310
+ }
311
+ addSymbolBlock(parameters) {
312
+ this.symbolBlocks.push(this.getSymbolBlock(parameters));
313
+ return this;
314
+ }
315
+ addText(text, parameters = {}) {
316
+ const symbolType = SymbolTypes.TEXT;
317
+ return this.addSymbolBlock(Object.assign(Object.assign({}, parameters), { text, symbolType }));
318
+ }
319
+ addTextSuperscript(text) {
320
+ const symbolType = SymbolTypes.TEXT;
321
+ const symbolModifier = SymbolModifiers.SUPERSCRIPT;
322
+ return this.addSymbolBlock({ text, symbolType, symbolModifier });
323
+ }
324
+ addTextSubscript(text) {
325
+ const symbolType = SymbolTypes.TEXT;
326
+ const symbolModifier = SymbolModifiers.SUBSCRIPT;
327
+ return this.addSymbolBlock({ text, symbolType, symbolModifier });
328
+ }
329
+ addGlyphSuperscript(glyph) {
330
+ const symbolType = SymbolTypes.GLYPH;
331
+ const symbolModifier = SymbolModifiers.SUPERSCRIPT;
332
+ return this.addSymbolBlock({ glyph, symbolType, symbolModifier });
333
+ }
334
+ addGlyph(glyph, params = {}) {
335
+ const symbolType = SymbolTypes.GLYPH;
336
+ return this.addSymbolBlock(Object.assign(Object.assign({}, params), { glyph, symbolType }));
337
+ }
338
+ addGlyphOrText(text, params = {}) {
339
+ let str = '';
340
+ for (let i = 0; i < text.length; ++i) {
341
+ const char = text[i];
342
+ if (ChordSymbol.glyphs[char]) {
343
+ if (str.length > 0) {
344
+ this.addText(str, params);
345
+ str = '';
346
+ }
347
+ this.addGlyph(char, params);
348
+ }
349
+ else {
350
+ str += char;
351
+ }
352
+ }
353
+ if (str.length > 0) {
354
+ this.addText(str, params);
355
+ }
356
+ return this;
357
+ }
358
+ addLine(width, params = {}) {
359
+ const symbolType = SymbolTypes.LINE;
360
+ return this.addSymbolBlock(Object.assign(Object.assign({}, params), { symbolType, width }));
361
+ }
362
+ setFont(f, size, weight, style) {
363
+ super.setFont(f, size, weight, style);
364
+ this.textFormatter = TextFormatter.create(this.textFont);
365
+ return this;
366
+ }
367
+ setEnableKerning(val) {
368
+ this.useKerning = val;
369
+ return this;
370
+ }
371
+ setVertical(vj) {
372
+ this.vertical = typeof vj === 'string' ? ChordSymbol.VerticalJustifyString[vj] : vj;
373
+ return this;
374
+ }
375
+ getVertical() {
376
+ return this.vertical;
377
+ }
378
+ setHorizontal(hj) {
379
+ this.horizontal = typeof hj === 'string' ? ChordSymbol.HorizontalJustifyString[hj] : hj;
380
+ return this;
381
+ }
382
+ getHorizontal() {
383
+ return this.horizontal;
384
+ }
385
+ getWidth() {
386
+ let width = 0;
387
+ this.symbolBlocks.forEach((symbol) => {
388
+ width += symbol.vAlign ? 0 : symbol.width;
389
+ });
390
+ return width;
391
+ }
392
+ getYOffsetForText(text) {
393
+ var _a;
394
+ let acc = 0;
395
+ let i = 0;
396
+ for (i = 0; i < text.length; ++i) {
397
+ const metrics = this.textFormatter.getGlyphMetrics(text[i]);
398
+ if (metrics) {
399
+ const yMax = (_a = metrics.y_max) !== null && _a !== void 0 ? _a : 0;
400
+ acc = yMax < acc ? yMax : acc;
401
+ }
402
+ }
403
+ const resolution = this.textFormatter.getResolution();
404
+ return i > 0 ? -1 * (acc / resolution) : 0;
405
+ }
406
+ draw() {
407
+ const ctx = this.checkContext();
408
+ const note = this.checkAttachedNote();
409
+ this.setRendered();
410
+ ctx.save();
411
+ const classString = Object.keys(this.getAttribute('classes')).join(' ');
412
+ ctx.openGroup(classString, this.getAttribute('id'));
413
+ const start = note.getModifierStartXY(Modifier.Position.ABOVE, this.index);
414
+ ctx.setFont(this.textFont);
415
+ let y;
416
+ const hasStem = note.hasStem();
417
+ const stave = note.checkStave();
418
+ if (this.vertical === ChordSymbolVerticalJustify.BOTTOM) {
419
+ y = stave.getYForBottomText(this.text_line + Tables.TEXT_HEIGHT_OFFSET_HACK);
420
+ if (hasStem) {
421
+ const stem_ext = note.checkStem().getExtents();
422
+ const spacing = stave.getSpacingBetweenLines();
423
+ const stem_base = note.getStemDirection() === 1 ? stem_ext.baseY : stem_ext.topY;
424
+ y = Math.max(y, stem_base + spacing * (this.text_line + 2));
425
+ }
426
+ }
427
+ else {
428
+ y = Math.min(stave.getYForTopText(this.text_line), note.getYs()[0] - 10);
429
+ if (hasStem) {
430
+ const stem_ext = note.checkStem().getExtents();
431
+ const spacing = stave.getSpacingBetweenLines();
432
+ y = Math.min(y, stem_ext.topY - 5 - spacing * this.text_line);
433
+ }
434
+ }
435
+ let x = start.x;
436
+ if (this.horizontal === ChordSymbolHorizontalJustify.LEFT) {
437
+ x = start.x;
438
+ }
439
+ else if (this.horizontal === ChordSymbolHorizontalJustify.RIGHT) {
440
+ x = start.x + this.getWidth();
441
+ }
442
+ else if (this.horizontal === ChordSymbolHorizontalJustify.CENTER) {
443
+ x = start.x - this.getWidth() / 2;
444
+ }
445
+ else {
446
+ x = note.getStemX() - this.getWidth() / 2;
447
+ }
448
+ L('Rendering ChordSymbol: ', this.textFormatter, x, y);
449
+ this.symbolBlocks.forEach((symbol) => {
450
+ const isSuper = ChordSymbol.isSuperscript(symbol);
451
+ const isSub = ChordSymbol.isSubscript(symbol);
452
+ let curY = y;
453
+ L('shift was ', symbol.xShift, symbol.yShift);
454
+ L('curY pre sub ', curY);
455
+ if (isSuper) {
456
+ curY += this.superscriptOffset;
457
+ }
458
+ if (isSub) {
459
+ curY += this.subscriptOffset;
460
+ }
461
+ L('curY sup/sub ', curY);
462
+ if (symbol.symbolType === SymbolTypes.TEXT) {
463
+ if (isSuper || isSub) {
464
+ ctx.save();
465
+ if (this.textFont) {
466
+ const { family, size, weight, style } = this.textFont;
467
+ const smallerFontSize = Font.scaleSize(size, ChordSymbol.superSubRatio);
468
+ ctx.setFont(family, smallerFontSize, weight, style);
469
+ }
470
+ }
471
+ L('Rendering Text: ', symbol.text, x + symbol.xShift, curY + symbol.yShift);
472
+ ctx.fillText(symbol.text, x + symbol.xShift, curY + symbol.yShift);
473
+ if (isSuper || isSub) {
474
+ ctx.restore();
475
+ }
476
+ }
477
+ else if (symbol.symbolType === SymbolTypes.GLYPH && symbol.glyph) {
478
+ curY += symbol.yShift;
479
+ L('Rendering Glyph: ', symbol.glyph.code, x + symbol.xShift, curY);
480
+ symbol.glyph.render(ctx, x + symbol.xShift, curY);
481
+ }
482
+ else if (symbol.symbolType === SymbolTypes.LINE) {
483
+ L('Rendering Line : ', symbol.width, x, curY);
484
+ ctx.beginPath();
485
+ ctx.setLineWidth(1);
486
+ ctx.moveTo(x, y);
487
+ ctx.lineTo(x + symbol.width, curY);
488
+ ctx.stroke();
489
+ }
490
+ x += symbol.width;
491
+ if (symbol.vAlign) {
492
+ x += symbol.xShift;
493
+ }
494
+ });
495
+ ctx.closeGroup();
496
+ ctx.restore();
497
+ }
498
+ }
499
+ ChordSymbol.DEBUG = false;
500
+ ChordSymbol.HorizontalJustify = ChordSymbolHorizontalJustify;
501
+ ChordSymbol.HorizontalJustifyString = {
502
+ left: ChordSymbolHorizontalJustify.LEFT,
503
+ right: ChordSymbolHorizontalJustify.RIGHT,
504
+ center: ChordSymbolHorizontalJustify.CENTER,
505
+ centerStem: ChordSymbolHorizontalJustify.CENTER_STEM,
506
+ };
507
+ ChordSymbol.VerticalJustify = ChordSymbolVerticalJustify;
508
+ ChordSymbol.VerticalJustifyString = {
509
+ top: ChordSymbolVerticalJustify.TOP,
510
+ above: ChordSymbolVerticalJustify.TOP,
511
+ below: ChordSymbolVerticalJustify.BOTTOM,
512
+ bottom: ChordSymbolVerticalJustify.BOTTOM,
513
+ };
514
+ ChordSymbol.glyphs = {
515
+ diminished: {
516
+ code: 'csymDiminished',
517
+ },
518
+ dim: {
519
+ code: 'csymDiminished',
520
+ },
521
+ halfDiminished: {
522
+ code: 'csymHalfDiminished',
523
+ },
524
+ '+': {
525
+ code: 'csymAugmented',
526
+ },
527
+ augmented: {
528
+ code: 'csymAugmented',
529
+ },
530
+ majorSeventh: {
531
+ code: 'csymMajorSeventh',
532
+ },
533
+ minor: {
534
+ code: 'csymMinor',
535
+ },
536
+ '-': {
537
+ code: 'csymMinor',
538
+ },
539
+ '(': {
540
+ code: 'csymParensLeftTall',
541
+ },
542
+ leftParen: {
543
+ code: 'csymParensLeftTall',
544
+ },
545
+ ')': {
546
+ code: 'csymParensRightTall',
547
+ },
548
+ rightParen: {
549
+ code: 'csymParensRightTall',
550
+ },
551
+ leftBracket: {
552
+ code: 'csymBracketLeftTall',
553
+ },
554
+ rightBracket: {
555
+ code: 'csymBracketRightTall',
556
+ },
557
+ leftParenTall: {
558
+ code: 'csymParensLeftVeryTall',
559
+ },
560
+ rightParenTall: {
561
+ code: 'csymParensRightVeryTall',
562
+ },
563
+ '/': {
564
+ code: 'csymDiagonalArrangementSlash',
565
+ },
566
+ over: {
567
+ code: 'csymDiagonalArrangementSlash',
568
+ },
569
+ '#': {
570
+ code: 'accidentalSharp',
571
+ },
572
+ b: {
573
+ code: 'accidentalFlat',
574
+ },
575
+ };
576
+ ChordSymbol.symbolTypes = SymbolTypes;
577
+ ChordSymbol.symbolModifiers = SymbolModifiers;
578
+ ChordSymbol.noFormat = false;