[luatex] Request for Callback

Élie Roux elie.roux at telecom-bretagne.eu
Thu Jun 27 11:45:29 CEST 2013


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