rism-digital / verovio

🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)
https://www.verovio.org
GNU Lesser General Public License v3.0
686 stars 185 forks source link

using glyph.num with accidentals #1837

Closed ramagottfried closed 3 years ago

ramagottfried commented 4 years ago

hello! thanks for all your great work on verovio, really nice project.

I'm investigating using the system with a project I'm working on but am stuck when trying to use alternative accidentals from the Bravura font.

here is my test code, running in node.js, with verovio v.2.7.2 installed via npm.

just as a simple test for glyph.num I'm using a standard accidental U+E260 ( https://w3c.github.io/smufl/gitbook/tables/standard-accidentals-12-edo.html )

const verovio = require('verovio');
const fs = require("fs");

verovio.module.onRuntimeInitialized = function ()
{
    /* create the toolkit instance */
    var vrvToolkit = new verovio.toolkit();

    let mei = `<mei xmlns="http://www.music-encoding.org/ns/mei">
<meiHead>
    <fileDesc>
        <titleStmt>
            <title/>
        </titleStmt>
        <pubStmt/>
    </fileDesc>
</meiHead>
<music>
    <body>
        <mdiv>
            <score>
                <scoreDef>
                    <staffGrp>
                        <staffDef clef.shape="G" clef.line="2" n="1" lines="5"/>
                    </staffGrp>
                </scoreDef>
                <section>
                    <measure>
                        <staff n="1">
                            <layer>
                                <note pname="c" oct="4" dur="4">
                                    <accid glyph.num="U+ E260" />
                                </note>

                                <note pname="d" oct="4" dur="4"/>
                                <note pname="e" oct="4" dur="4"/>
                                <note pname="f" oct="4" dur="4"/>

                            </layer>
                        </staff>
                    </measure>
                </section>
            </score>
        </mdiv>
    </body>
</music>
</mei>`;

    const options = { font: "Bravura" }
    vrvToolkit.setOptions(options);

    vrvToolkit.loadData(mei);

    svg = vrvToolkit.renderToSVG(1, {});

    fs.writeFileSync("hello.svg", svg);
}

in the resulting SVG, I see the accid but no glyph:

    <g id="note-0000001862637027" class="note">
        <g class="notehead">
            <use xlink:href="#E0A4" x="933" y="1620" height="720px" width="720px" />
        </g>
        <g id="stem-0000002094793443" class="stem">
            <rect x="1127" y="990" height="608" width="18" />
        </g>
        <g id="accid-0000002079994892" class="accid" />
    </g>

I also tried <accid glyph.auth="smufl" glyph.num="U+E260" /> but no change.

should this work?

thanks for any suggestions.

all the best, rama

lpugin commented 4 years ago

This is not supported, but should be fairly straightforward to implement. You can have a look at the corresponding implementation for <fermata> https://github.com/rism-ch/verovio/blob/e612f679ca3a597f93724adc8865a73aea8bf1cc/src/fermata.cpp#L64-L88