Skip to content

Commit

Permalink
Merge branch 'master' into modifier-index
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfe authored Jun 7, 2021
2 parents 66a760d + 268cd9a commit fd9a019
Show file tree
Hide file tree
Showing 41 changed files with 442 additions and 407 deletions.
5 changes: 2 additions & 3 deletions src/accidental.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//
// See `tests/accidental_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { Fraction } from './fraction';
import { Flow } from './tables';
import { Music } from './music';
Expand All @@ -21,7 +20,7 @@ import { GraceNote } from './gracenote';

// To enable logging for this class. Set `Vex.Flow.Accidental.DEBUG` to `true`.
function L(...args) {
if (Accidental.DEBUG) Vex.L('Vex.Flow.Accidental', args);
if (Accidental.DEBUG) log('Vex.Flow.Accidental', args);
}

const getGlyphWidth = (glyph) => glyph.getMetrics().width;
Expand Down
7 changes: 3 additions & 4 deletions src/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
// See `tests/annotation_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError, log } from './util';
import { Flow } from './tables';
import { Modifier } from './modifier';
import { TextFont } from './textfont';
Expand All @@ -18,9 +18,8 @@ import { ModifierContextState } from './modifiercontext';
// To enable logging for this class. Set `Vex.Flow.Annotation.DEBUG` to `true`.
function L(
// eslint-disable-next-line
...args: any[]
) {
if (Annotation.DEBUG) Vex.L('Vex.Flow.Annotation', args);
...args: any []) {
if (Annotation.DEBUG) log('Vex.Flow.Annotation', args);
}

enum Justify {
Expand Down
8 changes: 3 additions & 5 deletions src/articulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
//
// See `tests/articulation_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { Flow } from './tables';
import { Modifier } from './modifier';
import { Glyph } from './glyph';
Expand All @@ -33,9 +32,8 @@ export interface ArticulationStruct {
// To enable logging for this class. Set `Vex.Flow.Articulation.DEBUG` to `true`.
function L(
// eslint-disable-next-line
...args: any[]
) {
if (Articulation.DEBUG) Vex.L('Vex.Flow.Articulation', args);
...args: any[]) {
if (Articulation.DEBUG) log('Vex.Flow.Articulation', args);
}

const { ABOVE, BELOW } = Modifier.Position;
Expand Down
9 changes: 5 additions & 4 deletions src/barnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
//
// See `tests/barnote_tests.js` for usage examples.

import { Vex } from './vex';
import { log } from './util';
import { Note } from './note';
import { Barline, BarlineType } from './stavebarline';

// To enable logging for this class. Set `Vex.Flow.BarNote.DEBUG` to `true`.
// eslint-disable-next-line
function L(...args: any[]) {
if (BarNote.DEBUG) Vex.L('Vex.Flow.BarNote', args);
function L(
// eslint-disable-next-line
...args: any[]) {
if (BarNote.DEBUG) log('Vex.Flow.BarNote', args);
}

export class BarNote extends Note {
Expand Down
3 changes: 1 addition & 2 deletions src/bend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// This file implements tablature bends.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { Flow } from './tables';
import { Modifier } from './modifier';
Expand Down Expand Up @@ -171,7 +170,7 @@ export class Bend extends Modifier {
const additional_width =
bend.type === Bend.UP ? this.render_options.bend_width : this.render_options.release_width;

bend.width = Vex.Max(additional_width, measure_text(bend.text)) + 3;
bend.width = Math.max(additional_width, measure_text(bend.text)) + 3;
bend.draw_width = bend.width / 2;
total_width += bend.width;
}
Expand Down
4 changes: 2 additions & 2 deletions src/canvascontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Copyright Mohit Cheppudira 2010

import { Vex } from './vex';
import { warn } from './util';

/** @constructor */
export class CanvasContext {
Expand All @@ -21,7 +21,7 @@ export class CanvasContext {

static SanitizeCanvasDims(width, height) {
if (Math.max(width, height) > this.CANVAS_BROWSER_SIZE_LIMIT) {
Vex.W('Canvas dimensions exceed browser limit. Cropping to ' + this.CANVAS_BROWSER_SIZE_LIMIT);
warn('Canvas dimensions exceed browser limit. Cropping to ' + this.CANVAS_BROWSER_SIZE_LIMIT);
if (width > this.CANVAS_BROWSER_SIZE_LIMIT) {
width = this.CANVAS_BROWSER_SIZE_LIMIT;
// note: Math.min return 0 for undefined, NaN for null. Would change inputs.
Expand Down
13 changes: 7 additions & 6 deletions src/chordsymbol.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
//
// See `tests/chordsymbol_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError, log } from './util';
import { DefaultFontStack } from './font';
import { Flow } from './tables';
import { Glyph } from './glyph';
import { TextFont } from './textfont';
import { Modifier } from './modifier';

// To enable logging for this class. Set `Vex.Flow.ChordSymbol.DEBUG` to `true`.
function L(...args) {
if (ChordSymbol.DEBUG) Vex.L('Vex.Flow.ChordSymbol', args);
if (ChordSymbol.DEBUG) log('Vex.Flow.ChordSymbol', args);
}

export class ChordSymbol extends Modifier {
Expand Down Expand Up @@ -104,7 +105,7 @@ export class ChordSymbol extends Modifier {
}

static get engravingFontResolution() {
return Vex.Flow.DEFAULT_FONT_STACK[0].getResolution();
return DefaultFontStack[0].getResolution();
}

static get spacingBetweenBlocks() {
Expand Down Expand Up @@ -234,15 +235,15 @@ export class ChordSymbol extends Modifier {
}

static get chordSymbolMetrics() {
return Vex.Flow.DEFAULT_FONT_STACK[0].metrics.glyphs.chordSymbol;
return DefaultFontStack[0].metrics.glyphs.chordSymbol;
}

static get lowerKerningText() {
return Vex.Flow.DEFAULT_FONT_STACK[0].metrics.glyphs.chordSymbol.global.lowerKerningText;
return DefaultFontStack[0].metrics.glyphs.chordSymbol.global.lowerKerningText;
}

static get upperKerningText() {
return Vex.Flow.DEFAULT_FONT_STACK[0].metrics.glyphs.chordSymbol.global.upperKerningText;
return DefaultFontStack[0].metrics.glyphs.chordSymbol.global.upperKerningText;
}

// ### format
Expand Down
5 changes: 2 additions & 3 deletions src/clef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
//
// See `tests/clef_tests.js` for usage examples.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { StaveModifier } from './stavemodifier';
import { Glyph } from './glyph';
import { Stave } from './stave';
Expand All @@ -30,7 +29,7 @@ export interface ClefType {
function L(
// eslint-disable-next-line
...args: any []) {
if (Clef.DEBUG) Vex.L('Vex.Flow.Clef', args);
if (Clef.DEBUG) log('Vex.Flow.Clef', args);
}

export class Clef extends StaveModifier {
Expand Down
4 changes: 2 additions & 2 deletions src/crescendo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// type in VexFlow. This object would most likely be formatted in a Voice
// with `TextNotes` - which are used to represent other dynamics markings.

import { Vex } from './vex';
import { log } from './util';
import { Note, NoteStruct } from './note';
import { TickContext } from './tickcontext';
import { RenderContext } from './types/common';
Expand All @@ -25,7 +25,7 @@ export interface CrescendoParams {
function L(
// eslint-disable-next-line
...args: any []) {
if (Crescendo.DEBUG) Vex.L('Vex.Flow.Crescendo', args);
if (Crescendo.DEBUG) log('Vex.Flow.Crescendo', args);
}

// Private helper to draw the hairpin
Expand Down
4 changes: 2 additions & 2 deletions src/easyscore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* eslint max-classes-per-file: "off" */

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { StaveNote } from './stavenote';
import { Match, Parser, Result, Rule, RuleFunction } from './parser';
import { Articulation } from './articulation';
Expand All @@ -20,7 +20,7 @@ import { Voice } from './voice';
// To enable logging for this class. Set `Vex.Flow.EasyScore.DEBUG` to `true`.
// eslint-disable-next-line
function L(...args: any[]): void {
if (EasyScore.DEBUG) Vex.L('Vex.Flow.EasyScore', args);
if (EasyScore.DEBUG) log('Vex.Flow.EasyScore', args);
}

export const X = Vex.MakeException('EasyScoreError');
Expand Down
6 changes: 3 additions & 3 deletions src/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { RuntimeError } from './util';
import { Registry } from './registry';
import { Flow } from './tables';
import { DefaultFontStack } from './font';
import { BoundingBox } from './boundingbox';
import { Font } from './font';
import { RenderContext } from './types/common';
Expand Down Expand Up @@ -62,8 +62,8 @@ export abstract class Element {
};

this.rendered = false;
this.fontStack = Flow.DEFAULT_FONT_STACK;
this.musicFont = Flow.DEFAULT_FONT_STACK[0];
this.fontStack = DefaultFontStack;
this.musicFont = DefaultFontStack[0];

// If a default registry exist, then register with it right away.
Registry.getDefaultRegistry()?.register(this);
Expand Down
3 changes: 2 additions & 1 deletion src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// *This API is currently DRAFT*

import { Vex } from './vex';
import { log } from './util';
import { Accidental } from './accidental';
import { Articulation } from './articulation';
import { Annotation } from './annotation';
Expand Down Expand Up @@ -52,7 +53,7 @@ import { TextFont } from './textfont';

// To enable logging for this class. Set `Vex.Flow.Factory.DEBUG` to `true`.
function L(...args) {
if (Factory.DEBUG) Vex.L('Vex.Flow.Factory', args);
if (Factory.DEBUG) log('Vex.Flow.Factory', args);
}

export const X = Vex.MakeException('FactoryError');
Expand Down
2 changes: 1 addition & 1 deletion src/font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface FontGlyph {
y_min?: number;
y_max?: number;
ha: number;
o?: string;
o: string;
leftSideBearing?: number;
advanceWidth?: number;
cached_outline?: string[];
Expand Down
7 changes: 4 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
// here (`FormatAndDraw`, `FormatAndDrawTab`) also serve as useful usage examples.

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { DefaultFontStack } from './font';
import { Beam } from './beam';
import { Flow } from './tables';
import { Fraction } from './fraction';
Expand Down Expand Up @@ -120,7 +121,7 @@ function createContexts<T>(
function L(
// eslint-disable-next-line
...args: any[]) {
if (Formatter.DEBUG) Vex.L('Vex.Flow.Formatter', args);
if (Formatter.DEBUG) log('Vex.Flow.Formatter', args);
}

// Helper function to locate the next non-rest note(s).
Expand Down Expand Up @@ -187,7 +188,7 @@ export class Formatter {
options?: { stavePadding: number }
): void {
options = {
stavePadding: Flow.DEFAULT_FONT_STACK[0].lookupMetric('stave.padding'),
stavePadding: DefaultFontStack[0].lookupMetric('stave.padding'),
...options,
};

Expand Down
4 changes: 2 additions & 2 deletions src/glyph.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// [VexFlow](http://vexflow.com) - Copyright (c) Mohit Muthanna 2010.

import { RuntimeError } from './util';
import { Flow } from './tables';
import { DefaultFontStack } from './font';
import { Element } from './element';
import { BoundingBoxComputation } from './boundingboxcomputation';
import { BoundingBox } from './boundingbox';
Expand Down Expand Up @@ -236,7 +236,7 @@ export class Glyph extends Element {
options?: { font?: Font; category: string }
): GlyphMetrics {
const params = {
fontStack: Flow.DEFAULT_FONT_STACK,
fontStack: DefaultFontStack,
...options,
};
const metrics = Glyph.loadMetrics(params.fontStack, val, params.category);
Expand Down
2 changes: 1 addition & 1 deletion src/glyphnote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class GlyphNote extends Note {
const stave = this.checkStave();
const ctx = stave.checkContext();
this.setRendered();
ctx.openGroup('glypheNote', this.getAttribute('id'));
ctx.openGroup('glyphNote', this.getAttribute('id'));

// Context is set when setStave is called on Note
if (!this.glyph.getContext()) {
Expand Down
7 changes: 3 additions & 4 deletions src/gracenotegroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// This file implements `GraceNoteGroup` which is used to format and
// render grace notes.

import { Vex } from './vex';
import { RuntimeError, log } from './util';
import { Flow } from './tables';
import { Modifier } from './modifier';
import { Formatter } from './formatter';
Expand All @@ -22,9 +22,8 @@ import { RenderContext } from './types/common';
// To enable logging for this class. Set `GraceNoteGroup.DEBUG` to `true`.
function L(
// eslint-disable-next-line
...args: any
) {
if (GraceNoteGroup.DEBUG) Vex.L('Vex.Flow.GraceNoteGroup', args);
...args: any) {
if (GraceNoteGroup.DEBUG) log('Vex.Flow.GraceNoteGroup', args);
}

/** GraceNoteGroup is used to format and render grace notes. */
Expand Down
2 changes: 1 addition & 1 deletion src/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export enum ModifierPosition {
}

// To enable logging for this class. Set `Vex.Flow.Modifier.DEBUG` to `true`.
// function L(...args) { if (Modifier.DEBUG) Vex.L('Vex.Flow.Modifier', args); }
// function L(...args) { if (Modifier.DEBUG) log('Vex.Flow.Modifier', args); }

export class Modifier extends Element {
// Modifiers are attached to a note and an index. An index is a specific head in a chord.
Expand Down
5 changes: 2 additions & 3 deletions src/modifiercontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
// This class implements various types of members to notes (e.g. bends,
// fingering positions etc.)

import { Vex } from './vex';
import { RuntimeError } from './util';
import { RuntimeError, log } from './util';
import { StaveNote } from './stavenote';
import { Dot } from './dot';
import { FretHandFinger } from './frethandfinger';
Expand Down Expand Up @@ -43,7 +42,7 @@ export type ModifierContextMember = Modifier | StaveNote | TabNote;
function L(
// eslint-disable-next-line
...args: any[]) {
if (ModifierContext.DEBUG) Vex.L('Vex.Flow.ModifierContext', args);
if (ModifierContext.DEBUG) log('Vex.Flow.ModifierContext', args);
}

export class ModifierContext {
Expand Down
Loading

0 comments on commit fd9a019

Please sign in to comment.