diff --git a/fonts/gootville/metadata.json b/fonts/gootville/metadata.json index 38d1adca2d68e..c7d3a3c1e2215 100644 --- a/fonts/gootville/metadata.json +++ b/fonts/gootville/metadata.json @@ -6587,7 +6587,7 @@ -0.168 ], "stemUpSE": [ - 1.18, + 1.26, 0.168 ] }, @@ -7091,7 +7091,7 @@ -0.168 ], "stemUpSE": [ - 1.18, + 1.26, 0.168 ] }, @@ -8472,4 +8472,4 @@ ] } } -} \ No newline at end of file +} diff --git a/fonts/mscore/metadata.json b/fonts/mscore/metadata.json index 90e632d2ae689..28e399f9a7ad8 100644 --- a/fonts/mscore/metadata.json +++ b/fonts/mscore/metadata.json @@ -978,7 +978,7 @@ -0.2347675 ], "stemUpSE": [ - 1.6452225, + 1.3152225, 0.2347675 ] }, @@ -1256,7 +1256,7 @@ -0.196 ], "stemUpSE": [ - 1.364, + 1.387, 0.192 ] }, diff --git a/libmscore/stem.cpp b/libmscore/stem.cpp index d3177b9d7ba47..cab4cc807a7ea 100644 --- a/libmscore/stem.cpp +++ b/libmscore/stem.cpp @@ -80,11 +80,10 @@ qreal Stem::stemLen() const void Stem::layout() { - qreal l = _len + _userLen; - qreal _up = up() ? -1.0 : 1.0; - l *= _up; - - qreal y1 = 0.0; // vertical displacement to match note attach point + qreal _up = up() ? -1.0 : 1.0; + qreal l = (_len + _userLen) * _up; + qreal x = 0.0; // horizontal displacement to match note attach point + qreal y1 = 0.0; // vertical displacement to match note attach point const Staff* stf = staff(); if (chord()) { setMag(chord()->mag()); @@ -106,18 +105,66 @@ void Stem::layout() } else { // non-TAB // move stem start to note attach point - Note* n = up() ? chord()->downNote() : chord()->upNote(); - if ((up() && !n->mirror()) || (!up() && n->mirror())) - y1 += n->stemUpSE().y(); - else - y1 += n->stemDownNW().y(); + bool u = up(); + Note* n = u ? chord()->downNote() : chord()->upNote(); + bool m = n->mirror(); + qreal lw = lineWidthMag(); + SymId symId = n->noteHead(); + if ((u && !m) || (!u && m)) { + // default offsets for all fonts, fits for most + x = n->stemUpSE().x() - 0.5 * lw; + y1 = n->stemUpSE().y(); + if (symId == SymId::noteheadDoubleWhole) { + x += n->headWidth(); + y1 -= 0.5 * spatium(); + } + // some fonts' qlyphs need special treatment, suitable offsets found after lots of trial and error + QString muscicalFont = score()->styleSt(Sid::musicalSymbolFont); + if (muscicalFont == "AloisenGrooveU") { + if (symId == SymId::noteheadHalf || symId == SymId::noteheadBlack) + x += n->headWidth() - 0.075 * lw; // sticks out of the notehead a bit, but does so for downstem too + } + else if (muscicalFont == "AloisenU" || muscicalFont == "Bravura") { + if (symId == SymId::noteheadHalf || symId == SymId::noteheadBlack) + x += 1.1 * lw; // apparently these glyphs` stemUpSE cater for stemwidth, but need an extra 0.1 to prevent a slight 'hump' + } +#if 0 // fixing the metadata instead + else if (muscicalFont == "Emmentaler") { + if (symId == SymId::noteheadHalf) + x += 0.2 * lw; // to prevent a slight 'hump', we should be able to fix this in the metadata + else if (symId == SymId::noteheadBlack) + x -= 2.5 * lw; // pure madness, but we should be able to fix this in the metadata + } + else if (muscicalFont == "Gonville") { + if (symId == SymId::noteheadHalf || symId == SymId::noteheadBlack) + x += 0.7 * lw; // we should be able to fix this in the metadata + } +#endif + else if (muscicalFont == "Legato") { + if (symId == SymId::noteheadDoubleWhole) // so far the only font with correct metadata for this notehead + x -= n->headWidth(); + } + else if (muscicalFont == "Petaluma") { + if (symId == SymId::noteheadDoubleWhole) + x -= 0.25 * lw; + else if (symId == SymId::noteheadHalf) + x += 0.25 * lw; + } + } + else { // here all fonts seem to agree; + x = n->stemDownNW().x() + 0.5 * lw; + y1 = n->stemDownNW().y(); + if (symId == SymId::noteheadDoubleWhole) + y1 += 0.5 * spatium(); + } + rxpos() = n->rxpos(); rypos() = n->rypos(); } } qreal lw5 = 0.5 * lineWidthMag(); - line.setLine(0.0, y1, 0.0, l); + line.setLine(x, y1, x, l); // compute bounding rectangle QRectF r(line.p1(), line.p2()); diff --git a/mtest/musicxml/io/testSystemDistance_ref.xml b/mtest/musicxml/io/testSystemDistance_ref.xml index 3cbc4d5a6f6f2..947793ac1cd44 100644 --- a/mtest/musicxml/io/testSystemDistance_ref.xml +++ b/mtest/musicxml/io/testSystemDistance_ref.xml @@ -409,7 +409,7 @@ light-light - + A @@ -431,7 +431,7 @@ up - + A @@ -453,7 +453,7 @@ up - + A @@ -475,7 +475,7 @@ up - + A @@ -497,7 +497,7 @@ up - + A @@ -519,7 +519,7 @@ up - + A @@ -541,7 +541,7 @@ up - + A @@ -563,7 +563,7 @@ up - + A @@ -635,7 +635,7 @@ 1 - + A @@ -676,7 +676,7 @@ 1 - + A @@ -717,7 +717,7 @@ 1 - + A @@ -758,7 +758,7 @@ 1 - + A @@ -799,7 +799,7 @@ 1 - + A @@ -1074,7 +1074,7 @@ 0.00 - -0.00 + 0.00 150.00