vexflow 4.0.1-alpha.2 → 4.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/build/cjs/vexflow-bravura.js +2 -2
  2. package/build/cjs/vexflow-bravura.js.map +1 -1
  3. package/build/cjs/vexflow-core.js +2 -2
  4. package/build/cjs/vexflow-core.js.map +1 -1
  5. package/build/cjs/vexflow-debug-with-tests.js +345 -115
  6. package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
  7. package/build/cjs/vexflow-debug.js +247 -78
  8. package/build/cjs/vexflow-debug.js.map +1 -1
  9. package/build/cjs/vexflow-font-bravura.js +1 -1
  10. package/build/cjs/vexflow-font-bravura.js.map +1 -1
  11. package/build/cjs/vexflow-font-gonville.js +1 -1
  12. package/build/cjs/vexflow-font-gonville.js.map +1 -1
  13. package/build/cjs/vexflow-font-petaluma.js +1 -1
  14. package/build/cjs/vexflow-font-petaluma.js.map +1 -1
  15. package/build/cjs/vexflow-gonville.js +2 -2
  16. package/build/cjs/vexflow-gonville.js.map +1 -1
  17. package/build/cjs/vexflow-petaluma.js +2 -2
  18. package/build/cjs/vexflow-petaluma.js.map +1 -1
  19. package/build/cjs/vexflow.js +2 -2
  20. package/build/cjs/vexflow.js.map +1 -1
  21. package/build/esm/src/accidental.js +1 -1
  22. package/build/esm/src/annotation.js +24 -5
  23. package/build/esm/src/articulation.js +5 -2
  24. package/build/esm/src/beam.js +4 -0
  25. package/build/esm/src/fonts/bravura_metrics.js +8 -5
  26. package/build/esm/src/fonts/gonville_glyphs.js +4 -4
  27. package/build/esm/src/fonts/gonville_metrics.js +8 -2
  28. package/build/esm/src/fonts/petaluma_metrics.js +8 -5
  29. package/build/esm/src/gracenote.js +2 -0
  30. package/build/esm/src/note.js +1 -1
  31. package/build/esm/src/stavenote.js +88 -22
  32. package/build/esm/src/staverepetition.js +8 -8
  33. package/build/esm/src/stavetie.js +2 -0
  34. package/build/esm/src/stemmablenote.js +4 -2
  35. package/build/esm/src/tables.js +36 -0
  36. package/build/esm/src/tabnote.js +12 -9
  37. package/build/esm/src/version.js +3 -3
  38. package/build/esm/tests/articulation_tests.js +11 -24
  39. package/build/esm/tests/formatter_tests.js +2 -2
  40. package/build/esm/tests/gracenote_tests.js +43 -0
  41. package/build/esm/tests/ornament_tests.js +0 -1
  42. package/build/esm/tests/stavenote_tests.js +32 -0
  43. package/build/types/entry/vexflow-font-bravura.d.ts +8 -5
  44. package/build/types/entry/vexflow-font-gonville.d.ts +8 -2
  45. package/build/types/entry/vexflow-font-petaluma.d.ts +8 -5
  46. package/build/types/src/fonts/bravura_metrics.d.ts +8 -5
  47. package/build/types/src/fonts/gonville_metrics.d.ts +8 -2
  48. package/build/types/src/fonts/petaluma_metrics.d.ts +8 -5
  49. package/build/types/src/glyph.d.ts +4 -0
  50. package/build/types/src/note.d.ts +1 -0
  51. package/build/types/src/stavenote.d.ts +2 -0
  52. package/build/types/src/stem.d.ts +4 -1
  53. package/build/types/src/stemmablenote.d.ts +4 -1
  54. package/build/types/src/tabnote.d.ts +4 -1
  55. package/package.json +1 -1
  56. package/src/accidental.ts +1 -1
  57. package/src/annotation.ts +27 -6
  58. package/src/articulation.ts +8 -2
  59. package/src/beam.ts +4 -0
  60. package/src/fonts/bravura_metrics.ts +8 -5
  61. package/src/fonts/gonville_glyphs.ts +4 -4
  62. package/src/fonts/gonville_metrics.ts +8 -2
  63. package/src/fonts/petaluma_metrics.ts +8 -5
  64. package/src/glyph.ts +4 -0
  65. package/src/gracenote.ts +4 -1
  66. package/src/note.ts +2 -2
  67. package/src/stavenote.ts +97 -21
  68. package/src/staverepetition.ts +8 -8
  69. package/src/stavetie.ts +8 -0
  70. package/src/stem.ts +1 -1
  71. package/src/stemmablenote.ts +6 -4
  72. package/src/tables.ts +36 -0
  73. package/src/tabnote.ts +16 -13
  74. package/build/esm/src/publicpath.js +0 -1
  75. package/build/types/src/publicpath.d.ts +0 -0
  76. package/src/publicpath.ts +0 -0
@@ -144,11 +144,17 @@ export const PetalumaMetrics = {
144
144
  },
145
145
 
146
146
  staveRepetition: {
147
- default: {
147
+ symbolText: {
148
+ offsetX: 12,
148
149
  offsetY: 25,
149
- offsetSymbol: 12,
150
150
  spacing: 5,
151
151
  },
152
+ coda: {
153
+ offsetY: 25,
154
+ },
155
+ segno: {
156
+ offsetY: 10,
157
+ },
152
158
  },
153
159
 
154
160
  noteHead: {
@@ -245,9 +251,6 @@ export const PetalumaMetrics = {
245
251
  flag128thDown: {
246
252
  shiftX: -1.2,
247
253
  },
248
- tabStem: {
249
- shiftX: -1.75,
250
- },
251
254
  staveTempo: {
252
255
  shiftX: -1,
253
256
  },
package/src/glyph.ts CHANGED
@@ -19,6 +19,8 @@ export interface GlyphProps {
19
19
  line_below: number;
20
20
  line_above: number;
21
21
  stem_beam_extension: number;
22
+ stem_up_extension: number;
23
+ stem_down_extension: number;
22
24
  stem: Stem;
23
25
  code: string;
24
26
  code_flag_upstem: string;
@@ -26,6 +28,8 @@ export interface GlyphProps {
26
28
  flag: boolean;
27
29
  width: number;
28
30
  text: string;
31
+ tabnote_stem_down_extension: number;
32
+ tabnote_stem_up_extension: number;
29
33
  beam_count: number;
30
34
  shift_y: number;
31
35
  getWidth(a?: number): number;
package/src/gracenote.ts CHANGED
@@ -59,7 +59,6 @@ export class GraceNote extends StaveNote {
59
59
  return 0;
60
60
  }
61
61
 
62
- // FIXME: move this to more basic class.
63
62
  getStaveNoteScale(): number {
64
63
  return this.render_options.glyph_font_scale / Tables.NOTATION_FONT_SCALE;
65
64
  }
@@ -95,8 +94,12 @@ export class GraceNote extends StaveNote {
95
94
  ? noteHeadBounds.y_top - noteStemHeight
96
95
  : noteHeadBounds.y_bottom - noteStemHeight;
97
96
 
97
+ const defaultStemExtention =
98
+ stem_direction === Stem.DOWN ? this.glyph.stem_down_extension : this.glyph.stem_up_extension;
99
+
98
100
  let defaultOffsetY = Tables.STEM_HEIGHT;
99
101
  defaultOffsetY -= defaultOffsetY / 2.8;
102
+ defaultOffsetY += defaultStemExtention;
100
103
  y += defaultOffsetY * staveNoteScale * stem_direction;
101
104
 
102
105
  const offsets =
package/src/note.ts CHANGED
@@ -550,9 +550,9 @@ export abstract class Note extends Tickable {
550
550
  return this;
551
551
  }
552
552
 
553
- // Get all modifiers of a specific type in the `ModifierContext`
553
+ /** Get all modifiers of a specific type in `this.modifiers`. */
554
554
  getModifiersByType(type: string): Modifier[] {
555
- return this.checkModifierContext().getMembers(type) as Modifier[];
555
+ return this.modifiers.filter((modifier) => modifier.getCategory() === type);
556
556
  }
557
557
 
558
558
  /** Get the coordinates for where modifiers begin. */
package/src/stavenote.ts CHANGED
@@ -182,7 +182,8 @@ export class StaveNote extends StemmableNote {
182
182
 
183
183
  // Test for two voice note intersection
184
184
  if (voices === 2) {
185
- const lineSpacing = noteU.stemDirection === noteL.stemDirection ? 0.0 : 0.5;
185
+ const lineSpacing =
186
+ noteU.note.hasStem() && noteL.note.hasStem() && noteU.stemDirection === noteL.stemDirection ? 0.0 : 0.5;
186
187
  if (noteU.minLine <= noteL.maxLine + lineSpacing) {
187
188
  if (noteU.isrest) {
188
189
  // shift rest up
@@ -190,14 +191,73 @@ export class StaveNote extends StemmableNote {
190
191
  } else if (noteL.isrest) {
191
192
  // shift rest down
192
193
  shiftRestVertical(noteL, noteU, -1);
193
- } else if (noteU.stemDirection === noteL.stemDirection) {
194
- // upper voice is middle voice, so shift it right
195
- xShift = voiceXShift + 2;
196
- noteU.note.setXShift(xShift);
197
194
  } else {
198
- // shift lower voice right
199
- xShift = voiceXShift + 2;
200
- noteL.note.setXShift(xShift);
195
+ //Instead of shifting notes, remove the appropriate flag
196
+ //If we are sharing a line, switch one notes stem direction.
197
+ //If we are sharing a line and in the same voice, only then offset one note
198
+ const lineDiff = Math.abs(noteU.line - noteL.line);
199
+ if (noteU.note.hasStem() && noteL.note.hasStem()) {
200
+ //If we have different dot values, must offset
201
+ //Or If we have a white mixed with a black notehead, must offset
202
+ let whiteNoteHeadCount = 0;
203
+ let blackNoteHeadCount = 0;
204
+ if (Tables.durationToNumber(noteU.note.duration) === 2) {
205
+ whiteNoteHeadCount++;
206
+ } else if (Tables.durationToNumber(noteU.note.duration) > 2) {
207
+ blackNoteHeadCount++;
208
+ }
209
+ if (Tables.durationToNumber(noteL.note.duration) === 2) {
210
+ whiteNoteHeadCount++;
211
+ } else if (Tables.durationToNumber(noteL.note.duration) > 2) {
212
+ blackNoteHeadCount++;
213
+ }
214
+ if (
215
+ (whiteNoteHeadCount !== 2 && blackNoteHeadCount !== 2) ||
216
+ noteU.note.getModifiersByType(Category.Dot).length !== noteL.note.getModifiersByType(Category.Dot).length
217
+ ) {
218
+ xShift = voiceXShift + 2;
219
+ if (noteU.stemDirection === noteL.stemDirection) {
220
+ // upper voice is middle voice, so shift it right
221
+ noteU.note.setXShift(xShift);
222
+ } else {
223
+ // shift lower voice right
224
+ noteL.note.setXShift(xShift);
225
+ }
226
+ } else if (lineDiff < 1 && lineDiff > 0) {
227
+ //if the notes are quite close but not on the same line, shift
228
+ xShift = voiceXShift + 2;
229
+ if (noteU.stemDirection === noteL.stemDirection) {
230
+ // upper voice is middle voice, so shift it right
231
+ noteU.note.setXShift(xShift);
232
+ } else {
233
+ // shift lower voice right
234
+ noteL.note.setXShift(xShift);
235
+ }
236
+ } else if (noteU.note.voice !== noteL.note.voice) {
237
+ //If we are not in the same voice
238
+ if (noteU.stemDirection === noteL.stemDirection) {
239
+ if (noteU.line != noteL.line) {
240
+ xShift = voiceXShift + 2;
241
+ noteU.note.setXShift(xShift);
242
+ } else {
243
+ //same line, swap stem direction for one note
244
+ if (noteL.stemDirection === 1) {
245
+ noteL.stemDirection = -1;
246
+ noteL.note.setStemDirection(-1);
247
+ }
248
+ }
249
+ }
250
+ } //Very close whole notes
251
+ } else {
252
+ xShift = voiceXShift + 2;
253
+ if (noteU.stemDirection === noteL.stemDirection) {
254
+ // upper voice is middle voice, so shift it right
255
+ noteU.note.setXShift(xShift);
256
+ } else {
257
+ // shift lower voice right
258
+ noteL.note.setXShift(xShift);
259
+ }
260
+ }
201
261
  }
202
262
  }
203
263
 
@@ -373,7 +433,7 @@ export class StaveNote extends StemmableNote {
373
433
  setBeam(beam: Beam): this {
374
434
  this.beam = beam;
375
435
  this.calcNoteDisplacements();
376
- // Update stem extension is a beam is assigned.
436
+ // Update stem extension if a beam is assigned.
377
437
  if (this.stem) {
378
438
  this.stem.setExtension(this.getStemExtension());
379
439
  }
@@ -748,13 +808,13 @@ export class StaveNote extends StemmableNote {
748
808
  setStyle(style: ElementStyle): this {
749
809
  super.setStyle(style);
750
810
  this._noteHeads.forEach((notehead) => notehead.setStyle(style));
751
- this.stem?.setStyle(style);
811
+ if (this.stem) this.stem.setStyle(style);
752
812
  return this;
753
813
  }
754
814
 
755
815
  setStemStyle(style: ElementStyle): this {
756
816
  const stem = this.getStem();
757
- stem?.setStyle(style);
817
+ if (stem) stem.setStyle(style);
758
818
  return this;
759
819
  }
760
820
  getStemStyle(): ElementStyle | undefined {
@@ -1037,17 +1097,24 @@ export class StaveNote extends StemmableNote {
1037
1097
  // eslint-disable-next-line
1038
1098
  const noteStemHeight = this.stem!.getHeight();
1039
1099
  const flagX = this.getStemX();
1040
- // FIXME: What's with the magic +/- 2
1100
+ // What's with the magic +/- 2
1041
1101
  // ANSWER: a corner of the note stem pokes out beyond the tip of the flag.
1042
1102
  // The extra +/- 2 pushes the flag glyph outward so it covers the stem entirely.
1043
1103
  // Alternatively, we could shorten the stem.
1044
- const extension = this.flag !== undefined ? this.flag.checkMetrics().y_shift : 0;
1045
1104
  const flagY =
1046
1105
  this.getStemDirection() === Stem.DOWN
1047
1106
  ? // Down stems are below the note head and have flags on the right.
1048
- y_top - noteStemHeight + 2 - extension
1107
+ y_top -
1108
+ noteStemHeight +
1109
+ 2 -
1110
+ (this.glyph ? this.glyph.stem_down_extension : 0) * this.getStaveNoteScale() -
1111
+ (this.flag?.getMetrics().y_shift ?? 0) * (1 - this.getStaveNoteScale())
1049
1112
  : // Up stems are above the note head and have flags on the right.
1050
- y_bottom - noteStemHeight - 2 - extension;
1113
+ y_bottom -
1114
+ noteStemHeight -
1115
+ 2 +
1116
+ (this.glyph ? this.glyph.stem_up_extension : 0) * this.getStaveNoteScale() -
1117
+ (this.flag?.getMetrics().y_shift ?? 0) * (1 - this.getStaveNoteScale());
1051
1118
 
1052
1119
  // Draw the Flag
1053
1120
  ctx.openGroup('flag', undefined, { pointerBBox: true });
@@ -1084,9 +1151,16 @@ export class StaveNote extends StemmableNote {
1084
1151
  this.stem.adjustHeightForFlag();
1085
1152
  }
1086
1153
 
1087
- ctx.openGroup('stem', undefined, { pointerBBox: true });
1088
- this.stem?.setContext(ctx).draw();
1089
- ctx.closeGroup();
1154
+ if (this.stem) {
1155
+ ctx.openGroup('stem', undefined, { pointerBBox: true });
1156
+ this.stem.setContext(ctx).draw();
1157
+ ctx.closeGroup();
1158
+ }
1159
+ }
1160
+
1161
+ /** Primarily used as the scaling factor for grace notes, GraceNote will return the required scale. */
1162
+ getStaveNoteScale(): number {
1163
+ return 1.0;
1090
1164
  }
1091
1165
 
1092
1166
  /**
@@ -1143,9 +1217,11 @@ export class StaveNote extends StemmableNote {
1143
1217
  // Format note head x positions
1144
1218
  this._noteHeads.forEach((notehead) => notehead.setX(xBegin));
1145
1219
 
1146
- // Format stem x positions
1147
- const stemX = this.getStemX();
1148
- this.stem?.setNoteHeadXBounds(stemX, stemX);
1220
+ if (this.stem) {
1221
+ // Format stem x positions
1222
+ const stemX = this.getStemX();
1223
+ this.stem.setNoteHeadXBounds(stemX, stemX);
1224
+ }
1149
1225
 
1150
1226
  L('Rendering ', this.isChord() ? 'chord :' : 'note :', this.keys);
1151
1227
 
@@ -114,7 +114,7 @@ export class Repetition extends StaveModifier {
114
114
  Glyph.renderGlyph(
115
115
  stave.checkContext(),
116
116
  this.x + x + this.x_shift,
117
- y + Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetY'),
117
+ y + Tables.currentMusicFont().lookupMetric('staveRepetition.coda.offsetY'),
118
118
  40,
119
119
  'coda',
120
120
  { category: 'coda' }
@@ -127,7 +127,7 @@ export class Repetition extends StaveModifier {
127
127
  Glyph.renderGlyph(
128
128
  stave.checkContext(),
129
129
  this.x + x + this.x_shift,
130
- y + Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetY'),
130
+ y + Tables.currentMusicFont().lookupMetric('staveRepetition.segno.offsetY'),
131
131
  30,
132
132
  'segno',
133
133
  { category: 'segno' }
@@ -152,7 +152,7 @@ export class Repetition extends StaveModifier {
152
152
  symbol_x =
153
153
  text_x +
154
154
  ctx.measureText(text).width +
155
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetSymbol');
155
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.offsetX');
156
156
  break;
157
157
  // To the right without symbol
158
158
  case Repetition.type.DC:
@@ -165,7 +165,7 @@ export class Repetition extends StaveModifier {
165
165
  x +
166
166
  this.x_shift +
167
167
  stave.getWidth() -
168
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.spacing') -
168
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.spacing') -
169
169
  modifierWidth -
170
170
  ctx.measureText(text).width;
171
171
  break;
@@ -176,21 +176,21 @@ export class Repetition extends StaveModifier {
176
176
  x +
177
177
  this.x_shift +
178
178
  stave.getWidth() -
179
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.spacing') -
179
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.spacing') -
180
180
  modifierWidth -
181
181
  ctx.measureText(text).width -
182
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetSymbol');
182
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.offsetX');
183
183
  symbol_x =
184
184
  text_x +
185
185
  ctx.measureText(text).width +
186
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetSymbol');
186
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.offsetX');
187
187
  break;
188
188
  }
189
189
 
190
190
  const y =
191
191
  stave.getYForTopText(stave.getNumLines()) +
192
192
  this.y_shift +
193
- Tables.currentMusicFont().lookupMetric('staveRepetition.default.offsetY');
193
+ Tables.currentMusicFont().lookupMetric('staveRepetition.symbolText.offsetY');
194
194
  if (draw_coda) {
195
195
  Glyph.renderGlyph(ctx, symbol_x, y, 40, 'coda', { category: 'coda' });
196
196
  }
package/src/stavetie.ts CHANGED
@@ -152,12 +152,20 @@ export class StaveTie extends Element {
152
152
  const top_cp_y = (first_y_px + last_y_px) / 2 + cp1 * params.direction;
153
153
  const bottom_cp_y = (first_y_px + last_y_px) / 2 + cp2 * params.direction;
154
154
 
155
+ // id probably unnecessary if we save the group to 'el' via setAttribute
156
+ // let id: string = "";
157
+ // if (this.notes.first_note) {
158
+ // id = this.notes.first_note.getAttribute('id') + '-tie';
159
+ // }
160
+ // this.setAttribute('el', ctx.openGroup('stavetie', id));
161
+ this.setAttribute('el', ctx.openGroup('stavetie'));
155
162
  ctx.beginPath();
156
163
  ctx.moveTo(params.first_x_px + first_x_shift, first_y_px);
157
164
  ctx.quadraticCurveTo(cp_x, top_cp_y, params.last_x_px + last_x_shift, last_y_px);
158
165
  ctx.quadraticCurveTo(cp_x, bottom_cp_y, params.first_x_px + first_x_shift, first_y_px);
159
166
  ctx.closePath();
160
167
  ctx.fill();
168
+ ctx.closeGroup();
161
169
  }
162
170
  }
163
171
 
package/src/stem.ts CHANGED
@@ -147,7 +147,7 @@ export class Stem extends Element {
147
147
 
148
148
  // Get the y coordinates for the very base of the stem to the top of
149
149
  // the extension
150
- getExtents(): Record<string, number> {
150
+ getExtents(): { topY: number; baseY: number } {
151
151
  const isStemUp = this.stem_direction === Stem.UP;
152
152
  const ys = [this.y_top, this.y_bottom];
153
153
  const stemHeight = Stem.HEIGHT + this.stem_extension;
@@ -191,9 +191,11 @@ export abstract class StemmableNote extends Note {
191
191
  return glyph.stem_beam_extension;
192
192
  }
193
193
 
194
- const flagCode =
195
- this.getStemDirection() === Stem.DOWN ? this.glyph.code_flag_downstem : this.glyph.code_flag_upstem;
196
- return Math.abs(Tables.currentMusicFont().lookupMetric(`glyphs.flag.${flagCode}.shiftY`, 0));
194
+ if (glyph) {
195
+ return this.getStemDirection() === Stem.UP ? glyph.stem_up_extension : glyph.stem_down_extension;
196
+ }
197
+
198
+ return 0;
197
199
  }
198
200
 
199
201
  // Set the stem length to a specific. Will override the default length.
@@ -203,7 +205,7 @@ export abstract class StemmableNote extends Note {
203
205
  }
204
206
 
205
207
  // Get the top and bottom `y` values of the stem.
206
- getStemExtents(): Record<string, number> {
208
+ getStemExtents(): { topY: number; baseY: number } {
207
209
  if (!this.stem) throw new RuntimeError('NoStem', 'No stem attached to this note.');
208
210
  return this.stem.getExtents();
209
211
  }
package/src/tables.ts CHANGED
@@ -890,6 +890,10 @@ const durationCodes: Record<string, any> = {
890
890
  stem: false,
891
891
  stem_offset: 0,
892
892
  flag: false,
893
+ stem_up_extension: -Tables.STEM_HEIGHT,
894
+ stem_down_extension: -Tables.STEM_HEIGHT,
895
+ tabnote_stem_up_extension: -Tables.STEM_HEIGHT,
896
+ tabnote_stem_down_extension: -Tables.STEM_HEIGHT,
893
897
  dot_shiftY: 0,
894
898
  line_above: 0,
895
899
  line_below: 0,
@@ -945,6 +949,10 @@ const durationCodes: Record<string, any> = {
945
949
  stem: false,
946
950
  stem_offset: 0,
947
951
  flag: false,
952
+ stem_up_extension: -Tables.STEM_HEIGHT,
953
+ stem_down_extension: -Tables.STEM_HEIGHT,
954
+ tabnote_stem_up_extension: -Tables.STEM_HEIGHT,
955
+ tabnote_stem_down_extension: -Tables.STEM_HEIGHT,
948
956
  dot_shiftY: 0,
949
957
  line_above: 0,
950
958
  line_below: 0,
@@ -1000,6 +1008,10 @@ const durationCodes: Record<string, any> = {
1000
1008
  stem: true,
1001
1009
  stem_offset: 0,
1002
1010
  flag: false,
1011
+ stem_up_extension: 0,
1012
+ stem_down_extension: 0,
1013
+ tabnote_stem_up_extension: 0,
1014
+ tabnote_stem_down_extension: 0,
1003
1015
  dot_shiftY: 0,
1004
1016
  line_above: 0,
1005
1017
  line_below: 0,
@@ -1056,6 +1068,10 @@ const durationCodes: Record<string, any> = {
1056
1068
  stem: true,
1057
1069
  stem_offset: 0,
1058
1070
  flag: false,
1071
+ stem_up_extension: 0,
1072
+ stem_down_extension: 0,
1073
+ tabnote_stem_up_extension: 0,
1074
+ tabnote_stem_down_extension: 0,
1059
1075
  dot_shiftY: 0,
1060
1076
  line_above: 0,
1061
1077
  line_below: 0,
@@ -1117,6 +1133,10 @@ const durationCodes: Record<string, any> = {
1117
1133
  stem_beam_extension: 0,
1118
1134
  code_flag_upstem: 'flag8thUp',
1119
1135
  code_flag_downstem: 'flag8thDown',
1136
+ stem_up_extension: 0,
1137
+ stem_down_extension: 0,
1138
+ tabnote_stem_up_extension: 0,
1139
+ tabnote_stem_down_extension: 0,
1120
1140
  dot_shiftY: 0,
1121
1141
  line_above: 0,
1122
1142
  line_below: 0,
@@ -1179,6 +1199,10 @@ const durationCodes: Record<string, any> = {
1179
1199
  flag: true,
1180
1200
  code_flag_upstem: 'flag16thUp',
1181
1201
  code_flag_downstem: 'flag16thDown',
1202
+ stem_up_extension: 0,
1203
+ stem_down_extension: 0,
1204
+ tabnote_stem_up_extension: 0,
1205
+ tabnote_stem_down_extension: 0,
1182
1206
  dot_shiftY: 0,
1183
1207
  line_above: 0,
1184
1208
  line_below: 0,
@@ -1241,6 +1265,10 @@ const durationCodes: Record<string, any> = {
1241
1265
  flag: true,
1242
1266
  code_flag_upstem: 'flag32ndUp',
1243
1267
  code_flag_downstem: 'flag32ndDown',
1268
+ stem_up_extension: 9,
1269
+ stem_down_extension: 9,
1270
+ tabnote_stem_up_extension: 9,
1271
+ tabnote_stem_down_extension: 9,
1244
1272
  dot_shiftY: 0,
1245
1273
  line_above: 0,
1246
1274
  line_below: 0,
@@ -1303,6 +1331,10 @@ const durationCodes: Record<string, any> = {
1303
1331
  flag: true,
1304
1332
  code_flag_upstem: 'flag64thUp',
1305
1333
  code_flag_downstem: 'flag64thDown',
1334
+ stem_up_extension: 13,
1335
+ stem_down_extension: 13,
1336
+ tabnote_stem_up_extension: 13,
1337
+ tabnote_stem_down_extension: 13,
1306
1338
  dot_shiftY: 0,
1307
1339
  line_above: 0,
1308
1340
  line_below: 0,
@@ -1365,6 +1397,10 @@ const durationCodes: Record<string, any> = {
1365
1397
  flag: true,
1366
1398
  code_flag_upstem: 'flag128thUp',
1367
1399
  code_flag_downstem: 'flag128thDown',
1400
+ stem_up_extension: 22,
1401
+ stem_down_extension: 22,
1402
+ tabnote_stem_up_extension: 22,
1403
+ tabnote_stem_down_extension: 22,
1368
1404
  dot_shiftY: 0,
1369
1405
  line_above: 0,
1370
1406
  line_below: 0,
package/src/tabnote.ts CHANGED
@@ -208,12 +208,14 @@ export class TabNote extends StemmableNote {
208
208
 
209
209
  // Get the default stem extension for the note
210
210
  getStemExtension(): number {
211
+ const glyph = this.getGlyph();
212
+
211
213
  if (this.stem_extension_override != null) {
212
214
  return this.stem_extension_override;
213
215
  }
214
216
 
215
- if (this.flag) {
216
- return this.getStemDirection() === 1 ? -this.flag.checkMetrics().y_shift : this.flag.checkMetrics().y_shift;
217
+ if (glyph) {
218
+ return this.getStemDirection() === Stem.UP ? glyph.tabnote_stem_up_extension : glyph.tabnote_stem_down_extension;
217
219
  }
218
220
 
219
221
  return 0;
@@ -339,7 +341,7 @@ export class TabNote extends StemmableNote {
339
341
  }
340
342
 
341
343
  // Get the stem extents for the tabnote
342
- getStemExtents(): Record<string, number> {
344
+ getStemExtents(): { topY: number; baseY: number } {
343
345
  return this.checkStem().getExtents();
344
346
  }
345
347
 
@@ -348,8 +350,7 @@ export class TabNote extends StemmableNote {
348
350
  const {
349
351
  beam,
350
352
  glyph,
351
- stem_direction,
352
- render_options: { draw_stem, glyph_font_scale },
353
+ render_options: { draw_stem },
353
354
  } = this;
354
355
  const context = this.checkContext();
355
356
 
@@ -357,16 +358,18 @@ export class TabNote extends StemmableNote {
357
358
 
358
359
  // Now it's the flag's turn.
359
360
  if (glyph.flag && shouldDrawFlag) {
360
- const flag_x = this.getStemX() + 1;
361
- const flag_y = this.getStemY() - this.checkStem().getHeight();
362
-
363
- const flag_code =
364
- stem_direction === Stem.DOWN
365
- ? glyph.code_flag_downstem // Down stems have flags on the left.
366
- : glyph.code_flag_upstem;
361
+ const flag_x = this.getStemX();
362
+ const flag_y =
363
+ this.getStemDirection() === Stem.DOWN
364
+ ? // Down stems are below the note head and have flags on the right.
365
+ this.getStemY() - this.checkStem().getHeight() - (this.glyph ? this.glyph.stem_down_extension : 0)
366
+ : // Up stems are above the note head and have flags on the right.
367
+ this.getStemY() - this.checkStem().getHeight() + (this.glyph ? this.glyph.stem_up_extension : 0);
367
368
 
368
369
  // Draw the Flag
369
- Glyph.renderGlyph(context, flag_x, flag_y, glyph_font_scale, flag_code, { category: 'flag.tabStem' });
370
+ //this.flag?.setOptions({ category: 'flag.tabStem' });
371
+ this.flag?.render(context, flag_x, flag_y);
372
+ //Glyph.renderGlyph(context, flag_x, flag_y, glyph_font_scale, flag_code, { category: 'flag.tabStem' });
370
373
  }
371
374
  }
372
375
 
@@ -1 +0,0 @@
1
- "use strict";
File without changes
package/src/publicpath.ts DELETED
File without changes