diff --git a/src/annotation.ts b/src/annotation.ts index 14f64ecdda..9274a94b4a 100644 --- a/src/annotation.ts +++ b/src/annotation.ts @@ -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 { diff --git a/src/chordsymbol.ts b/src/chordsymbol.ts index 0206b2b126..4fc03dce92 100644 --- a/src/chordsymbol.ts +++ b/src/chordsymbol.ts @@ -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. diff --git a/src/font.ts b/src/font.ts index 4a09e0a9d3..dd4ab67195 100644 --- a/src/font.ts +++ b/src/font.ts @@ -1,4 +1,5 @@ import { ChordSymbolMetrics } from './chordsymbol'; +import { NoteHeadMetrics } from './notehead'; import { OrnamentMetrics } from './ornament'; import { StringNumberMetrics } from './stringnumber'; import { defined } from './util'; @@ -43,10 +44,9 @@ export interface FontMetrics extends Record { // Not specified in gonville_metrics.ts. articulation?: Record>; tremolo?: Record>; - // Not specified in bravura_metrics.ts or gonville_metrics.ts. - noteHead?: Record>; chordSymbol?: ChordSymbolMetrics; ornament?: Record; + noteHead?: NoteHeadMetrics; stringNumber?: StringNumberMetrics; // eslint-disable-next-line glyphs: Record>; diff --git a/src/fonts/bravura_metrics.ts b/src/fonts/bravura_metrics.ts index 767d65ed75..f9e1aa5e6a 100644 --- a/src/fonts/bravura_metrics.ts +++ b/src/fonts/bravura_metrics.ts @@ -308,8 +308,9 @@ export const BravuraMetrics = { }, }, - // noteHead: { - // }, + noteHead: { + minPadding: 2, + }, stem: { heightAdjustmentForFlag: -3, @@ -493,14 +494,11 @@ export const BravuraMetrics = { }, }, noteHead: { - minPadding: 2, - standard: { - restQuarterStemUp: { - point: 35, - }, - restQuarterStemDown: { - point: 35, - }, + restQuarterStemUp: { + point: 35, + }, + restQuarterStemDown: { + point: 35, }, }, chordSymbol: { diff --git a/src/fonts/gonville_metrics.ts b/src/fonts/gonville_metrics.ts index 5cc3b4003d..b6a6710911 100644 --- a/src/fonts/gonville_metrics.ts +++ b/src/fonts/gonville_metrics.ts @@ -299,8 +299,9 @@ export const GonvilleMetrics = { }, }, - // noteHead: { - // }, + noteHead: { + minPadding: 2, + }, stem: { heightAdjustmentForFlag: -3, @@ -392,9 +393,6 @@ export const GonvilleMetrics = { shiftY: 4, }, }, - noteHead: { - minPadding: 2, - }, chordSymbol: { csymDiminished: { scale: 0.8, diff --git a/src/fonts/leland_metrics.ts b/src/fonts/leland_metrics.ts index 6f467a479a..ac69ab92ad 100644 --- a/src/fonts/leland_metrics.ts +++ b/src/fonts/leland_metrics.ts @@ -304,8 +304,9 @@ export const LelandMetrics = { }, }, - // noteHead: { - // }, + noteHead: { + minPadding: 2, + }, stem: { heightAdjustmentForFlag: -3, @@ -489,14 +490,11 @@ export const LelandMetrics = { }, }, noteHead: { - minPadding: 2, - standard: { - restQuarterStemUp: { - point: 35, - }, - restQuarterStemDown: { - point: 35, - }, + restQuarterStemUp: { + point: 35, + }, + restQuarterStemDown: { + point: 35, }, }, chordSymbol: { diff --git a/src/fonts/petaluma_metrics.ts b/src/fonts/petaluma_metrics.ts index e05d2a39e8..11fcf82c72 100644 --- a/src/fonts/petaluma_metrics.ts +++ b/src/fonts/petaluma_metrics.ts @@ -308,9 +308,8 @@ export const PetalumaMetrics = { }, noteHead: { - displaced: { - shiftX: -2, - }, + minPadding: 2, + displacedShiftX: -2, }, stem: { @@ -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: { diff --git a/src/notehead.ts b/src/notehead.ts index 1e3744ecdc..75f645a587 100644 --- a/src/notehead.ts +++ b/src/notehead.ts @@ -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; @@ -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 + @@ -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}`, }); } } diff --git a/src/ornament.ts b/src/ornament.ts index f4148180f0..ff04afc865 100644 --- a/src/ornament.ts +++ b/src/ornament.ts @@ -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: { diff --git a/src/stavenote.ts b/src/stavenote.ts index c21fd989a3..8f605647ed 100644 --- a/src/stavenote.ts +++ b/src/stavenote.ts @@ -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. */