Investigate whether other music fonts work
In theory we should support any SMuFL-compliant music font, but we've only ever worked with and tested against Bravura. We should try out some other fonts and see what breaks.
https://github.com/fkretlow/sebastian sebastian (Bach) looks like a good one to test.
music fonts can be registered with neoscore.register_music_font
I don't think so, unless we want to bundle the new font in the repo. I'm open to it, but only if user demand is enough to warrant increasing the package size. This ticket is more about manually testing out examples with other SMuFL-compliant fonts and seeing if anything breaks or looks wrong. I expect bugs would surface and we'd want to spin off separate issues for this.
That said, I think @craigvear has been chipping away at this, so if you want to take a crack at it we should confirm with him first. Craig, what do you think?
Hi both. I did have a little trial with Sebastian font, but then got distracted with other priorities. @jgarte please do have a play with it.
And thanks for all you help with this @jgarte truly appreciated.
@craigvear @ajyoon
- What are the steps involved in properly testing other music fonts?
- How many do we want to test in total in order to close this issue?
I think the basic process would be something like..
- Download one or two SMuFL-compliant fonts (maybe Sebastian and Petaluma would be good?)
- Try modifying some of the provided repo examples to register the new music font and then update the examples to use the new fonts. Music fonts are automatically inherited from objects' ancestor chains with the
HasMusicFontmixin, so updating the font requires working out where the font is being inherited from when not explicitly provided. In staff contexts, all fonts are usually inherited from the staff, whose font family defaults to Bravura. Staff font families can be changed simply with themusic_font_familyarg in the constructor. - Take notes of anything that breaks, anything confusing (for documentation improvements), anything awkward about the API (for potential library improvements), and report back here.
Once we know this functionality works, we'll update the documentation to describe the process, but that will be a separate ticket.
We might want to consider adding a way to globally change the default music font (maybe the global default text font too), but that would be a separate ticket down the line too.
Just noticed that there are some clipping issues with the Bravura font when used in a Text object:

Here's the code used to generate this image:
from neoscore.common import *
neoscore.setup()
lowercase_alphabet = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
uppercase_alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
other = ["`", "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "=", "+", "[", "{", "]", "}", ";", ":",
"'", "\"", ",", "<", ".", ">", "/", "?", "\\", "|"]
for index, text in enumerate(lowercase_alphabet):
Text((Unit(0), Unit(index*10)), None, text, Font("Bravura", (index % 7)+5))
for index, text in enumerate(uppercase_alphabet):
Text((Unit(20), Unit(index*10)), None, text, Font("Bravura", (index % 7)+5))
for index, text in enumerate(numbers):
Text((Unit(40), Unit(index*10)), None, text, Font("Bravura", (index % 7)+5))
for index, text in enumerate(other):
Text((Unit(60), Unit(index*10)), None, text, Font("Bravura", (index % 7)+5))
neoscore.set_viewport_scale(8)
neoscore.show()
Thanks for reporting that, I've noticed similar issues with other fonts and plaint Text objects before too. If I remember right, the issue affects different environments differently since it relies on low-level text layout systems. I'll try to take a look this week.
I built a little example demonstrating this capability and tested it locally. I found one small bug and fixed it in the above commit.
Sebastian:

Bravura:
(don't mind the broken trill appearance, that's because I used the wrong glyph for it)