@@ -41,6 +41,10 @@ void EngravingCompat::doPreLayoutCompatIfNeeded(MasterScore* score)
4141{
4242 int mscVersion = score->mscVersion ();
4343
44+ if (mscVersion < 470 ) {
45+ adjustTextOffset (score);
46+ }
47+
4448 if (mscVersion < 460 ) {
4549 resetMarkerLeftFontSize (score);
4650 resetRestVerticalOffsets (score);
@@ -233,6 +237,39 @@ void EngravingCompat::adjustVBoxDistances(MasterScore* masterScore)
233237 }
234238}
235239
240+ void EngravingCompat::adjustTextOffset (MasterScore* masterScore)
241+ {
242+ auto doAdjustTextOffset = [](EngravingItem* item) {
243+ if (!item->isTextBase ()) {
244+ return ;
245+ }
246+
247+ TextBase* text = toTextBase (item);
248+
249+ // Staff text, system text, and harp pedal diagrams are the only types which are attached to notes and weren't already
250+ // placed with their left edges / centres / right edges aligned to the left / centre / right of the notehead
251+ if (text->positionRelativeToNoteheadRest () && (text->isStaffText () || text->isSystemText () || text->isHarpPedalDiagram ())) {
252+ double mag = item->staff () ? item->staff ()->staffMag (item) : 1.0 ;
253+ double xAdj = item->symWidth (SymId::noteheadBlack) * mag;
254+
255+ switch (text->position ()) {
256+ case AlignH::HCENTER:
257+ text->setProperty (Pid::OFFSET, PointF (text->offset ().x () - xAdj / 2 , text->offset ().y ()));
258+ break ;
259+ case AlignH::RIGHT:
260+ text->setProperty (Pid::OFFSET, PointF (text->offset ().x () - xAdj, text->offset ().y ()));
261+ break ;
262+ default :
263+ break ;
264+ }
265+ }
266+ };
267+
268+ for (Score* score : masterScore->scoreList ()) {
269+ score->scanElements (doAdjustTextOffset);
270+ }
271+ }
272+
236273void EngravingCompat::doPostLayoutCompatIfNeeded (MasterScore* score)
237274{
238275 bool needRelayout = false ;
0 commit comments