[MU3] Add the possibility to use custom ScoreFonts#82
Conversation
|
@cbjeukendrup: any idea why almost all mtests crash? |
bdf9aa7 to
fb90c23
Compare
|
I'm afraid I won't have time to look into this very soon, but I'll add it to my list :) |
|
Howto use custom Scorefonts. -create new directory 'ScoreFonts', on the same level as Scores, Plugins, SoundFonts .. Standard Music Font Layout (SMuFL) compatible Fonts. SIL Font Licence Sebastian by Florian Kretlow Leipzig (verovio) Finale Smufl Fonts: GoldenAge eNote legato Ekmelos Free (unknown licence) Cap1800 Commercial Fonts Norfonts: November 2. Music Type Foundry. Copyrighted: AloisenU and AloisenGrooveU |
fb90c23 to
34c7bef
Compare
| } | ||
| } | ||
|
|
||
| bool hasMetadataFile = QFileInfo::exists(fontDirPath + "metadata.json"); |
There was a problem hiding this comment.
Would be nice to allow for <fontname>_metatada.json here (but not making it mandatory), or simply *metadata.json, or even *.json, at least if there is only one?
There was a problem hiding this comment.
Yes. As is you cannot have a music font and a text font in the same directory (e.g. Finale Jazz and Finale Jazz text
There was a problem hiding this comment.
correction: Bravura has only one metadata.json file for Bravura.otf and BravuraText.otf. so it should be possible.
There was a problem hiding this comment.
It indeed should. You just can't have different json files for both
What is strange though: regardless of whether the score has a *Text variant or not, the dialog always shows one
There was a problem hiding this comment.
I can't display dynamic, with none of the fonts i tried (e.g. Finale Ash). I need to switch the 'Musical Text Font' to a buildin one.
Can you get this working?
There was a problem hiding this comment.
It might be your renaming away the spaces in the filenames. It probably needs the space before the "Text" for the text fonts, see https://github.com/Jojo-Schmitz/MuseScore/pull/82/files#diff-9e3816e63546943283fc7dc1cebdb8edfd0d1ca4bb2f0713a3cfe607308a5ff4R3179-R3180
There was a problem hiding this comment.
That does not fix the problem. I checked with FontForge the fonts. The dynamics are in the main font, not in the text font. All present with the correct code, e.g. E52F for ff.
In a local debug build, i see this error: /MuseScore/libmscore/sym.cpp:Ms::ScoreFont::draw: ScoreFont::draw: invalid sym 0 (not sure it is related)
sym.cpp:
if (!isValid(id)) {
if (MScore::useFallbackFont && this != ScoreFont::fallbackFont())
fallbackFont()->draw(id, painter, mag, pos, worldScale);
else
qDebug("ScoreFont::draw: invalid sym %d", int(id));
return;
}
Anyway, for me no fallback to Bravura, at least not for the dynamics.
If i remove Finale Ash, when opening a score with that font, then fallback to Bravura does work.
There was a problem hiding this comment.
Ok, i have a workaround.
- Change libmscore/sym.h (remove the " Text" extension)
QString correspondingTextFontName() const { return _name; }
QString correspondingTextFontFamily() const { return _family; } - Install the font as a system font.
=> the dynamics from the font are shown.
(does not seem to work with Finale Fonts, but works ok for all others)
This is of course not a real solution....
There was a problem hiding this comment.
This was not such a good idea after all.
How do these dynamics work exactly? Obviously not the same way as other elements.
(I added a json file for AloisenGrooveU.)
There was a problem hiding this comment.
There is obviously something not working in the code, which i don't understand.
But I have a workaround without changing the code.
-open font with FontForge.
Change name to fontnameText , e.g. cap1800Text
Change Family Name and Name for Humans to "fontname Text" e.g. "cap1800 Text"

Generate Font.
Install the font on the computer as system font.
-You can try with attached cap1800
cap1800Text.zip
|
|
||
| qDebug() << "Found" << userfonts.count() << "user score fonts."; | ||
|
|
||
| // TODO: Check for fonts that duplicate built-in fonts |
There was a problem hiding this comment.
Allowing duplicates might even be good, if the external one would override the internal one. That would allow for example to load a newer version of Bravura, Leland, without needing to rebuild.
Doesn't even need to override, so you can quickly change between the duplicates and compare.
| } | ||
|
|
||
| _allScoreFonts = _builtinScoreFonts; | ||
| _allScoreFonts << _userScoreFonts; |
There was a problem hiding this comment.
A sepaparator between the builtin fonts and the user fonts would be nice
34c7bef to
ae8bf72
Compare
|
Hey Jojo, to be sure, check to see after making use of a custom font if this thing exports well into PDF/SVG. If I remember correctly, it did not for some fonts (it didn't save the font into it and resulted in rectangles everywhere). Has to do with font-family stuff. If it turns out not to work, I've got a fix somewhere in my local build and can send the code over your way |
|
I tried all existing free smufl fonts, and all exported correctly to pdf. |
sounds good |
|
Nevertheless, there are problems with the code. Also, when uploading to musescore.com, tempo looks like" [?] = 120" => the 1/4 note missing and a box displayed. |
|
The failing tests are indeed worrying me and are keeping me from merging the PR |
ae8bf72 to
967d702
Compare
|
In https://w3c.github.io/smufl/latest/specification/font-metadata-locations.html we find recommendations where SMuFL fonts and metadata files should be stored and being searched for, and how the metadata files should be called. Seems to make up for a pretty good change to this PR, so I've now implemented it |
fb40c92 to
59d9491
Compare
ef71657 to
686ee93
Compare
d7ecc2f to
fca793b
Compare
|
Seems I found a fix for the mtest failures, I'm just not sure whether it is just band aid... followed by another crash... |
fca793b to
a95c2be
Compare
|
@cbjeukendrup That mtest fix might be the last missing part for your https://github.com/cbjeukendrup/MuseScore/tree/custom-music-fonts to make it into Mu4. Maybe someone can come up with a better fix though, one that feels less like band aid... |
a95c2be to
4034145
Compare
like: * fixing a typo * re-sorting and addting to `Q_INIT_RECOURCES()` to match CMakeLists.txt Match number and order of fonts with CMakeLists.txt * (re-?)initializing `PREF_APP_PATHS_MYSCOREFONTS` to its default and creating the default directry if it doesn't exust
…aces. Partial backport of musescore#17886
b562d46 to
5e8255d
Compare

Shamelessly stolen (from https://github.com/cbjeukendrup/MuseScore/tree/custom-music-fonts, actually rather from. https://github.com/cbjeukendrup/MuseScore/tree/mu3-custom-scorefonts) ;-)