paulrosen / abcjs

javascript for rendering abc music notation
Other
1.93k stars 284 forks source link

Custom formatting for annotations #831

Open alensiljak opened 2 years ago

alensiljak commented 2 years ago

I am using annotations a lot for almost all the text on the sheets, within the score - lyrics, instrument changes, riterdando marks, bar numbers, etc.

Currently, all the annotations are formatted the same. Considering the different purposes of each type of annotation, it would be great to be able to customize the font used for them.

Ideally, it would be possible to define a style, including:

and apply to annotation text within the quotes in the score section of the sheet.

Reference: Section 11.4.2 Font directives

The %%setfont-n + $n-syntax does not seem to work with annotations at the moment.

Staff2Stand commented 9 months ago

Just wanted to resurrect this.
There is the %%annotationfont directive but I can't seem to get that to work.

Did you find a solution to this?

alensiljak commented 9 months ago

Did you find a solution to this?

Yes and no. :) No with abc but yes with MuseScore or Lilypond, depending on the context/project. Horses for courses.

Staff2Stand commented 9 months ago

Okay. I'm thinking maybe there's a way to add a custom class to the <tspan> in the afterParsing function. This way we could parse for something like"{{italic}}pizz", remove the "{{italic}}" and give the tspan an .abcjs-italic class and control it in css.

paulrosen commented 9 months ago

If you put this in the header you can change the annotations globally:

%%annotationfont italic 16

But it sounds like you want to change them on the fly. The following will work with the %%text and the W: field:

%%setfont-1 italic 16
%%text some text $1in italic $0 and regular
W: some text $1in italic $0 and regular

But not in annotations. I am planning a small release for this week and I'll see if I can get the following to work:

"^some text $1in italic $0 and regular"A4

That's what you are looking for, right?

Staff2Stand commented 9 months ago

Yes that is what I’m looking for! It would also be nice to be able to pass the setfonts into the abcjsParams, but I could always append it to the header in after parsing

On Sat, Jan 20, 2024 at 5:40 PM Paul Rosen @.***> wrote:

If you put this in the header you can change the annotations globally:

%%annotationfont italic 16

But it sounds like you want to change them on the fly. The following will work with the %%text and the W: field:

%%setfont-1 italic 16 %%text some text $1in italic $0 and regular W: some text $1in italic $0 and regular

But not in annotations. I am planning a small release for this week and I'll see if I can get the following to work:

"^some text $1in italic $0 and regular"A4

That's what you are looking for, right?

— Reply to this email directly, view it on GitHub https://github.com/paulrosen/abcjs/issues/831#issuecomment-1902304714, or unsubscribe https://github.com/notifications/unsubscribe-auth/A63GOMCI6OD2WGKTTQLDEJLYPRBU3AVCNFSM6AAAAAARANYHPGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBSGMYDINZRGQ . You are receiving this because you commented.Message ID: @.***>

paulrosen commented 9 months ago

That's a good idea.