Skip to content

Commit

Permalink
notehead metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
rvilarl committed Dec 13, 2022
1 parent 4d2df70 commit 0e4cdb9
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Annotation extends Modifier {
// words don't run into each other.
static get minAnnotationPadding(): number {
const musicFont = Tables.currentMusicFont();
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
return musicFont.lookupMetric('noteHead.minPadding');
}
/** Arrange annotations within a `ModifierContext` */
static format(annotations: Annotation[], state: ModifierContextState): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/chordsymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class ChordSymbol extends Modifier {

static get minPadding(): number {
const musicFont = Tables.currentMusicFont();
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
return musicFont.lookupMetric('noteHead.minPadding');
}
/**
* Estimate the width of the whole chord symbol, based on the sum of the widths of the individual blocks.
Expand Down
4 changes: 2 additions & 2 deletions src/font.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ChordSymbolMetrics } from './chordsymbol';
import { NoteHeadMetrics } from './notehead';
import { OrnamentMetrics } from './ornament';
import { StringNumberMetrics } from './stringnumber';
import { defined } from './util';
Expand Down Expand Up @@ -43,10 +44,9 @@ export interface FontMetrics extends Record<string, any> {
// Not specified in gonville_metrics.ts.
articulation?: Record<string, Record<string, number>>;
tremolo?: Record<string, Record<string, number>>;
// Not specified in bravura_metrics.ts or gonville_metrics.ts.
noteHead?: Record<string, Record<string, number>>;
chordSymbol?: ChordSymbolMetrics;
ornament?: Record<string, OrnamentMetrics>;
noteHead?: NoteHeadMetrics;
stringNumber?: StringNumberMetrics;
// eslint-disable-next-line
glyphs: Record<string, Record<string, any>>;
Expand Down
18 changes: 8 additions & 10 deletions src/fonts/bravura_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ export const BravuraMetrics = {
},
},

// noteHead: {
// },
noteHead: {
minPadding: 2,
},

stem: {
heightAdjustmentForFlag: -3,
Expand Down Expand Up @@ -493,14 +494,11 @@ export const BravuraMetrics = {
},
},
noteHead: {
minPadding: 2,
standard: {
restQuarterStemUp: {
point: 35,
},
restQuarterStemDown: {
point: 35,
},
restQuarterStemUp: {
point: 35,
},
restQuarterStemDown: {
point: 35,
},
},
chordSymbol: {
Expand Down
8 changes: 3 additions & 5 deletions src/fonts/gonville_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ export const GonvilleMetrics = {
},
},

// noteHead: {
// },
noteHead: {
minPadding: 2,
},

stem: {
heightAdjustmentForFlag: -3,
Expand Down Expand Up @@ -392,9 +393,6 @@ export const GonvilleMetrics = {
shiftY: 4,
},
},
noteHead: {
minPadding: 2,
},
chordSymbol: {
csymDiminished: {
scale: 0.8,
Expand Down
18 changes: 8 additions & 10 deletions src/fonts/leland_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ export const LelandMetrics = {
},
},

// noteHead: {
// },
noteHead: {
minPadding: 2,
},

stem: {
heightAdjustmentForFlag: -3,
Expand Down Expand Up @@ -489,14 +490,11 @@ export const LelandMetrics = {
},
},
noteHead: {
minPadding: 2,
standard: {
restQuarterStemUp: {
point: 35,
},
restQuarterStemDown: {
point: 35,
},
restQuarterStemUp: {
point: 35,
},
restQuarterStemDown: {
point: 35,
},
},
chordSymbol: {
Expand Down
24 changes: 10 additions & 14 deletions src/fonts/petaluma_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,8 @@ export const PetalumaMetrics = {
},

noteHead: {
displaced: {
shiftX: -2,
},
minPadding: 2,
displacedShiftX: -2,
},

stem: {
Expand Down Expand Up @@ -513,17 +512,14 @@ export const PetalumaMetrics = {
},
},
noteHead: {
minPadding: 2,
standard: {
noteheadBlackStemUp: {
shiftX: 0.5,
},
noteheadHalfStemUp: {
shiftX: 0.725,
},
noteheadWholeStemUp: {
shiftX: 1,
},
noteheadBlackStemUp: {
shiftX: 0.5,
},
noteheadHalfStemUp: {
shiftX: 0.725,
},
noteheadWholeStemUp: {
shiftX: 1,
},
},
chordSymbol: {
Expand Down
8 changes: 6 additions & 2 deletions src/notehead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function L(...args: any[]) {
if (NoteHead.DEBUG) log('Vex.Flow.NoteHead', args);
}

export interface NoteHeadMetrics {
minPadding?: number;
displacedShiftX?: number;
}
export interface NoteHeadStruct extends NoteStruct {
line?: number;
glyph_font_scale?: number;
Expand Down Expand Up @@ -217,7 +221,7 @@ export class NoteHead extends Note {
const displacementStemAdjustment = Stem.WIDTH / 2;
const musicFont = Tables.currentMusicFont();
const fontShift = musicFont.lookupMetric('notehead.shiftX', 0) * this.stem_direction;
const displacedFontShift = musicFont.lookupMetric('noteHead.displaced.shiftX', 0) * this.stem_direction;
const displacedFontShift = musicFont.lookupMetric('noteHead.displacedShiftX', 0) * this.stem_direction;

return (
x +
Expand Down Expand Up @@ -290,7 +294,7 @@ export class NoteHead extends Note {
drawSlashNoteHead(ctx, this.duration, head_x, y, stem_direction, staveSpace);
} else {
Glyph.renderGlyph(ctx, head_x, y, glyph_font_scale, this.glyph_code, {
category: `noteHead.standard.${categorySuffix}`,
category: `noteHead.${categorySuffix}`,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ornament.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class Ornament extends Modifier {
}
static get minPadding(): number {
const musicFont = Tables.currentMusicFont();
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
return musicFont.lookupMetric('noteHead.minPadding');
}

protected ornament: {
Expand Down
2 changes: 1 addition & 1 deletion src/stavenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class StaveNote extends StemmableNote {

static get minNoteheadPadding(): number {
const musicFont = Tables.currentMusicFont();
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
return musicFont.lookupMetric('noteHead.minPadding');
}

/** Format notes inside a ModifierContext. */
Expand Down

0 comments on commit 0e4cdb9

Please sign in to comment.