diff --git a/src/chordsymbol.ts b/src/chordsymbol.ts index 4fc03dce92..cd24f542c4 100644 --- a/src/chordsymbol.ts +++ b/src/chordsymbol.ts @@ -562,10 +562,6 @@ export class ChordSymbol extends Modifier { const glyphArgs = ChordSymbol.glyphs[params.glyph]; const glyphPoints = 20; symbolBlock.glyph = new Glyph(glyphArgs.code, glyphPoints, { category: 'chordSymbol' }); - // Beware: glyph.metrics is not the same as glyph.getMetrics() ! - // rv.glyph.point = rv.glyph.point * rv.glyph.metrics.scale; - // rv.width = rv.glyph.getMetrics().width; - // don't set yShift here, b/c we need to do it at formatting time after the font is set. } else if (symbolType === SymbolTypes.TEXT) { symbolBlock.width = this.textFormatter.getWidthForTextInEm(symbolBlock.text); } else if (symbolType === SymbolTypes.LINE) { diff --git a/src/fonts/load_petaluma.ts b/src/fonts/load_petaluma.ts index 28ffa173ba..1a375bdfb0 100644 --- a/src/fonts/load_petaluma.ts +++ b/src/fonts/load_petaluma.ts @@ -4,7 +4,86 @@ import { Font } from '../font'; import { CommonMetrics } from './common_metrics'; import { PetalumaFont } from './petaluma_glyphs'; +import { ChordSymbolGlyphMetrics } from '../chordsymbol'; +import { FontMetrics } from '../font'; +const petalumaChordMetrics: Record = { + csymDiminished: { + leftSideBearing: -95, + advanceWidth: 506, + yOffset: 0, + }, + csymHalfDiminished: { + leftSideBearing: -32, + advanceWidth: 506, + yOffset: 0, + }, + csymAugmented: { + leftSideBearing: -25, + advanceWidth: 530, + yOffset: 0, + }, + csymParensLeftTall: { + leftSideBearing: 0, + advanceWidth: 155, + yOffset: 150, + }, + csymParensRightTall: { + leftSideBearing: 40, + advanceWidth: 189, + yOffset: 150, + }, + csymBracketLeftTall: { + leftSideBearing: 0, + advanceWidth: 328, + yOffset: 0, + }, + csymBracketRightTall: { + leftSideBearing: 1, + advanceWidth: 600, + yOffset: 0, + }, + csymParensLeftVeryTall: { + leftSideBearing: 0, + advanceWidth: 210, + yOffset: 250, + }, + csymParensRightVeryTall: { + leftSideBearing: -100, + advanceWidth: 111, + yOffset: 250, + }, + csymDiagonalArrangementSlash: { + leftSideBearing: -1, + advanceWidth: 990, + yOffset: 0, + }, + csymMinor: { + leftSideBearing: 0, + advanceWidth: 482, + yOffset: 0, + }, + csymMajorSeventh: { + leftSideBearing: 100, + yOffset: 0, + advanceWidth: 600, + }, + accidentalSharp: { + leftSideBearing: 0, + advanceWidth: 425, + yOffset: -422, + }, + accidentalFlat: { + leftSideBearing: -10, + advanceWidth: 228, + yOffset: -284, + } +} export function loadPetaluma() { - Font.load('Petaluma', PetalumaFont, CommonMetrics); + const metrics: FontMetrics = JSON.parse(JSON.stringify(CommonMetrics)); + const chordMetrics = metrics.chordSymbol; + if (chordMetrics) { + chordMetrics.glyphs = petalumaChordMetrics; + } + Font.load('Petaluma', PetalumaFont, metrics); }