Skip to content

Commit

Permalink
Incorporate changes from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronyeh committed May 1, 2021
1 parent b081563 commit 6b7bcd1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/fonts/bravura_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const BravuraMetrics = {
},

stem: {
renderHeightAdjustmentForFlag: -3,
heightAdjustmentForFlag: -3,
// These are stem (Y) offsets to the note heads. To shift the
// noteheads (x-position) themselves, see glyphs.notehead.custom.
noteHead: {
Expand Down
2 changes: 1 addition & 1 deletion src/fonts/gonville_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const GonvilleMetrics = {
},

stem: {
renderHeightAdjustmentForFlag: -3,
heightAdjustmentForFlag: -3,
// These are stem (Y) offsets to the note heads. To shift the
// noteheads (x-position) themselves, see glyphs.notehead.custom.
noteHead: {
Expand Down
2 changes: 1 addition & 1 deletion src/fonts/petaluma_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const PetalumaMetrics = {
},

stem: {
renderHeightAdjustmentForFlag: -3,
heightAdjustmentForFlag: -3,
// These are stem (Y) offsets to the note heads. To shift the
// noteheads (x-position) themselves, see glyphs.notehead.custom.
noteHead: {
Expand Down
8 changes: 5 additions & 3 deletions src/stavenote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1155,9 +1155,10 @@ export class StaveNote extends StemmableNote {
}

shouldDrawFlag(): boolean {
const hasFlag = this.getGlyph().flag; // this.glyph.flag is a boolean, as specified in tables.js
const hasStem = this.stem !== undefined;
const hasFlag = this.glyph.flag as boolean; // specified in tables.js
const hasNoBeam = this.beam === undefined;
return hasFlag && hasNoBeam;
return hasStem && hasFlag && hasNoBeam;
}

// Draw the flag for the note
Expand All @@ -1169,7 +1170,8 @@ export class StaveNote extends StemmableNote {

if (this.shouldDrawFlag()) {
const { y_top, y_bottom } = this.getNoteHeadBounds();
const noteStemHeight = this.stem?.getHeight() ?? 0;
// eslint-disable-next-line
const noteStemHeight = this.stem!.getHeight();
const flagX = this.getStemX();
// FIXME: What's with the magic +/- 2
// ANSWER: a corner of the note stem pokes out beyond the tip of the flag.
Expand Down
6 changes: 3 additions & 3 deletions src/stem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ export class Stem extends Element {
return this;
}

adjustHeightForFlag() {
this.renderHeightAdjustment = this.musicFont.lookupMetric('stem.renderHeightAdjustmentForFlag', -3);
adjustHeightForFlag(): void {
this.renderHeightAdjustment = this.musicFont.lookupMetric('stem.heightAdjustmentForFlag', -3);
}

adjustHeightForBeam() {
adjustHeightForBeam(): void {
this.renderHeightAdjustment = -Stem.WIDTH / 2;
}

Expand Down

0 comments on commit 6b7bcd1

Please sign in to comment.