Skip to content

Commit 0e4cdb9

Browse files
committed
notehead metrics
1 parent 4d2df70 commit 0e4cdb9

File tree

10 files changed

+41
-47
lines changed

10 files changed

+41
-47
lines changed

src/annotation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class Annotation extends Modifier {
7373
// words don't run into each other.
7474
static get minAnnotationPadding(): number {
7575
const musicFont = Tables.currentMusicFont();
76-
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
76+
return musicFont.lookupMetric('noteHead.minPadding');
7777
}
7878
/** Arrange annotations within a `ModifierContext` */
7979
static format(annotations: Annotation[], state: ModifierContextState): boolean {

src/chordsymbol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export class ChordSymbol extends Modifier {
270270

271271
static get minPadding(): number {
272272
const musicFont = Tables.currentMusicFont();
273-
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
273+
return musicFont.lookupMetric('noteHead.minPadding');
274274
}
275275
/**
276276
* Estimate the width of the whole chord symbol, based on the sum of the widths of the individual blocks.

src/font.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ChordSymbolMetrics } from './chordsymbol';
2+
import { NoteHeadMetrics } from './notehead';
23
import { OrnamentMetrics } from './ornament';
34
import { StringNumberMetrics } from './stringnumber';
45
import { defined } from './util';
@@ -43,10 +44,9 @@ export interface FontMetrics extends Record<string, any> {
4344
// Not specified in gonville_metrics.ts.
4445
articulation?: Record<string, Record<string, number>>;
4546
tremolo?: Record<string, Record<string, number>>;
46-
// Not specified in bravura_metrics.ts or gonville_metrics.ts.
47-
noteHead?: Record<string, Record<string, number>>;
4847
chordSymbol?: ChordSymbolMetrics;
4948
ornament?: Record<string, OrnamentMetrics>;
49+
noteHead?: NoteHeadMetrics;
5050
stringNumber?: StringNumberMetrics;
5151
// eslint-disable-next-line
5252
glyphs: Record<string, Record<string, any>>;

src/fonts/bravura_metrics.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@ export const BravuraMetrics = {
308308
},
309309
},
310310

311-
// noteHead: {
312-
// },
311+
noteHead: {
312+
minPadding: 2,
313+
},
313314

314315
stem: {
315316
heightAdjustmentForFlag: -3,
@@ -493,14 +494,11 @@ export const BravuraMetrics = {
493494
},
494495
},
495496
noteHead: {
496-
minPadding: 2,
497-
standard: {
498-
restQuarterStemUp: {
499-
point: 35,
500-
},
501-
restQuarterStemDown: {
502-
point: 35,
503-
},
497+
restQuarterStemUp: {
498+
point: 35,
499+
},
500+
restQuarterStemDown: {
501+
point: 35,
504502
},
505503
},
506504
chordSymbol: {

src/fonts/gonville_metrics.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@ export const GonvilleMetrics = {
299299
},
300300
},
301301

302-
// noteHead: {
303-
// },
302+
noteHead: {
303+
minPadding: 2,
304+
},
304305

305306
stem: {
306307
heightAdjustmentForFlag: -3,
@@ -392,9 +393,6 @@ export const GonvilleMetrics = {
392393
shiftY: 4,
393394
},
394395
},
395-
noteHead: {
396-
minPadding: 2,
397-
},
398396
chordSymbol: {
399397
csymDiminished: {
400398
scale: 0.8,

src/fonts/leland_metrics.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,9 @@ export const LelandMetrics = {
304304
},
305305
},
306306

307-
// noteHead: {
308-
// },
307+
noteHead: {
308+
minPadding: 2,
309+
},
309310

310311
stem: {
311312
heightAdjustmentForFlag: -3,
@@ -489,14 +490,11 @@ export const LelandMetrics = {
489490
},
490491
},
491492
noteHead: {
492-
minPadding: 2,
493-
standard: {
494-
restQuarterStemUp: {
495-
point: 35,
496-
},
497-
restQuarterStemDown: {
498-
point: 35,
499-
},
493+
restQuarterStemUp: {
494+
point: 35,
495+
},
496+
restQuarterStemDown: {
497+
point: 35,
500498
},
501499
},
502500
chordSymbol: {

src/fonts/petaluma_metrics.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,8 @@ export const PetalumaMetrics = {
308308
},
309309

310310
noteHead: {
311-
displaced: {
312-
shiftX: -2,
313-
},
311+
minPadding: 2,
312+
displacedShiftX: -2,
314313
},
315314

316315
stem: {
@@ -513,17 +512,14 @@ export const PetalumaMetrics = {
513512
},
514513
},
515514
noteHead: {
516-
minPadding: 2,
517-
standard: {
518-
noteheadBlackStemUp: {
519-
shiftX: 0.5,
520-
},
521-
noteheadHalfStemUp: {
522-
shiftX: 0.725,
523-
},
524-
noteheadWholeStemUp: {
525-
shiftX: 1,
526-
},
515+
noteheadBlackStemUp: {
516+
shiftX: 0.5,
517+
},
518+
noteheadHalfStemUp: {
519+
shiftX: 0.725,
520+
},
521+
noteheadWholeStemUp: {
522+
shiftX: 1,
527523
},
528524
},
529525
chordSymbol: {

src/notehead.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ function L(...args: any[]) {
1717
if (NoteHead.DEBUG) log('Vex.Flow.NoteHead', args);
1818
}
1919

20+
export interface NoteHeadMetrics {
21+
minPadding?: number;
22+
displacedShiftX?: number;
23+
}
2024
export interface NoteHeadStruct extends NoteStruct {
2125
line?: number;
2226
glyph_font_scale?: number;
@@ -217,7 +221,7 @@ export class NoteHead extends Note {
217221
const displacementStemAdjustment = Stem.WIDTH / 2;
218222
const musicFont = Tables.currentMusicFont();
219223
const fontShift = musicFont.lookupMetric('notehead.shiftX', 0) * this.stem_direction;
220-
const displacedFontShift = musicFont.lookupMetric('noteHead.displaced.shiftX', 0) * this.stem_direction;
224+
const displacedFontShift = musicFont.lookupMetric('noteHead.displacedShiftX', 0) * this.stem_direction;
221225

222226
return (
223227
x +
@@ -290,7 +294,7 @@ export class NoteHead extends Note {
290294
drawSlashNoteHead(ctx, this.duration, head_x, y, stem_direction, staveSpace);
291295
} else {
292296
Glyph.renderGlyph(ctx, head_x, y, glyph_font_scale, this.glyph_code, {
293-
category: `noteHead.standard.${categorySuffix}`,
297+
category: `noteHead.${categorySuffix}`,
294298
});
295299
}
296300
}

src/ornament.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class Ornament extends Modifier {
4141
}
4242
static get minPadding(): number {
4343
const musicFont = Tables.currentMusicFont();
44-
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
44+
return musicFont.lookupMetric('noteHead.minPadding');
4545
}
4646

4747
protected ornament: {

src/stavenote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class StaveNote extends StemmableNote {
123123

124124
static get minNoteheadPadding(): number {
125125
const musicFont = Tables.currentMusicFont();
126-
return musicFont.lookupMetric('glyphs.noteHead.minPadding');
126+
return musicFont.lookupMetric('noteHead.minPadding');
127127
}
128128

129129
/** Format notes inside a ModifierContext. */

0 commit comments

Comments
 (0)