// Summary: // Save scores to portable SVG, with embedded OTF fonts (base64 encoded). // This demo is buggy, since the note heads are detached from the stems. // Perhaps this is a glyph measurement issue? // // Run: // node import2.mjs // // Press a key to advance to the next command. CTRL+C to quit. // This demo uses await import(...) to load vexflow.js.
import{defaultas fs }from'fs';
import{JSDOM}from'jsdom';
// Reference to VexFlow, assigned in the step1() function. letVF;
// Create an SVG renderer and attach it to the DIV element named "vf". const div = document.getElementById('vf'); const renderer =newRenderer(div, Renderer.Backends.SVG);
asyncfunctionstep0(){ console.log('Press any key to run the next command. CTRL+C to quit.'); console.log('\n==================================\n'); console.log('>>> load vexflow ...');
// Make sure the output folder exists. if(!fs.existsSync('./output/')){ fs.mkdirSync('./output/'); } }
asyncfunctionstep2(){ VF.setFonts('Bravura','Academico'); console.log('The current music font stack is:',VF.getFonts()); fs.writeFileSync('output/score_bravura.svg',svgScore('Bravura'));
asyncfunctionstep3(){ VF.setFonts('Petaluma','Petaluma Script'); console.log('The current music font stack is:',VF.getFonts()); fs.writeFileSync('output/score_petaluma.svg',svgScore('Petaluma'));
asyncfunctionstep4(){ VF.setFonts('Gonville','Academico'); console.log('The current music font stack is:',VF.getFonts()); fs.writeFileSync('output/score_gonville.svg',svgScore('Gonville'));
asyncfunctionstep5(){ VF.setFonts('Leland','Edwin'); console.log('The current music font stack is:',VF.getFonts()); fs.writeFileSync('output/score_leland.svg',svgScore('Leland'));