Skip to content

Commit be54b60

Browse files
authored
Merge pull request #1537 from rvilarl/point/pedals
point fixed on pedals
2 parents 8e5b373 + 28d1a39 commit be54b60

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/fonts/common_metrics.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,7 @@ export const CommonMetrics = {
226226
},
227227
},
228228

229-
pedalMarking: {
230-
up: {
231-
point: 40,
232-
},
233-
down: {
234-
point: 34,
235-
},
236-
},
229+
pedalMarking: {},
237230

238231
// These are for numeric digits, such as in time signatures
239232
digits: {

src/pedalmarking.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function L(...args: any[]) {
2323
function drawPedalGlyph(name: string, context: RenderContext, x: number, y: number, point: number): void {
2424
const glyph_data = PedalMarking.GLYPHS[name];
2525
const glyph = new Glyph(glyph_data.code, point, { category: 'pedalMarking' });
26-
glyph.render(context, x + glyph_data.x_shift, y + glyph_data.y_shift);
26+
// Center the middle of the glyph with the middle of the note head (Tables.STAVE_LINE_DISTANCE / 2)
27+
glyph.render(context, x - (glyph.getMetrics().width - Tables.STAVE_LINE_DISTANCE) / 2, y);
2728
}
2829

2930
/**
@@ -61,16 +62,12 @@ export class PedalMarking extends Element {
6162
protected notes: StaveNote[];
6263

6364
/** Glyph data */
64-
static readonly GLYPHS: Record<string, { code: string; y_shift: number; x_shift: number }> = {
65+
static readonly GLYPHS: Record<string, { code: string }> = {
6566
pedal_depress: {
6667
code: 'keyboardPedalPed',
67-
x_shift: -10,
68-
y_shift: 0,
6968
},
7069
pedal_release: {
7170
code: 'keyboardPedalUp',
72-
x_shift: -2,
73-
y_shift: 3,
7471
},
7572
};
7673

@@ -188,7 +185,9 @@ export class PedalMarking extends Element {
188185
const prev_is_same = notes[index - 1] === note;
189186

190187
let x_shift = 0;
191-
const point = Tables.currentMusicFont().lookupMetric(`pedalMarking.${is_pedal_depressed ? 'down' : 'up'}.point`);
188+
const point =
189+
Tables.currentMusicFont().lookupMetric(`pedalMarking.${is_pedal_depressed ? 'down' : 'up'}.point`) ??
190+
Tables.NOTATION_FONT_SCALE;
192191

193192
if (is_pedal_depressed) {
194193
// Adjustment for release+depress
@@ -248,7 +247,9 @@ export class PedalMarking extends Element {
248247
const x = note.getAbsoluteX();
249248
const y = stave.getYForBottomText(this.line + 3);
250249

251-
const point = Tables.currentMusicFont().lookupMetric(`pedalMarking.${is_pedal_depressed ? 'down' : 'up'}.point`);
250+
const point =
251+
Tables.currentMusicFont().lookupMetric(`pedalMarking.${is_pedal_depressed ? 'down' : 'up'}.point`) ??
252+
Tables.NOTATION_FONT_SCALE;
252253

253254
let text_width = 0;
254255
if (is_pedal_depressed) {

0 commit comments

Comments
 (0)