[luatex] Request for Callback
Keith J. Schultz
schultzk at gmx.net
Fri Jun 28 09:35:51 CEST 2013
Hi Élie,
I do not much about music, let alone Gregorian chants, yet I would look
at the chants or music as natural language.
In looking at them that way your problem comes down to the use of
grammar rules. TeX to my knowledge does not facilitate this.
Hans has already said it is possible to hook into the parbuilder mechanism
as in the case of arabic. He states that it slows down the process, yet I think
that is a payable price for the automatism and ease of use that you are looking for.
Your problem reminds me of the problem of typesetting text on an arbitrary
curve and in an arbitrary shape. The processes is described in his book over MetaFun.
What you do is get the size of the gylphs and calculate the rest. It is know how long
a line of music is and thereby can calculate how many of your notes fit on a line and which
note is at the end. Then you can adjust as need. This approach may seem as overkill, but would work.
Another route you might try is to look at the MusiTeX packages and try to port them to ConTexT.
I do not know if these packages facilitate the functionality that you need, but it might be a starting
point.
regards
Keith.
Am 27.06.2013 um 11:45 schrieb Élie Roux <elie.roux at telecom-bretagne.eu>:
> Dear All,
>
> I would like to propose a new callback.
>
> This callback would be called at linebreak time, it would be hooked after TeX makes a "proposal" for linebreaks and before it evaluates it, this would allow users to correct it and make the linebreak algorithm more flexible, without redefining it completely. I have to say I'm no expert in linebreaking and I'm not sure it cannot lead to infinite loops...
>
> The idea behind it is to allow the following: in Gregorian chant, if a flat is on a certain note, all these notes in the same syllable will be flatted; but flats won't be printed except if there is a new line inbetween. For example:
>
> Ok:
> syllable1(note1 note2) syllable2(note1 flat-note3 note4 note3)
>
> Ok:
> syllable1(note1 note2) syllable2(note1 flat-note3 note4 note3
> note 5 note 6)
>
> Ok:
> syllable1(note1 note2) syllable2(note1 flat-note3 note4 note3
> note5 flat-note3)
>
> NOk:
> syllable1(note1 note2) syllable2(note1 flat note3 note4 note3
> note5 note3)
>
> In the last case, I would have to add a flat (so that it's the same as in third case), this would be done in the same callback... I don't think I can handle that without hooking in linebreak_filter right?
>
> There is also something that I seem to be able to fix with discretionary but that would be great if it was fixeable in Lua: still in Gregorian chant, a clef change can happen in the middle of a line, but not at the beginning nor at the end. Let's say "cc" is a clef change:
>
> notes notes cc notes notes OK
> cc notes notes NOK
> notes notes cc NOK
>
> For the second and third case, the new clef will already be in a localleftbox, so it's useless to print it, it should simply be removed. If this new callback was present, I could remove the cc character before TeX evaluates if the linebreak is good or not...
>
> If you think this callback is a bad idea, is there somewhere an implementation of a librebreak_filter callback in Lua? It wouldn't have to be precisely the same implementation as TeX, it can be simplified...
>
> Thank you!
> --
> Elie
More information about the luatex
mailing list