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,135 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Accidental } from '../src/accidental.js';
|
|
3
|
+
import { Bend } from '../src/bend.js';
|
|
4
|
+
import { CanvasContext } from '../src/canvascontext.js';
|
|
5
|
+
import { Element } from '../src/element.js';
|
|
6
|
+
import { Flow } from '../src/flow.js';
|
|
7
|
+
import { Font, FontStyle, FontWeight } from '../src/font.js';
|
|
8
|
+
import { PedalMarking } from '../src/pedalmarking.js';
|
|
9
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
10
|
+
import { TextBracket } from '../src/textbracket.js';
|
|
11
|
+
import { TextNote } from '../src/textnote.js';
|
|
12
|
+
import { Voice } from '../src/voice.js';
|
|
13
|
+
const FontTests = {
|
|
14
|
+
Start() {
|
|
15
|
+
QUnit.module('Font');
|
|
16
|
+
test('setFont', setFont);
|
|
17
|
+
test('Parsing', fontParsing);
|
|
18
|
+
test('Sizes', fontSizes);
|
|
19
|
+
const run = VexFlowTests.runTests;
|
|
20
|
+
run('Set Text Font to Georgia', setTextFontToGeorgia);
|
|
21
|
+
run('Set Music Font to Petaluma', setMusicFontToPetaluma);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
function setFont() {
|
|
25
|
+
const canvas = document.createElement('canvas');
|
|
26
|
+
canvas.width = 800;
|
|
27
|
+
canvas.height = 400;
|
|
28
|
+
const ctx = new CanvasContext(canvas.getContext('2d'));
|
|
29
|
+
ctx.setFont('PetalumaScript', '100px', 'normal', 'italic');
|
|
30
|
+
equal(ctx.font, 'italic 100px PetalumaScript');
|
|
31
|
+
const voice = new Voice();
|
|
32
|
+
propEqual(voice.fontInfo, Element.TEXT_FONT);
|
|
33
|
+
voice.setFont('bold 32pt Arial');
|
|
34
|
+
const fontInfo = voice.fontInfo;
|
|
35
|
+
equal(fontInfo === null || fontInfo === void 0 ? void 0 : fontInfo.size, '32pt');
|
|
36
|
+
const flat = new Accidental('b');
|
|
37
|
+
equal(flat.textFont, undefined);
|
|
38
|
+
flat.setFont(undefined, undefined, undefined, FontStyle.ITALIC);
|
|
39
|
+
equal(flat.getFont(), 'italic 10pt Arial, sans-serif');
|
|
40
|
+
flat.setFont(undefined, undefined, FontWeight.BOLD, undefined);
|
|
41
|
+
equal(flat.getFont(), 'bold 10pt Arial, sans-serif');
|
|
42
|
+
flat.setFont(undefined, undefined, FontWeight.BOLD, FontStyle.ITALIC);
|
|
43
|
+
equal(flat.getFont(), 'italic bold 10pt Arial, sans-serif');
|
|
44
|
+
flat.setFont(undefined, undefined, FontWeight.BOLD, 'oblique');
|
|
45
|
+
equal(flat.getFont(), 'oblique bold 10pt Arial, sans-serif');
|
|
46
|
+
flat.setFont(undefined, undefined, 'normal', '');
|
|
47
|
+
equal(flat.getFont(), '10pt Arial, sans-serif');
|
|
48
|
+
}
|
|
49
|
+
function fontParsing() {
|
|
50
|
+
const b = new Bend('1/2', true);
|
|
51
|
+
const bFont = b.fontInfo;
|
|
52
|
+
equal(bFont === null || bFont === void 0 ? void 0 : bFont.family, Font.SANS_SERIF);
|
|
53
|
+
equal(bFont === null || bFont === void 0 ? void 0 : bFont.size, Font.SIZE);
|
|
54
|
+
equal(bFont === null || bFont === void 0 ? void 0 : bFont.weight, FontWeight.NORMAL);
|
|
55
|
+
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
|
+
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
|
+
equal(f2 === null || f2 === void 0 ? void 0 : f2.size, 15);
|
|
64
|
+
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
|
+
equal(f3SizeInPx, 24);
|
|
68
|
+
}
|
|
69
|
+
function fontSizes() {
|
|
70
|
+
{
|
|
71
|
+
const size = '17px';
|
|
72
|
+
const sizeInEm = Font.convertSizeToPixelValue(size) / Font.scaleToPxFrom.em;
|
|
73
|
+
equal(sizeInEm, 1.0625);
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
const size = '2em';
|
|
77
|
+
const sizeInPx = Font.convertSizeToPixelValue(size);
|
|
78
|
+
equal(sizeInPx, 32);
|
|
79
|
+
}
|
|
80
|
+
{
|
|
81
|
+
const pedal = new PedalMarking([]);
|
|
82
|
+
equal(pedal.getFont(), 'italic bold 12pt Times New Roman, serif');
|
|
83
|
+
equal(pedal.fontSizeInPoints, 12);
|
|
84
|
+
equal(pedal.fontSizeInPixels, 16);
|
|
85
|
+
const doubledSizePx = pedal.fontSizeInPixels * 2;
|
|
86
|
+
equal(doubledSizePx, 32);
|
|
87
|
+
const doubledSizePt = Font.scaleSize(pedal.fontSizeInPoints, 2);
|
|
88
|
+
equal(doubledSizePt, 24);
|
|
89
|
+
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'], stem_direction: -1, duration: 'h' }),
|
|
98
|
+
factory.StaveNote({ keys: ['d/4', 'f/4'], stem_direction: -1, duration: 'q' }),
|
|
99
|
+
factory.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: 'q' }),
|
|
100
|
+
]);
|
|
101
|
+
const defaultFont = TextNote.TEXT_FONT;
|
|
102
|
+
TextNote.TEXT_FONT = {
|
|
103
|
+
family: 'Georgia, Courier New, serif',
|
|
104
|
+
size: 14,
|
|
105
|
+
weight: 'bold',
|
|
106
|
+
style: 'italic',
|
|
107
|
+
};
|
|
108
|
+
const voice2 = score.voice([
|
|
109
|
+
factory
|
|
110
|
+
.TextNote({ text: 'Here are some fun lyrics...', duration: 'w' })
|
|
111
|
+
.setJustification(TextNote.Justification.LEFT),
|
|
112
|
+
]);
|
|
113
|
+
const formatter = factory.Formatter();
|
|
114
|
+
formatter.joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
|
|
115
|
+
factory.draw();
|
|
116
|
+
TextNote.TEXT_FONT = defaultFont;
|
|
117
|
+
ok(true);
|
|
118
|
+
}
|
|
119
|
+
function setMusicFontToPetaluma(options) {
|
|
120
|
+
Flow.setMusicFont('Petaluma');
|
|
121
|
+
const factory = VexFlowTests.makeFactory(options, 400, 200);
|
|
122
|
+
const stave = factory.Stave({ y: 40 });
|
|
123
|
+
const score = factory.EasyScore();
|
|
124
|
+
const voice = score.voice([
|
|
125
|
+
factory.StaveNote({ keys: ['c/4', 'e/4', 'a/4'], stem_direction: -1, duration: 'h' }),
|
|
126
|
+
factory.StaveNote({ keys: ['d/4', 'f/4'], stem_direction: -1, duration: 'q' }),
|
|
127
|
+
factory.StaveNote({ keys: ['c/4', 'f/4', 'a/4'], stem_direction: -1, duration: 'q' }),
|
|
128
|
+
]);
|
|
129
|
+
const formatter = factory.Formatter();
|
|
130
|
+
formatter.joinVoices([voice]).formatToStave([voice], stave);
|
|
131
|
+
factory.draw();
|
|
132
|
+
ok(true);
|
|
133
|
+
}
|
|
134
|
+
VexFlowTests.register(FontTests);
|
|
135
|
+
export { FontTests };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
class FrameStack {
|
|
3
|
+
constructor(parentEl, numFrames, params) {
|
|
4
|
+
this.parentEl = parentEl;
|
|
5
|
+
this.numFrames = numFrames;
|
|
6
|
+
this.options = Object.assign({ prefix: 'vex-frame-', width: 700, height: 800, iterationCallback: null }, params);
|
|
7
|
+
this.frames = [];
|
|
8
|
+
this.currentFrame = 0;
|
|
9
|
+
document.getElementById(this.parentEl).innerHTML = '';
|
|
10
|
+
for (let i = 0; i < this.numFrames; i++) {
|
|
11
|
+
const div = document.createElement('div');
|
|
12
|
+
div.id = this.frameID(i);
|
|
13
|
+
div.style.position = 'absolute';
|
|
14
|
+
div.style.top = 0;
|
|
15
|
+
div.style.left = 0;
|
|
16
|
+
div.style.width = `${this.options.width}px`;
|
|
17
|
+
div.style.height = `${this.options.height}px`;
|
|
18
|
+
div.style.display = 'none';
|
|
19
|
+
this.frames[i] = div;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
frameID(i) {
|
|
23
|
+
return `${this.options.prefix}${i}`;
|
|
24
|
+
}
|
|
25
|
+
install() {
|
|
26
|
+
this.show(0);
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
const fragment = document.createDocumentFragment();
|
|
29
|
+
for (let i = 0; i < this.numFrames; i++) {
|
|
30
|
+
fragment.appendChild(this.frames[i]);
|
|
31
|
+
}
|
|
32
|
+
const parent = document.getElementById(this.parentEl);
|
|
33
|
+
parent.appendChild(fragment);
|
|
34
|
+
parent.style.width = `${this.options.width}px`;
|
|
35
|
+
parent.style.height = `${this.options.height}px`;
|
|
36
|
+
}, 0);
|
|
37
|
+
}
|
|
38
|
+
get(i) {
|
|
39
|
+
return this.frames[i];
|
|
40
|
+
}
|
|
41
|
+
show(i) {
|
|
42
|
+
this.frames[this.currentFrame].style.display = 'none';
|
|
43
|
+
this.frames[i].style.display = 'block';
|
|
44
|
+
this.currentFrame = i;
|
|
45
|
+
}
|
|
46
|
+
start(params) {
|
|
47
|
+
const options = Object.assign({ start: 0, end: this.numFrames, intervalms: 100 }, params);
|
|
48
|
+
this.animationTimer = setInterval(() => {
|
|
49
|
+
const frame = this.currentFrame + 1 === this.numFrames ? 0 : this.currentFrame + 1;
|
|
50
|
+
this.show(frame);
|
|
51
|
+
if (this.options.iterationCallback)
|
|
52
|
+
this.options.iterationCallback(frame);
|
|
53
|
+
}, options.intervalms);
|
|
54
|
+
}
|
|
55
|
+
stop() {
|
|
56
|
+
clearInterval(this.animationTimer);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (typeof module != 'undefined') {
|
|
60
|
+
module.exports = { FrameStack };
|
|
61
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const VF = Vex.Flow;
|
|
3
|
+
function subgroup(el, iterations, params) {
|
|
4
|
+
const options = Object.assign({ systemWidth: 550, debug: true }, params);
|
|
5
|
+
const f = new VF.Factory({
|
|
6
|
+
renderer: {
|
|
7
|
+
elementId: el,
|
|
8
|
+
width: options.width,
|
|
9
|
+
height: options.height,
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
f.StaveNote = f.StaveNote.bind(f);
|
|
13
|
+
const stave1 = f.Stave({ x: 15, y: 40, width: options.systemWidth }).setClef('treble');
|
|
14
|
+
const notes1 = [
|
|
15
|
+
{ keys: ['f/5'], stem_direction: 1, duration: '4' },
|
|
16
|
+
{ keys: ['d/4'], stem_direction: 1, duration: '4', clef: 'bass' },
|
|
17
|
+
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'alto' },
|
|
18
|
+
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'soprano' },
|
|
19
|
+
].map(f.StaveNote);
|
|
20
|
+
const notes2 = [
|
|
21
|
+
{ keys: ['c/4'], stem_direction: -1, duration: '4' },
|
|
22
|
+
{ keys: ['c/3'], stem_direction: -1, duration: '4', clef: 'bass' },
|
|
23
|
+
{ keys: ['d/4'], stem_direction: -1, duration: '4', clef: 'alto' },
|
|
24
|
+
{ keys: ['f/4'], stem_direction: -1, duration: '4', clef: 'soprano' },
|
|
25
|
+
].map(f.StaveNote);
|
|
26
|
+
const stave2 = f.Stave({ x: 15, y: 160, width: options.systemWidth }).setClef('bass');
|
|
27
|
+
const notes3 = [
|
|
28
|
+
{ keys: ['e/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
29
|
+
{ keys: ['g/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
30
|
+
{ keys: ['d/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
31
|
+
{ keys: ['f/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
32
|
+
{ keys: ['c/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
33
|
+
{ keys: ['g/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
34
|
+
{ keys: ['d/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
35
|
+
{ keys: ['f/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
36
|
+
].map(f.StaveNote);
|
|
37
|
+
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'brace' });
|
|
38
|
+
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'singleLeft' });
|
|
39
|
+
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'singleRight' });
|
|
40
|
+
function addAccidental(note, acc) {
|
|
41
|
+
return note.addModifier(f.Accidental({ type: acc }), 0);
|
|
42
|
+
}
|
|
43
|
+
function addSubGroup(note, subNotes) {
|
|
44
|
+
return note.addModifier(f.NoteSubGroup({ notes: subNotes }), 0);
|
|
45
|
+
}
|
|
46
|
+
f.Beam({ notes: notes3.slice(1, 4) });
|
|
47
|
+
f.Beam({ notes: notes3.slice(5) });
|
|
48
|
+
addAccidental(notes1[1], '#');
|
|
49
|
+
addSubGroup(notes1[1], [f.ClefNote({ type: 'bass', options: { size: 'small' } }), f.TimeSigNote({ time: '3/4' })]);
|
|
50
|
+
addSubGroup(notes2[2], [f.ClefNote({ type: 'alto', options: { size: 'small' } }), f.TimeSigNote({ time: '9/8' })]);
|
|
51
|
+
addSubGroup(notes1[3], [f.ClefNote({ type: 'soprano', options: { size: 'small' } })]);
|
|
52
|
+
addSubGroup(notes3[1], [f.ClefNote({ type: 'treble', options: { size: 'small' } })]);
|
|
53
|
+
addSubGroup(notes3[5], [f.ClefNote({ type: 'bass', options: { size: 'small' } })]);
|
|
54
|
+
addAccidental(notes3[0], '#');
|
|
55
|
+
addAccidental(notes3[3], 'b');
|
|
56
|
+
addAccidental(notes3[5], '#');
|
|
57
|
+
addAccidental(notes1[2], 'b');
|
|
58
|
+
addAccidental(notes2[3], '#');
|
|
59
|
+
const voice = f.Voice().addTickables(notes1);
|
|
60
|
+
const voice2 = f.Voice().addTickables(notes2);
|
|
61
|
+
const voice3 = f.Voice().addTickables(notes3);
|
|
62
|
+
const formatter = f.Formatter();
|
|
63
|
+
formatter.joinVoices([voice, voice2]).joinVoices([voice3]).formatToStave([voice, voice2, voice3], stave1);
|
|
64
|
+
for (let i = 0; i < iterations; i++) {
|
|
65
|
+
formatter.tune({ alpha: 0.01 });
|
|
66
|
+
}
|
|
67
|
+
f.draw();
|
|
68
|
+
if (options.debug) {
|
|
69
|
+
VF.Formatter.plotDebugging(f.getContext(), formatter, stave1.getNoteStartX(), 20, 320);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function tuplets(el, iterations, params) {
|
|
73
|
+
const options = Object.assign({ systemWidth: 500, debug: true }, params);
|
|
74
|
+
const f = new VF.Factory({
|
|
75
|
+
renderer: {
|
|
76
|
+
elementId: el,
|
|
77
|
+
width: options.width,
|
|
78
|
+
height: options.height,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const system = f.System({
|
|
82
|
+
x: 50,
|
|
83
|
+
width: options.systemWidth,
|
|
84
|
+
debugFormatter: options.debug,
|
|
85
|
+
formatIterations: iterations,
|
|
86
|
+
});
|
|
87
|
+
const score = f.EasyScore();
|
|
88
|
+
const newVoice = function (notes) {
|
|
89
|
+
return score.voice(notes, { time: '1/4' });
|
|
90
|
+
};
|
|
91
|
+
const newStave = function (voice) {
|
|
92
|
+
return system
|
|
93
|
+
.addStave({ voices: [voice], debugNoteMetrics: options.debug })
|
|
94
|
+
.addClef('treble')
|
|
95
|
+
.addTimeSignature('1/4');
|
|
96
|
+
};
|
|
97
|
+
const voices = [
|
|
98
|
+
score.notes('c5/8, c5'),
|
|
99
|
+
score.tuplet(score.notes('a4/8, a4, a4'), { notes_occupied: 2 }),
|
|
100
|
+
score.notes('c5/16, c5, c5, c5'),
|
|
101
|
+
score.tuplet(score.notes('a4/16, a4, a4, a4, a4'), { notes_occupied: 4 }),
|
|
102
|
+
score.tuplet(score.notes('a4/32, a4, a4, a4, a4, a4, a4'), { notes_occupied: 8 }),
|
|
103
|
+
];
|
|
104
|
+
voices.map(newVoice).forEach(newStave);
|
|
105
|
+
system.addConnector().setType(VF.StaveConnector.type.BRACKET);
|
|
106
|
+
f.draw();
|
|
107
|
+
}
|
|
108
|
+
function multistave(el, iterations, params) {
|
|
109
|
+
const options = Object.assign({ systemWidth: 550, debug: true, justify: true, alpha: 0.1 }, params);
|
|
110
|
+
const f = new VF.Factory({
|
|
111
|
+
renderer: {
|
|
112
|
+
elementId: el,
|
|
113
|
+
width: options.width,
|
|
114
|
+
height: options.height,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
const score = f.EasyScore();
|
|
118
|
+
const stave11 = f.Stave({ y: 20, width: 275 }).addTrebleGlyph().addTimeSignature('6/8');
|
|
119
|
+
const notes11 = score.notes('f4/4, d4/8, g4/4, eb4/8');
|
|
120
|
+
const voice11 = score.voice(notes11, { time: '6/8' });
|
|
121
|
+
const stave21 = f.Stave({ y: 130, width: 275 }).addTrebleGlyph().addTimeSignature('6/8');
|
|
122
|
+
const notes21 = score.notes('d4/8, d4, d4, d4, eb4, eb4');
|
|
123
|
+
const voice21 = score.voice(notes21, { time: '6/8' });
|
|
124
|
+
const stave31 = f.Stave({ y: 250, width: 275 }).addClef('bass').addTimeSignature('6/8');
|
|
125
|
+
const notes31 = score.notes('a5/8, a5, a5, a5, a5, a5', { stem: 'down' });
|
|
126
|
+
const voice31 = score.voice(notes31, { time: '6/8' });
|
|
127
|
+
f.StaveConnector({
|
|
128
|
+
top_stave: stave21,
|
|
129
|
+
bottom_stave: stave31,
|
|
130
|
+
type: 'brace',
|
|
131
|
+
});
|
|
132
|
+
f.Beam({ notes: notes21.slice(0, 3) });
|
|
133
|
+
f.Beam({ notes: notes21.slice(3, 6) });
|
|
134
|
+
f.Beam({ notes: notes31.slice(0, 3) });
|
|
135
|
+
f.Beam({ notes: notes31.slice(3, 6) });
|
|
136
|
+
let formatter = f.Formatter().joinVoices([voice11]).joinVoices([voice21]).joinVoices([voice31]);
|
|
137
|
+
if (options.justify) {
|
|
138
|
+
formatter.formatToStave([voice11, voice21, voice31], stave11);
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
formatter.format([voice11, voice21, voice31], 0);
|
|
142
|
+
}
|
|
143
|
+
for (let i = 0; i < iterations; i++) {
|
|
144
|
+
formatter.tune({ alphs: options.alpha });
|
|
145
|
+
}
|
|
146
|
+
if (options.debug) {
|
|
147
|
+
VF.Formatter.plotDebugging(f.getContext(), formatter, stave11.getNoteStartX(), 20, 320);
|
|
148
|
+
}
|
|
149
|
+
const stave12 = f.Stave({
|
|
150
|
+
x: stave11.width + stave11.x,
|
|
151
|
+
y: stave11.y,
|
|
152
|
+
width: stave11.width,
|
|
153
|
+
});
|
|
154
|
+
var notes12 = score.notes('ab4/4, bb4/8, (cb5 eb5)/4[stem="down"], d5/8[stem="down"]');
|
|
155
|
+
var voice12 = score.voice(notes12, { time: '6/8' });
|
|
156
|
+
f.Stave({
|
|
157
|
+
x: stave21.width + stave21.x,
|
|
158
|
+
y: stave21.y,
|
|
159
|
+
width: stave21.width,
|
|
160
|
+
});
|
|
161
|
+
var notes22 = score.notes('(eb4 ab4)/4., (c4 eb4 ab4)/4, db5/8', { stem: 'up' });
|
|
162
|
+
var voice22 = score.voice(notes22, { time: '6/8' });
|
|
163
|
+
f.Stave({
|
|
164
|
+
x: stave31.width + stave31.x,
|
|
165
|
+
y: stave31.y,
|
|
166
|
+
width: stave31.width,
|
|
167
|
+
});
|
|
168
|
+
var notes32 = score.notes('a5/8, a5, a5, a5, a5, a5', { stem: 'down' });
|
|
169
|
+
var voice32 = score.voice(notes32, { time: '6/8' });
|
|
170
|
+
formatter = f.Formatter().joinVoices([voice12]).joinVoices([voice22]).joinVoices([voice32]);
|
|
171
|
+
if (options.justify) {
|
|
172
|
+
formatter.formatToStave([voice12, voice22, voice32], stave12);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
formatter.format([voice12, voice22, voice32], 0);
|
|
176
|
+
}
|
|
177
|
+
for (var j = 0; j < iterations; j++) {
|
|
178
|
+
formatter.tune({ alpha: options.alpha });
|
|
179
|
+
}
|
|
180
|
+
f.Beam({ notes: notes32.slice(0, 3) });
|
|
181
|
+
f.Beam({ notes: notes32.slice(3, 6) });
|
|
182
|
+
f.draw();
|
|
183
|
+
if (options.debug) {
|
|
184
|
+
VF.Formatter.plotDebugging(f.getContext(), formatter, stave12.getNoteStartX(), 20, 320);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const Tests = {
|
|
188
|
+
tuplets: {
|
|
189
|
+
options: { width: 600, height: 750, debug: true },
|
|
190
|
+
fn: tuplets,
|
|
191
|
+
},
|
|
192
|
+
subgroup: {
|
|
193
|
+
options: { width: 650, height: 350, debug: true },
|
|
194
|
+
fn: subgroup,
|
|
195
|
+
},
|
|
196
|
+
multistave: {
|
|
197
|
+
options: { width: 650, height: 350, debug: true },
|
|
198
|
+
fn: multistave,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
if (typeof module != 'undefined') {
|
|
202
|
+
module.exports = Tests;
|
|
203
|
+
}
|