Skip to content

Commit

Permalink
Add additional padding to left of accidentals
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronDavidNewman committed Jun 14, 2021
1 parent 4e6df4f commit 67a7f45
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/accidental.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ export class Accidental extends Modifier {

// Arrange accidentals inside a ModifierContext.
static format(accidentals, state) {
const noteheadAccidentalPadding = 1;
const musicFont = Flow.DEFAULT_FONT_STACK[0];
const noteheadAccidentalPadding = musicFont.lookupMetric('accidental.noteheadAccidentalPadding');
const leftShift = state.left_shift + noteheadAccidentalPadding;
const accidentalSpacing = 3;
const accidentalSpacing = musicFont.lookupMetric('accidental.accidentalSpacing');
const additionalPadding = musicFont.lookupMetric('accidental.leftPadding'); // padding to the left of all accidentals

// If there are no accidentals, we needn't format their positions
if (!accidentals || accidentals.length === 0) return;
Expand Down Expand Up @@ -298,7 +300,7 @@ export class Accidental extends Modifier {
});

// update the overall layout with the full width of the accidental shapes:
state.left_shift += totalShift;
state.left_shift += totalShift + additionalPadding;
}

// Helper function to determine whether two lines of accidentals collide vertically
Expand Down
6 changes: 5 additions & 1 deletion src/fonts/bravura_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export const BravuraMetrics = {
endPaddingMax: 10,
endPaddingMin: 5
},

accidental: {
noteheadAccidentalPadding: 1,
leftPadding: 2,
accidentalSpacing: 3
},
clef: {
default: {
point: 32,
Expand Down
6 changes: 5 additions & 1 deletion src/fonts/gonville_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export const GonvilleMetrics = {
endPaddingMax: 10,
endPaddingMin: 5
},

accidental: {
noteheadAccidentalPadding: 1,
leftPadding: 2,
accidentalSpacing: 3
},
clef: {
default: {
point: 40,
Expand Down
6 changes: 5 additions & 1 deletion src/fonts/petaluma_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ export const PetalumaMetrics = {
endPaddingMax: 15,
endPaddingMin: 7
},

accidental: {
noteheadAccidentalPadding: 1,
leftPadding: 2,
accidentalSpacing: 3
},
clef: {
default: {
point: 32,
Expand Down

0 comments on commit 67a7f45

Please sign in to comment.