// Summary: Create an HTML page containing the VexFlow output. // Use VexFlow to render a hello world score in a node-canvas context. // See: https://www.npmjs.com/package/canvas // Display the canvas data in an <img> tag via canvas.toDataURL(). // // // Since we use a require(...) statement below, we will load the CJS bundle at build/cjs/vexflow.js // See the `exports` field in package.json for details.
// Node canvas has a different API for loading fonts. registerFont('../../node_modules/@vexflow-fonts/bravura/bravura.otf',{family:'Bravura'}); registerFont('../../node_modules/@vexflow-fonts/petaluma/petaluma.otf',{family:'Petaluma'});
// VexFlow 5 uses a hidden canvas for measuring font glyphs. // https://www.w3.org/TR/2012/WD-html5-author-20120329/the-canvas-element.html#the-canvas-element // In browsers, canvas elements usually default to 300 x 150. VexFlow.Element.setTextMeasurementCanvas(createCanvas(300,150));