Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed SMuFL anchors #8958

Merged
merged 2 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engraving/engravingmodule.h
Expand Up @@ -35,7 +35,7 @@ class EngravingModule : public modularity::IModuleSetup
void registerResources() override;
void registerUiTypes() override;
void onInit(const framework::IApplication::RunMode& mode) override;
void onDeinit();
void onDeinit() override;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/engraving/libmscore/mscoreview.cpp
Expand Up @@ -62,7 +62,7 @@ Element* MuseScoreView::elementAt(const mu::PointF& p)

Page* MuseScoreView::point2page(const mu::PointF& p)
{
if (score()->layoutMode() == LayoutMode::LINE) {
if (score()->layoutMode() == mu::engraving::LayoutMode::LINE) {
return score()->pages().isEmpty() ? 0 : score()->pages().front();
}
foreach (Page* page, score()->pages()) {
Expand Down
60 changes: 24 additions & 36 deletions src/engraving/libmscore/scorefont.cpp
Expand Up @@ -274,7 +274,6 @@ void ScoreFont::load()
void ScoreFont::loadGlyphsWithAnchors(const QJsonObject& glyphsWithAnchors)
{
for (const QString& symName : glyphsWithAnchors.keys()) {
constexpr qreal scale = SPATIUM20;
QJsonObject anchors = glyphsWithAnchors.value(symName).toObject();

SymId symId = Sym::nameToSymIdHash.value(symName, SymId::noSym);
Expand All @@ -284,42 +283,31 @@ void ScoreFont::loadGlyphsWithAnchors(const QJsonObject& glyphsWithAnchors)
continue;
}

Sym* sym = &m_symbols[int(symId)];

for (const QString& anchorKey : anchors.keys()) {
if (anchorKey == "stemDownNW") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::stemDownNW, PointF(x, -y) * 4.0 * DPI_F);
} else if (anchorKey == "stemUpSE") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::stemUpSE, PointF(x, -y) * 4.0 * DPI_F);
} else if (anchorKey == "stemDownSW") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::stemDownSW, PointF(x, -y) * 4.0 * DPI_F);
} else if (anchorKey == "stemUpNW") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::stemUpNW, PointF(x, -y) * 4.0 * DPI_F);
} else if (anchorKey == "cutOutNE") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::cutOutNE, PointF(x, -y) * scale);
} else if (anchorKey == "cutOutNW") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::cutOutNW, PointF(x, -y) * scale);
} else if (anchorKey == "cutOutSE") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::cutOutSE, PointF(x, -y) * scale);
} else if (anchorKey == "cutOutSW") {
qreal x = anchors.value(anchorKey).toArray().at(0).toDouble();
qreal y = anchors.value(anchorKey).toArray().at(1).toDouble();
sym->setSmuflAnchor(SmuflAnchorId::cutOutSW, PointF(x, -y) * scale);
Sym& sym = m_symbols[size_t(symId)];

static const std::unordered_map<QString, SmuflAnchorId> smuflAnchorIdNames {
{ "stemDownNW", SmuflAnchorId::stemDownNW },
{ "stemUpSE", SmuflAnchorId::stemUpSE },
{ "stemDownSW", SmuflAnchorId::stemDownSW },
{ "stemUpNW", SmuflAnchorId::stemUpNW },
{ "cutOutNE", SmuflAnchorId::cutOutNE },
{ "cutOutNW", SmuflAnchorId::cutOutNW },
{ "cutOutSE", SmuflAnchorId::cutOutSE },
{ "cutOutSW", SmuflAnchorId::cutOutSW }
};

for (const QString& anchorId : anchors.keys()) {
auto search = smuflAnchorIdNames.find(anchorId);
if (search == smuflAnchorIdNames.cend()) {
//LOGD() << "Unhandled SMuFL anchorId: " << anchorId;
continue;
}

QJsonArray arr = anchors.value(anchorId).toArray();
double x = arr.at(0).toDouble();
double y = arr.at(1).toDouble();

sym.setSmuflAnchor(search->second, PointF(x, -y) * SPATIUM20);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/framework/fonts/fonts_Petaluma.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource prefix="/">
<file alias="fonts/petaluma/metadata.json">../../../fonts/petaluma/petaluma_metadata.json</file>
<file alias="fonts/petaluma/Petaluma.otf">../../../fonts/petaluma/Petaluma.otf</file>
<file alias="fonts/petaluma/PetalumaText.otf">../../../fonts/petaluma/PetalumaText.otf</file>
<file alias="fonts/petaluma/PetalumaScript.otf">../../../fonts/petaluma/PetalumaScript.otf</file>
Expand Down
Expand Up @@ -22,6 +22,8 @@

#include "importxmlfirstpass.h"

#include "log.h"
cbjeukendrup marked this conversation as resolved.
Show resolved Hide resolved

namespace Ms {
// TODO: move somewhere else

Expand Down