diff --git a/src/notation/internal/engravingfontscontroller.cpp b/src/notation/internal/engravingfontscontroller.cpp index 19baa7fe7e4b8..3ad68e1ec3939 100644 --- a/src/notation/internal/engravingfontscontroller.cpp +++ b/src/notation/internal/engravingfontscontroller.cpp @@ -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; + } + } + } 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")) { @@ -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"); } - if (symbolFontPath.empty()) { - LOGE() << "Music font \"" << fontName << "\" for " << metadataPath << " not found"; - continue; + if (textFontPath.empty()) { + textFontPath = symbolFontPath; } LOGI() << "Adding custom SMuFL font: " << fontName