Closed craigsapp closed 2 years ago
Used to work in 3.8.1
Notice that the clef glyph in 3.8.1 does seem to be the same as the Leipzig font glyphs, so it does seem likely to be related to font substitutions not being included in the SVG <defs>
.
@craigsapp have a coffee first, it seems to be early for you 🤣
@craigsapp and @lpugin: thank you both so much for looking in to this! In case it is helpful, I can say that this bug/regression occurred between Sunday and Monday CET.
I suspect that it is related to this PR: https://github.com/rism-digital/verovio/pull/2626
This line is a manifestation of the problem:
When there is no glyph for a given font, there will be no contents at that path name, so it will not be inserted into the SVG <defs>
section.
the variable m_smuflGlyphs
that is being iterated through around that line has information about all of the glyphs. For the test files there are four glyphs E909, E915, E925, E93C. The Leland font only has E93C available (in the most recent devel which I have double checked was installed on the system), so that is the only glyph being inserted into the SVG <defs>
by the above code.
m_smuflGlyphs
is being filled within the function SvgDeviceContext::DrawMusicText()
:
Line 903:
Glyph *glyph = Resources::GetGlyph(c);
Is loading the glyph information that is stored in m_smuflGlyphs
. This reads the glyph from the variable s_fontGlyphTable
which is filled in within the function Resources::LoadFont()
:
This function is in turn called from Resources::InitFonts()
:
And this function is where the font overlay system is being implemented: On line 85, the Bravura font is being loaded as the base font, then on line 87, the Leipzig font is being loaded as the backup base font.
Then in tools/main.cpp
, a final font will be loaded on top of these two base fonts:
Perhaps for efficiency, there should be a check for if the font is being set to Leipzig, and if so, do not load it a second time since it is already loaded in the InitFont()
function.
So when writing glyphs to the SVG <defs>
: if there is no glyph for a given code point in the desired font, the fallback font of Leipzig should be checked next, and if no glyph in Leipzig, then check in the Bravura font for a last resort font substitution.
Ideally the glyphs should be loaded when the fonts are loaded in main.cpp (Resources::LoadFont
) and/or the source font should be recorded for each glyph in a parallel table to s_fontGlyphTable
so that the svgdevicecontext.cpp code that writes the SVG <defs>
does not need to do the same font overlay process (which needs to be coordinated with the code in tools/main.cpp if it changes).
The new SMuFL code seems to be not fully implementing font overlays (meaning that if a font does not have a particular glyph, a fallback glyph from another font is used as a substitute). The problem seems to be happening at the last stage where glyphs are inserted into the SVG
<defs>
element. In the tests below, notice that the glyph references are being used in the Leland output, but the glyphs for clef and mensuration are not being added to the SVG<defs>
element.The Leland font should have these glyphs (at least the clef), but perhaps the verovio does not include all of Leland? Rendering the same data in Bravura and Leipzig show the clef and mensuration as demonstrated below. The font metrics for the missing glyphs seem to be known by verovio, because in the Leland example, space is left for the missing glyphs. SVG code is added after each rendering for examination.
This problem started very recently (which is why I suspect the new dynamic SMuFL font handling system that is being mentioned in the PRs).
Click to view MEI data used to generate the following renderings.
```xmlTranscoded from Humdrum
The SVG output contains a
g@class="mensur"
entry, but there is no glyph in<defs>
for Cut-C sign. Here is the mensur code in the following SVG output using the Leland font:Glyphs E915 and E925 are being referenced, but notice in the defs section, these glyphs are not included:
Click to view SVG output with Leland font.
```xml ```Click to view SVG output with Bravura font.
```xmlNotice that the
<defs>
section is filled in with more than one glyph now.Click to view SVG output with Leipzig font.
```xml