Selaa lähdekoodia

fix(part names): drawPartNames = false does not leave left x-spacing in first line anymore

fix #515
sschmid 6 vuotta sitten
vanhempi
commit
595f8ab5a2

+ 8 - 4
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -1591,18 +1591,22 @@ export abstract class MusicSheetCalculator {
     }
 
     protected maxInstrNameLabelLength(): number {
-        if (!EngravingRules.Rules.RenderPartNames) {
-            return 0;
-        }
         let maxLabelLength: number = 0.0;
         for (const instrument of this.graphicalMusicSheet.ParentMusicSheet.Instruments) {
             if (instrument.Voices.length > 0 && instrument.Voices[0].Visible) {
+                let renderedLabel: Label = instrument.NameLabel;
+                if (!EngravingRules.Rules.RenderPartNames) {
+                    renderedLabel = new Label("", renderedLabel.textAlignment, renderedLabel.font);
+                }
                 const graphicalLabel: GraphicalLabel = new GraphicalLabel(
-                    instrument.NameLabel, this.rules.InstrumentLabelTextHeight, TextAlignmentEnum.LeftCenter);
+                    renderedLabel, this.rules.InstrumentLabelTextHeight, TextAlignmentEnum.LeftCenter);
                 graphicalLabel.setLabelPositionAndShapeBorders();
                 maxLabelLength = Math.max(maxLabelLength, graphicalLabel.PositionAndShape.MarginSize.width);
             }
         }
+        if (!EngravingRules.Rules.RenderPartNames) {
+            return 0;
+        }
         return maxLabelLength;
     }
 

+ 4 - 0
src/MusicalScore/Graphical/MusicSystem.ts

@@ -297,6 +297,10 @@ export abstract class MusicSystem extends GraphicalObject {
                     instrNameLabel = new Label(labelText, instrument.NameLabel.textAlignment, instrument.NameLabel.font);
                 } else {
                     instrNameLabel = instrument.NameLabel;
+                    if (!EngravingRules.Rules.RenderPartNames) {
+                        instrNameLabel = new Label("", instrument.NameLabel.textAlignment, instrument.NameLabel.font);
+                        systemLabelsRightMargin = 0; // might affect lyricist/tempo placement. but without this there's still some extra x-spacing.
+                    }
                 }
                 const graphicalLabel: GraphicalLabel = new GraphicalLabel(
                     instrNameLabel, instrumentLabelTextHeight, TextAlignmentEnum.LeftCenter, this.boundingBox

+ 5 - 7
src/MusicalScore/Graphical/MusicSystemBuilder.ts

@@ -230,13 +230,11 @@ export class MusicSystemBuilder {
     }
 
     private addSystemLabels(): void {
-        if (EngravingRules.Rules.RenderPartNames) {
-            this.currentSystemParams.currentSystem.createMusicSystemLabel(
-                this.rules.InstrumentLabelTextHeight,
-                this.rules.SystemLabelsRightMargin,
-                this.rules.LabelMarginBorderFactor
-            );
-        }
+        this.currentSystemParams.currentSystem.createMusicSystemLabel(
+            this.rules.InstrumentLabelTextHeight,
+            this.rules.SystemLabelsRightMargin,
+            this.rules.LabelMarginBorderFactor
+        );
     }
 
     /**