Merge pull request #940 from mgavioli/Bravura_stylistic_alternates
Make needed Bravura stylistic alternates available to score font.
This commit is contained in:
commit
3167c3e7c4
1 changed files with 38 additions and 1 deletions
|
@ -6246,7 +6246,44 @@ void ScoreFont::load()
|
|||
sym->setBbox(QRectF(_fm->tightBoundingRect(s)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// access needed Bravura stylistic alternates
|
||||
|
||||
struct StylisticAlternate {
|
||||
QString key;
|
||||
QString altKey;
|
||||
SymId id;
|
||||
} alternate[] = {
|
||||
{ QString("6stringTabClef"),
|
||||
QString("6stringTabClefSerif"),
|
||||
SymId::sixStringTabClefSerif
|
||||
}
|
||||
};
|
||||
|
||||
// find each relevant alternate in "glyphsWithAlternates" value
|
||||
QJsonObject oa = o.value("glyphsWithAlternates").toObject();
|
||||
bool ok;
|
||||
for (const StylisticAlternate& c : alternate) {
|
||||
QJsonObject::const_iterator i = oa.find(c.key);
|
||||
if (i != oa.end()) {
|
||||
QJsonArray oaa = i.value().toObject().value("alternates").toArray();
|
||||
// locate the relevant altKey in alternate array
|
||||
for (auto j : oaa) {
|
||||
QJsonObject jo = j.toObject();
|
||||
if(jo.value("name") == c.altKey) {
|
||||
Sym* sym = &_symbols[int(c.id)];
|
||||
int code = jo.value("codepoint").toString().mid(2).toInt(&ok, 16);
|
||||
if (ok) {
|
||||
QString s = codeToString(code);
|
||||
sym->setString(s);
|
||||
sym->setBbox(QRectF(_fm->tightBoundingRect(s)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*for (int i = 1; i < int(SymId::lastSym); ++i) {
|
||||
Sym sym = _symbols[i];
|
||||
if (!sym.isValid())
|
||||
|
|
Loading…
Reference in a new issue