tpc2unicode()
I have added this function to my branch's version of pagesettings.cpp. It allows me to use the FreeSerif to display Unicode musical accidentals characters, which I find useful for displaying text versions of pitch values. Many other fonts contain these characters too.
I realize that this is not something that MuseScore needs right now, but it might in the future, so I would like to create a PR and add it to the master. What to you all think about that? Here is the pair of functions I have now:
//---------------------------------------------------------
// tpc2unicode
// return note name with unicode character set for musical symbols
//---------------------------------------------------------
QString tpc2unicode(int tpc, NoteSpellingType noteSpelling, NoteCaseType noteCase)
{
QString s;
QString acc;
tpc2unicode(tpc, noteSpelling, noteCase, s, acc);
return s + acc;
}
//---------------------------------------------------------
// tpc2unicode overload for internal use
// calls last tpc2name() for note letter text
// then it determines the accidental unicode text
//---------------------------------------------------------
void tpc2unicode(int tpc, NoteSpellingType noteSpelling, NoteCaseType noteCase, QString& s, QString& acc)
{
int n;
tpc2name(tpc, noteSpelling, noteCase, s, n);
switch (n) {
case -2: acc = "𝄫"; break; // double-flat
case -1: acc = "♭"; break; // flat
case 0: acc = ""; break; // ♮"; break; // natural not used, this is universal-ish text
case 1: acc = "♯"; break; // sharp
case 2: acc = "𝄪"; break; // double-sharp
default:
qDebug("tpc2name(%d): acc %d", tpc, n);
acc = "";
break;
}
}