Skip to content

Commit 94e1eb9

Browse files
committed
tuplet metrics
1 parent 0e4cdb9 commit 94e1eb9

File tree

6 files changed

+43
-27
lines changed

6 files changed

+43
-27
lines changed

src/font.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ChordSymbolMetrics } from './chordsymbol';
22
import { NoteHeadMetrics } from './notehead';
33
import { OrnamentMetrics } from './ornament';
44
import { StringNumberMetrics } from './stringnumber';
5+
import { TupletMetrics } from './tuplet';
56
import { defined } from './util';
67

78
export interface FontInfo {
@@ -48,6 +49,8 @@ export interface FontMetrics extends Record<string, any> {
4849
ornament?: Record<string, OrnamentMetrics>;
4950
noteHead?: NoteHeadMetrics;
5051
stringNumber?: StringNumberMetrics;
52+
tuplet?: TupletMetrics;
53+
5154
// eslint-disable-next-line
5255
glyphs: Record<string, Record<string, any>>;
5356
}

src/fonts/bravura_metrics.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ export const BravuraMetrics = {
363363
rightPadding: 6,
364364
},
365365

366+
tuplet: {
367+
noteHeadOffset: 20,
368+
stemOffset: 10,
369+
bottomLine: 4,
370+
topModifierOffset: 15,
371+
},
372+
366373
// Values under here are used by the Glyph class to reposition and rescale
367374
// glyphs based on their category. This should be the first stop for
368375
// custom font glyph repositioning.
@@ -545,11 +552,5 @@ export const BravuraMetrics = {
545552
scale: 0.9,
546553
},
547554
},
548-
tuplet: {
549-
noteHeadOffset: 20,
550-
stemOffset: 10,
551-
bottomLine: 4,
552-
topModifierOffset: 15,
553-
},
554555
},
555556
};

src/fonts/gonville_metrics.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,13 @@ export const GonvilleMetrics = {
354354
rightPadding: 6,
355355
},
356356

357+
tuplet: {
358+
noteHeadOffset: 20,
359+
stemOffset: 10,
360+
bottomLine: 4,
361+
topModifierOffset: 15,
362+
},
363+
357364
glyphs: {
358365
flag: {
359366
shiftX: -0.08,
@@ -480,11 +487,5 @@ export const GonvilleMetrics = {
480487
shiftY: -5,
481488
},
482489
},
483-
tuplet: {
484-
noteHeadOffset: 20,
485-
stemOffset: 10,
486-
bottomLine: 4,
487-
topModifierOffset: 15,
488-
},
489490
},
490491
};

src/fonts/leland_metrics.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ export const LelandMetrics = {
359359
rightPadding: 6,
360360
},
361361

362+
tuplet: {
363+
noteHeadOffset: 20,
364+
stemOffset: 10,
365+
bottomLine: 4,
366+
topModifierOffset: 15,
367+
},
368+
362369
// Values under here are used by the Glyph class to reposition and rescale
363370
// glyphs based on their category. This should be the first stop for
364371
// custom font glyph repositioning.
@@ -541,11 +548,5 @@ export const LelandMetrics = {
541548
scale: 0.9,
542549
},
543550
},
544-
tuplet: {
545-
noteHeadOffset: 20,
546-
stemOffset: 10,
547-
bottomLine: 4,
548-
topModifierOffset: 15,
549-
},
550551
},
551552
};

src/fonts/petaluma_metrics.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ export const PetalumaMetrics = {
363363
rightPadding: 6,
364364
},
365365

366+
tuplet: {
367+
noteHeadOffset: 20,
368+
stemOffset: 10,
369+
bottomLine: 4,
370+
topModifierOffset: 20,
371+
},
372+
366373
// Values under here are used by the Glyph class to reposition and rescale
367374
// glyphs based on their category. This should be the first stop for
368375
// custom font glyph repositioning.
@@ -566,11 +573,5 @@ export const PetalumaMetrics = {
566573
scale: 0.8,
567574
},
568575
},
569-
tuplet: {
570-
noteHeadOffset: 20,
571-
stemOffset: 10,
572-
bottomLine: 4,
573-
topModifierOffset: 20,
574-
},
575576
},
576577
};

src/tuplet.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export interface TupletOptions {
6464
y_offset?: number;
6565
}
6666

67+
export interface TupletMetrics {
68+
noteHeadOffset: number;
69+
stemOffset: number;
70+
bottomLine: number;
71+
topModifierOffset: number;
72+
}
73+
6774
export const enum TupletLocation {
6875
BOTTOM = -1,
6976
TOP = +1,
@@ -103,9 +110,11 @@ export class Tuplet extends Element {
103110
return 15;
104111
}
105112

106-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
107-
static get metrics(): any {
108-
return Tables.currentMusicFont().getMetrics().glyphs.tuplet;
113+
static get metrics(): TupletMetrics {
114+
const tupletMetrics = Tables.currentMusicFont().getMetrics().tuplet;
115+
116+
if (!tupletMetrics) throw new RuntimeError('BadMetrics', `tuplet missing`);
117+
return tupletMetrics;
109118
}
110119

111120
constructor(notes: Note[], options: TupletOptions = {}) {

0 commit comments

Comments
 (0)