Skip to content

Commit

Permalink
xShift, new group name
Browse files Browse the repository at this point in the history
  • Loading branch information
mscuthbert committed Mar 7, 2024
1 parent 358b7d2 commit c3de656
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export class Lyric extends prebase.ProtoM21Object {
if (style.color) {
annotation.setFill(style.color);
}
if (style.xShift) {
annotation.setXShift(-1 * style.xShift); // VF measures backwards
}
annotation.setTextLine(5 - lyric_line + (this.number ?? 0) * 2);
return annotation;
}
Expand Down
6 changes: 4 additions & 2 deletions src/vfShims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ export class VFLyricAnnotation extends Annotation {
throw new Error('Can only add lyrics to SVG Context not Canvas');
}
const note = this.checkAttachedNote();
// const textFormatter = TextFormatter.create(this.textFont);
let x = note.getModifierStartXY(ModifierPosition.ABOVE, this.index).x;
if (this.horizontalJustification === AnnotationHorizontalJustify.LEFT) {
x -= note.getGlyphWidth() / 2;
}
if (this.getXShift()) {
x += this.getXShift();
}

this.setRendered();

Expand All @@ -104,7 +106,7 @@ export class VFLyricAnnotation extends Annotation {
// still need to save context state just before this, since we will be
// changing ctx parameters below.
this.applyStyle();
const g: SVGGElement = ctx.openGroup('annotation', this.getAttribute('id'));
const g: SVGGElement = ctx.openGroup('lyricannotation', this.getAttribute('id'));
ctx.setFont(this.textFont);
if (this.fill) {
ctx.setFillStyle(this.fill);
Expand Down

0 comments on commit c3de656

Please sign in to comment.