vexflow 4.0.1-beta.1 → 4.0.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.
- package/README.md +48 -65
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +724 -697
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +550 -610
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/entry/vexflow-bravura.js +10 -0
- package/build/esm/entry/vexflow-core.js +53 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +11 -0
- package/build/esm/entry/vexflow-debug.js +8 -0
- package/build/esm/entry/vexflow-font-bravura.js +7 -0
- package/build/esm/entry/vexflow-font-custom.js +7 -0
- package/build/esm/entry/vexflow-font-gonville.js +7 -0
- package/build/esm/entry/vexflow-font-petaluma.js +7 -0
- package/build/esm/entry/vexflow-gonville.js +10 -0
- package/build/esm/entry/vexflow-petaluma.js +10 -0
- package/build/esm/entry/vexflow.js +8 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +238 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +644 -0
- package/build/esm/src/bend.js +202 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/boundingboxcomputation.js +107 -0
- package/build/esm/src/canvascontext.js +202 -0
- package/build/esm/src/chordsymbol.js +578 -0
- package/build/esm/src/clef.js +153 -0
- package/build/esm/src/clefnote.js +65 -0
- package/build/esm/src/crescendo.js +77 -0
- package/build/esm/src/curve.js +118 -0
- package/build/esm/src/dot.js +137 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +216 -0
- package/build/esm/src/factory.js +445 -0
- package/build/esm/src/flow.js +288 -0
- package/build/esm/src/font.js +262 -0
- package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
- package/build/esm/src/fonts/bravura_metrics.js +507 -0
- package/build/esm/src/fonts/custom_glyphs.js +78 -0
- package/build/esm/src/fonts/custom_metrics.js +5 -0
- package/build/esm/src/fonts/gonville_glyphs.js +828 -0
- package/build/esm/src/fonts/gonville_metrics.js +421 -0
- package/build/esm/src/fonts/load_all.js +10 -0
- package/build/esm/src/fonts/load_bravura.js +6 -0
- package/build/esm/src/fonts/load_custom.js +6 -0
- package/build/esm/src/fonts/load_gonville.js +6 -0
- package/build/esm/src/fonts/load_petaluma.js +6 -0
- package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
- package/build/esm/src/fonts/petaluma_metrics.js +536 -0
- package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
- package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
- package/build/esm/src/fonts/textfonts.js +44 -0
- package/build/esm/src/formatter.js +585 -0
- package/build/esm/src/fraction.js +171 -0
- package/build/esm/src/frethandfinger.js +156 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyph.js +337 -0
- package/build/esm/src/glyphnote.js +55 -0
- package/build/esm/src/gracenote.js +133 -0
- package/build/esm/src/gracenotegroup.js +128 -0
- package/build/esm/src/gracetabnote.js +12 -0
- package/build/esm/src/index.js +89 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +250 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/modifier.js +128 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +173 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +371 -0
- package/build/esm/src/notehead.js +169 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +206 -0
- package/build/esm/src/parenthesis.js +76 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +192 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +24 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +22 -0
- package/build/esm/src/stave.js +547 -0
- package/build/esm/src/stavebarline.js +182 -0
- package/build/esm/src/staveconnector.js +196 -0
- package/build/esm/src/stavehairpin.js +120 -0
- package/build/esm/src/staveline.js +215 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +860 -0
- package/build/esm/src/staverepetition.js +155 -0
- package/build/esm/src/stavesection.js +58 -0
- package/build/esm/src/stavetempo.js +91 -0
- package/build/esm/src/stavetext.js +82 -0
- package/build/esm/src/stavetie.js +141 -0
- package/build/esm/src/stavevolta.js +67 -0
- package/build/esm/src/stem.js +131 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +231 -0
- package/build/esm/src/strokes.js +200 -0
- package/build/esm/src/svgcontext.js +414 -0
- package/build/esm/src/system.js +109 -0
- package/build/esm/src/tables.js +1102 -0
- package/build/esm/src/tabnote.js +299 -0
- package/build/esm/src/tabslide.js +76 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +144 -0
- package/build/esm/src/textdynamics.js +81 -0
- package/build/esm/src/textformatter.js +177 -0
- package/build/esm/src/textnote.js +174 -0
- package/build/esm/src/tickable.js +214 -0
- package/build/esm/src/tickcontext.js +170 -0
- package/build/esm/src/timesigglyph.js +85 -0
- package/build/esm/src/timesignature.js +89 -0
- package/build/esm/src/timesignote.js +32 -0
- package/build/esm/src/tremolo.js +47 -0
- package/build/esm/src/tuning.js +54 -0
- package/build/esm/src/tuplet.js +240 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +58 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vex.js +51 -0
- package/build/esm/src/vibrato.js +100 -0
- package/build/esm/src/vibratobracket.js +50 -0
- package/build/esm/src/voice.js +187 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +974 -0
- package/build/esm/tests/annotation_tests.js +390 -0
- package/build/esm/tests/articulation_tests.js +365 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
- package/build/esm/tests/bach_tests.js +335 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +614 -0
- package/build/esm/tests/bend_tests.js +215 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
- package/build/esm/tests/chordsymbol_tests.js +320 -0
- package/build/esm/tests/clef_tests.js +131 -0
- package/build/esm/tests/curve_tests.js +118 -0
- package/build/esm/tests/dot_tests.js +123 -0
- package/build/esm/tests/easyscore_tests.js +462 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +135 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +203 -0
- package/build/esm/tests/formatter_tests.js +670 -0
- package/build/esm/tests/fraction_tests.js +72 -0
- package/build/esm/tests/ghostnote_tests.js +77 -0
- package/build/esm/tests/glyphnote_tests.js +113 -0
- package/build/esm/tests/gracenote_tests.js +413 -0
- package/build/esm/tests/gracetabnote_tests.js +79 -0
- package/build/esm/tests/index.js +68 -0
- package/build/esm/tests/key_clef_tests.js +103 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +308 -0
- package/build/esm/tests/mocks.js +71 -0
- package/build/esm/tests/modifier_tests.js +24 -0
- package/build/esm/tests/multimeasurerest_tests.js +141 -0
- package/build/esm/tests/music_tests.js +161 -0
- package/build/esm/tests/notehead_tests.js +137 -0
- package/build/esm/tests/notesubgroup_tests.js +149 -0
- package/build/esm/tests/offscreencanvas_tests.js +47 -0
- package/build/esm/tests/ornament_tests.js +298 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +64 -0
- package/build/esm/tests/percussion_tests.js +180 -0
- package/build/esm/tests/registry_tests.js +64 -0
- package/build/esm/tests/renderer_tests.js +113 -0
- package/build/esm/tests/rests_tests.js +248 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +560 -0
- package/build/esm/tests/staveconnector_tests.js +402 -0
- package/build/esm/tests/stavehairpin_tests.js +90 -0
- package/build/esm/tests/staveline_tests.js +122 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +867 -0
- package/build/esm/tests/stavetie_tests.js +108 -0
- package/build/esm/tests/stringnumber_tests.js +259 -0
- package/build/esm/tests/strokes_tests.js +275 -0
- package/build/esm/tests/style_tests.js +98 -0
- package/build/esm/tests/support/qunit.js +2765 -0
- package/build/esm/tests/tabnote_tests.js +474 -0
- package/build/esm/tests/tabslide_tests.js +135 -0
- package/build/esm/tests/tabstave_tests.js +23 -0
- package/build/esm/tests/tabtie_tests.js +173 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textformatter_tests.js +24 -0
- package/build/esm/tests/textnote_tests.js +215 -0
- package/build/esm/tests/threevoice_tests.js +132 -0
- package/build/esm/tests/tickcontext_tests.js +36 -0
- package/build/esm/tests/timesignature_tests.js +134 -0
- package/build/esm/tests/tremolo_tests.js +75 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +450 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/vexflow_test_helpers.js +266 -0
- package/build/esm/tests/vf_prefix_tests.js +115 -0
- package/build/esm/tests/vibrato_tests.js +92 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/voice_tests.js +69 -0
- package/build/types/entry/vexflow-bravura.d.ts +2 -0
- package/build/types/entry/vexflow-core.d.ts +2 -0
- package/build/types/entry/vexflow-debug.d.ts +2 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
- package/build/types/entry/vexflow-font-custom.d.ts +86 -0
- package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
- package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
- package/build/types/entry/vexflow-gonville.d.ts +2 -0
- package/build/types/entry/vexflow-petaluma.d.ts +2 -0
- package/build/types/entry/vexflow.d.ts +2 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +61 -0
- package/build/types/src/articulation.d.ts +62 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +153 -0
- package/build/types/src/bend.d.ts +73 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/boundingboxcomputation.d.ts +33 -0
- package/build/types/src/canvascontext.d.ts +89 -0
- package/build/types/src/chordsymbol.d.ts +149 -0
- package/build/types/src/clef.d.ts +48 -0
- package/build/types/src/clefnote.d.ts +25 -0
- package/build/types/src/crescendo.d.ts +27 -0
- package/build/types/src/curve.d.ts +41 -0
- package/build/types/src/dot.d.ts +20 -0
- package/build/types/src/easyscore.d.ts +152 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +274 -0
- package/build/types/src/flow.d.ts +260 -0
- package/build/types/src/font.d.ts +180 -0
- package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
- package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
- package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
- package/build/types/src/fonts/custom_metrics.d.ts +5 -0
- package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
- package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
- package/build/types/src/fonts/load_all.d.ts +1 -0
- package/build/types/src/fonts/load_bravura.d.ts +1 -0
- package/build/types/src/fonts/load_custom.d.ts +1 -0
- package/build/types/src/fonts/load_gonville.d.ts +1 -0
- package/build/types/src/fonts/load_petaluma.d.ts +1 -0
- package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
- package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
- package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
- package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
- package/build/types/src/fonts/textfonts.d.ts +1 -0
- package/build/types/src/formatter.d.ts +203 -0
- package/build/types/src/fraction.d.ts +62 -0
- package/build/types/src/frethandfinger.d.ts +22 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyph.d.ts +141 -0
- package/build/types/src/glyphnote.d.ts +17 -0
- package/build/types/src/gracenote.d.ts +19 -0
- package/build/types/src/gracenotegroup.d.ts +33 -0
- package/build/types/src/gracetabnote.d.ts +5 -0
- package/build/types/src/index.d.ts +89 -0
- package/build/types/src/keymanager.d.ts +25 -0
- package/build/types/src/keysignature.d.ts +50 -0
- package/build/types/src/keysignote.d.ts +11 -0
- package/build/types/src/modifier.d.ts +97 -0
- package/build/types/src/modifiercontext.d.ts +45 -0
- package/build/types/src/multimeasurerest.d.ts +61 -0
- package/build/types/src/music.d.ts +91 -0
- package/build/types/src/note.d.ts +232 -0
- package/build/types/src/notehead.d.ts +70 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +76 -0
- package/build/types/src/parenthesis.d.ts +22 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +69 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +64 -0
- package/build/types/src/renderer.d.ts +35 -0
- package/build/types/src/repeatnote.d.ts +6 -0
- package/build/types/src/stave.d.ts +186 -0
- package/build/types/src/stavebarline.d.ts +28 -0
- package/build/types/src/staveconnector.d.ts +67 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +54 -0
- package/build/types/src/stavemodifier.d.ts +44 -0
- package/build/types/src/stavenote.d.ts +154 -0
- package/build/types/src/staverepetition.d.ts +32 -0
- package/build/types/src/stavesection.d.ts +15 -0
- package/build/types/src/stavetempo.d.ts +25 -0
- package/build/types/src/stavetext.d.ts +25 -0
- package/build/types/src/stavetie.d.ts +59 -0
- package/build/types/src/stavevolta.d.ts +21 -0
- package/build/types/src/stem.d.ts +58 -0
- package/build/types/src/stemmablenote.d.ts +39 -0
- package/build/types/src/stringnumber.d.ts +27 -0
- package/build/types/src/strokes.d.ts +33 -0
- package/build/types/src/svgcontext.d.ts +131 -0
- package/build/types/src/system.d.ts +92 -0
- package/build/types/src/tables.d.ts +96 -0
- package/build/types/src/tabnote.d.ts +44 -0
- package/build/types/src/tabslide.d.ts +34 -0
- package/build/types/src/tabstave.d.ts +7 -0
- package/build/types/src/tabtie.d.ts +18 -0
- package/build/types/src/textbracket.d.ts +55 -0
- package/build/types/src/textdynamics.d.ts +39 -0
- package/build/types/src/textformatter.d.ts +109 -0
- package/build/types/src/textnote.d.ts +49 -0
- package/build/types/src/tickable.d.ts +140 -0
- package/build/types/src/tickcontext.d.ts +82 -0
- package/build/types/src/timesigglyph.d.ts +14 -0
- package/build/types/src/timesignature.d.ts +26 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +17 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +105 -0
- package/build/types/src/typeguard.d.ts +99 -0
- package/build/types/src/util.d.ts +27 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vex.d.ts +18 -0
- package/build/types/src/vibrato.d.ts +29 -0
- package/build/types/src/vibratobracket.d.ts +33 -0
- package/build/types/src/voice.d.ts +108 -0
- package/build/types/src/web.d.ts +2 -0
- package/entry/vexflow-bravura.ts +3 -3
- package/entry/vexflow-core.ts +3 -3
- package/entry/vexflow-debug-with-tests.ts +16 -2
- package/entry/vexflow-debug.ts +11 -3
- package/entry/vexflow-gonville.ts +3 -3
- package/entry/vexflow-petaluma.ts +3 -3
- package/entry/vexflow.ts +3 -3
- package/package.json +1 -1
- package/src/annotation.ts +38 -6
- package/src/articulation.ts +8 -2
- package/src/beam.ts +53 -6
- package/src/easyscore.ts +11 -1
- package/src/factory.ts +16 -2
- package/src/flow.ts +35 -20
- package/src/font.ts +0 -4
- package/src/fonts/gonville_glyphs.ts +4 -4
- package/src/formatter.ts +24 -8
- package/src/glyph.ts +8 -0
- package/src/index.ts +2 -7
- package/src/note.ts +2 -1
- package/src/staveline.ts +2 -5
- package/src/stavenote.ts +13 -9
- package/src/stavetext.ts +3 -3
- package/src/system.ts +1 -7
- package/src/textnote.ts +9 -11
|
@@ -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;
|