Skip to content

[MU3] Add the possibility to use custom ScoreFonts#82

Merged
Jojo-Schmitz merged 4 commits into
3.xfrom
custom-fonts
Jul 5, 2023
Merged

[MU3] Add the possibility to use custom ScoreFonts#82
Jojo-Schmitz merged 4 commits into
3.xfrom
custom-fonts

Conversation

@Jojo-Schmitz

Copy link
Copy Markdown
Owner

@Jojo-Schmitz

Copy link
Copy Markdown
Owner Author

@cbjeukendrup: any idea why almost all mtests crash?

@cbjeukendrup

Copy link
Copy Markdown

I'm afraid I won't have time to look into this very soon, but I'll add it to my list :)

@diedeno

diedeno commented Mar 7, 2023

Copy link
Copy Markdown

Howto use custom Scorefonts.

-create new directory 'ScoreFonts', on the same level as Scores, Plugins, SoundFonts ..
-check Edit/.Preferences/Folders if path to ScoreFonts is correct (a space in name gives problems in Linux)
-get a Smufl compatible font (e.g. Leipzig, Sebastian, legato, ...)
-make a directory for each font with it's name, e.g.:
├── legato
│   ├── Legato.otf
│   └── metadata.json
You need the font (otf or ttf) and a json file. Rename the json file to "metadata.json"
Restart MuseScore.
You should be able to select the newly installed font via Format/Style/Score/Musical Symbols Font.
If there is no txt font available, you can always choose the text font from another package
If there are spaces in the font name (e.g; Golden Age), remove them as this does not work under Linux.
e.g.
├── goldenage
│   ├── GoldenAge.otf
│   └── metadata.json

Standard Music Font Layout (SMuFL) compatible Fonts.

SIL Font Licence

Sebastian by Florian Kretlow
https://github.com/fkretlow/sebastian/releases

Leipzig (verovio)
https://github.com/rism-digital/verovio/tree/develop/fonts

Finale Smufl Fonts:
Finale Maestro
Finale Broadway
Finale Ash
Finale Engraver
Finale Jazz
Finale Legacy
Finale Maestro Text
Finale Broadway Legacy Text
Finale Broadway Text
Finale Ash Text
Finale Lyrics
Finale Jazz Text
https://makemusic.zendesk.com/hc/en-us/articles/1500013053461-MakeMusic-Fonts-and-Licensing-Information

GoldenAge
https://github.com/benwiggy/GoldenAge

eNote legato
https://github.com/eNote-GmbH/Legato

Ekmelos
http://www.ekmelic-music.org/en/extra/ekmelos.htm
(should be smufl compliant, but does not work correctly on my system)

Free (unknown licence)

Cap1800
remapped by Nor Eddine Bahha (Norfonts)
download cap1800.zip from https://forums.steinberg.net/t/1800-style-font/763178/6

Commercial Fonts

Norfonts:
https://norfonts.ma/en/product-tag/dorico/

November 2.
https://www.klemm-music.de/notation/november2/en/index.php

Music Type Foundry.
Abraham Lee used to sell Smufl versions of his Lilypond fonts. Personal licences were available at $1.
MTF Arnold
MTF Beethoven
MTF Cadence
MTF Haydn
MTF Scorlatti
Also sold LS Iris by Luis Salgueiro
But the business closed down.
It seems the fonts cannot be obtained anymore.

Copyrighted:

AloisenU and AloisenGrooveU
Fonts used in Overture. No official support for other apps. You’ll have to download the app to get the font, and no JSON file provided.
A json file can be downloaded here: https://notat.io/viewtopic.php?t=259&start=10 => does not work
Try the attached ones

aloisenu_json.zip

AloisenGrooveU_json.zip

@Jojo-Schmitz

Jojo-Schmitz commented Mar 7, 2023

Copy link
Copy Markdown
Owner Author

Great stuff, thanks a lot!

image

Spaces in filenames are not an issue on Windows BTW.

Comment thread libmscore/sym.cpp Outdated
}
}

bool hasMetadataFile = QFileInfo::exists(fontDirPath + "metadata.json");

@Jojo-Schmitz Jojo-Schmitz Mar 7, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@diedeno diedeno Mar 7, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correction: Bravura has only one metadata.json file for Bravura.otf and BravuraText.otf. so it should be possible.

@Jojo-Schmitz Jojo-Schmitz Mar 7, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@Jojo-Schmitz Jojo-Schmitz Mar 8, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i have a workaround.

  1. Change libmscore/sym.h (remove the " Text" extension)
    QString correspondingTextFontName() const { return _name; }
    QString correspondingTextFontFamily() const { return _family; }
  2. 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....

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.)

@diedeno diedeno Mar 12, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
cap1800
Generate Font.
Install the font on the computer as system font.

-You can try with attached cap1800
cap1800Text.zip

Comment thread libmscore/sym.cpp

qDebug() << "Found" << userfonts.count() << "user score fonts.";

// TODO: Check for fonts that duplicate built-in fonts

@Jojo-Schmitz Jojo-Schmitz Mar 7, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread libmscore/sym.cpp Outdated
}

_allScoreFonts = _builtinScoreFonts;
_allScoreFonts << _userScoreFonts;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sepaparator between the builtin fonts and the user fonts would be nice

@worldwideweary

Copy link
Copy Markdown
Collaborator

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

@diedeno

diedeno commented Apr 9, 2023

Copy link
Copy Markdown

I tried all existing free smufl fonts, and all exported correctly to pdf.

@worldwideweary

Copy link
Copy Markdown
Collaborator

I tried all existing free smufl fonts, and all exported correctly to pdf.

sounds good

@diedeno

diedeno commented Apr 9, 2023

Copy link
Copy Markdown

Nevertheless, there are problems with the code.
e.g.
-the Text fonts (reverts to Bravura( or Leland) on Windows, on Linux just shows some 'hand' glyphs) see above
-linux bug: directories must be lowercase, without spaces
-some errors in tests

Also, when uploading to musescore.com, tempo looks like" [?] = 120" => the 1/4 note missing and a box displayed.

@Jojo-Schmitz

Copy link
Copy Markdown
Owner Author

The failing tests are indeed worrying me and are keeping me from merging the PR
The other issue you mention too, but I don't see them myself

@Jojo-Schmitz

Jojo-Schmitz commented Apr 22, 2023

Copy link
Copy Markdown
Owner Author

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

@Jojo-Schmitz
Jojo-Schmitz force-pushed the custom-fonts branch 3 times, most recently from fb40c92 to 59d9491 Compare April 24, 2023 18:31
@Jojo-Schmitz
Jojo-Schmitz force-pushed the 3.x branch 2 times, most recently from ef71657 to 686ee93 Compare May 15, 2023 12:08
@Jojo-Schmitz
Jojo-Schmitz force-pushed the custom-fonts branch 2 times, most recently from d7ecc2f to fca793b Compare June 10, 2023 18:28
@Jojo-Schmitz

Jojo-Schmitz commented Jun 10, 2023

Copy link
Copy Markdown
Owner Author

Seems I found a fix for the mtest failures, I'm just not sure whether it is just band aid...
Before moving that preferences.init(true) to before the mscore->init() (and after having disabled some Q_ASSERT()s to prevent it from crashing, which almost all mtests apparently did) I got this:

Config: Using QtTest library 5.15.2, Qt 5.15.2 (x86_64-little_endian-llp64 shared (dynamic) release build; by GCC 8.1.0), windows 10
QDEBUG : TestTools::initTestCase() Ms::Preferences::checkType: Preference is not of correct type: application/paths/myScoreFonts
QDEBUG : TestTools::initTestCase() Ms::Preferences::checkIfKeyExists: Preference not found: application/paths/myScoreFonts
QDEBUG : TestTools::initTestCase() Ms::Preferences::settings: Preferences are not initialized. Call init() to initialize.

followed by another crash...

@Jojo-Schmitz

Copy link
Copy Markdown
Owner Author

@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...

 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
@Jojo-Schmitz
Jojo-Schmitz force-pushed the custom-fonts branch 3 times, most recently from b562d46 to 5e8255d Compare June 16, 2023 11:46
@Jojo-Schmitz
Jojo-Schmitz merged commit b7f6faa into 3.x Jul 5, 2023
@Jojo-Schmitz
Jojo-Schmitz deleted the custom-fonts branch July 5, 2023 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants