Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions src/notation/internal/engravingfontscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,36 @@ void EngravingFontsController::scanDirectory(const muse::io::path_t& path, bool
while (iterator.hasNext()) {
iterator.next();
QString fontDir = iterator.filePath();
muse::io::path_t metadataPath;

{
QDirIterator jsonFilesIterator(fontDir, { "*.json" }, QDir::Files);
while (jsonFilesIterator.hasNext()) {
jsonFilesIterator.next();
metadataPath = jsonFilesIterator.filePath();
QString fontName = iterator.fileName();
muse::io::path_t metadataPath = fontDir + "/" + fontName + ".json";
QFile fi(metadataPath.toQString());
if (!fi.exists()) {
if (isPrivate) {
metadataPath = fontDir + "/" + fontName.toLower().replace(" ", "_") + "_metadata.json";
fi.setFileName(metadataPath.toQString());
if (!fi.exists()) {
metadataPath = fontDir + "/" + "metadata.json";
fi.setFileName(metadataPath.toQString());
}
if (!fi.exists()) {
metadataPath = muse::io::path_t();
QDirIterator jsonFilesIterator(fontDir, { "*.json" }, QDir::Files);
while (jsonFilesIterator.hasNext()) {
jsonFilesIterator.next();
metadataPath = jsonFilesIterator.filePath();
}
if (metadataPath.empty()) {
continue;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
} else {
continue;
}
}

if (metadataPath.empty()) {
continue;
}

// We assume the font name is the same as the directory name,
// but maybe we should instead read the metadata.json file to get the font name

QString fontName = iterator.fileName();
QString fontFamily = fontName;

if (fontName.contains(u"Text")) {
Expand All @@ -141,19 +153,19 @@ void EngravingFontsController::scanDirectory(const muse::io::path_t& path, bool
symbolFontPath = findFontPath(tmp.replace(" ", ""));
}

muse::io::path_t textFontPath = findFontPath(fontName + " Text");
if (symbolFontPath.empty()) {
QString tmp = fontName;
symbolFontPath = findFontPath(tmp.replace(" ", "") + "Text");
LOGE() << "Music font \"" << fontName << "\" for " << metadataPath << " not found";
continue;
}

muse::io::path_t textFontPath = findFontPath(fontName + " Text");
if (textFontPath.empty()) {
textFontPath = symbolFontPath;
QString tmp = fontName;
textFontPath = findFontPath(tmp.replace(" ", "") + "Text");
Comment thread
Jojo-Schmitz marked this conversation as resolved.
}

if (symbolFontPath.empty()) {
LOGE() << "Music font \"" << fontName << "\" for " << metadataPath << " not found";
continue;
if (textFontPath.empty()) {
textFontPath = symbolFontPath;
}

LOGI() << "Adding custom SMuFL font: " << fontName
Expand Down
Loading