Skip to content

Commit

Permalink
[Fix] External font loading problem with text cursor accessing unacce…
Browse files Browse the repository at this point in the history
…ssible textbase
  • Loading branch information
worldwideweary authored and Jojo-Schmitz committed Sep 17, 2024
1 parent 1b2aa75 commit 33f2b19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
1 change: 1 addition & 0 deletions libmscore/mscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ void MScore::init()
":/fonts/finalebroadway/FinaleBroadwayText.otf",
};

// Include the above internal text fonts into QFontDatabase
for (unsigned i = 0; i < sizeof(fonts)/sizeof(*fonts); ++i) {
QString str(fonts[i]);
if (-1 == QFontDatabase::addApplicationFont(str)) {
Expand Down
18 changes: 12 additions & 6 deletions libmscore/sym.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6429,11 +6429,6 @@ void ScoreFont::draw(SymId id, QPainter* painter, const QSizeF& mag, const QPoin

if (MScore::pdfPrinting) {
if (font == 0) {
QString s(_fontPath+_filename);
if (-1 == QFontDatabase::addApplicationFont(s)) {
qDebug("Mscore: fatal error: cannot load internal font <%s>", qPrintable(s));
return;
}
font = new QFont;
font->setWeight(QFont::Normal);
font->setItalic(false);
Expand Down Expand Up @@ -6562,7 +6557,7 @@ const char* Sym::id2name(SymId id)
// load default score font
//---------------------------------------------------------

void ScoreFont::initScoreFonts()
void Ms::ScoreFont::initScoreFonts()
{
QJsonObject glyphNamesJson(ScoreFont::initGlyphNamesJson());
if (glyphNamesJson.empty())
Expand Down Expand Up @@ -6675,6 +6670,17 @@ void ScoreFont::scanUserFonts(const QString& path, bool system)

_allScoreFonts = _builtinScoreFonts;
_allScoreFonts << _userScoreFonts << _systemScoreFonts;

// Include external and internal score fonts into QFontDatabase
for (auto& f : _allScoreFonts) {
QString s(f._fontPath + f._filename);
if (-1 == QFontDatabase::addApplicationFont(s)) {
if (!MScore::testMode)
qDebug("Mscore: fatal error: cannot load external font <%s>", qPrintable(s));
if (!MScore::debugMode && !MScore::testMode)
exit(-1);
}
}
}

//---------------------------------------------------------
Expand Down

0 comments on commit 33f2b19

Please sign in to comment.