Re: [Dev-luatex] \lastnodetype not working as expected in LuaTeX
Hans, my fluency in the linebreak algorithm is a little bit rusty. Are you saying that there are other points and stuff in that space that is not updated or more on the page builder side of the house? Or asked differently is there more that needs updating to make my little example work, and if so could that be already done through a workaround like I did with tex.nest[tex.nest.ptr].tail = node.tail(head) or would it absolutely need fixes in the program itself? thanks frank
On 11-6-2012 17:43, Frank Mittelbach wrote:
Hans,
my fluency in the linebreak algorithm is a little bit rusty. Are you saying that there are other points and stuff in that space that is not updated or more on the page builder side of the house?
More in the pagebuilder area where we have this insert stuff (which for that reason I mostly left for the future). In your case setting the prevdepth and prevgraf is indeed needed. Actually, you need: \def\partest {% \directlua {% function hpackparagraph (head) local h = node.hpack(head) tex.nest[tex.nest.level].prevgraf = 1 tex.nest[tex.nest.level].prevdepth = h.depth return h end callback.register("linebreak_filter", hpackparagraph) }% \par } btw, Internally the linebreaker is somewhat complicated by the fact that hz and protrusion play a role. I have a (lua) parbuilder prototype that gets rid of a lot of that code but Harmut needs time to implement a few things in the backend (will happen later this year) and that in turn will make the parbuilder cleaner. We also want systematic usage of left/rightskip nodes in broken lines so that we can have a more predictable model of a broken line.
Or asked differently is there more that needs updating to make my little example work, and if so could that be already done through a workaround like I did with
tex.nest[tex.nest.ptr].tail = node.tail(head)
or would it absolutely need fixes in the program itself?
Sort of. The returned -1 is now a signal that prevdepth has not been set and that is not something deliberate. However, the fact that you need to set prevdepth and prefgraf (maybe more) explicitly gives the possibility to manipulate those depth and graf parameters. So, in any code that uses the callback one needs to take care of these variables anyway. Hans p.s I remember that there has been some fixes to lastnode(type) so it might as well that at that time some buglet crept in. ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Frank, Here's the whole story: function oneliner(head) local h = node.hpack(head) local d = tex.baselineskip.width - tex.nest[tex.nest.ptr].prevdepth - h.height tex.nest[tex.nest.ptr].prevdepth = h.depth tex.nest[tex.nest.ptr].prevgraf = 1 local n if d < tex.lineskiplimit then n = 1 d = tex.lineskip else n = 2 end local s = node.new("glue_spec") local n = node.new("glue",n) s.width = d n.spec = s return node.insert_before(h,h,n) end -- the function also has to take care of adding proper skips -- before (and if needed after) and setting some parameters callback.register("linebreak_filter",oneliner) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hi Hans
Here's the whole story:
function oneliner(head) local h = node.hpack(head) local d = tex.baselineskip.width - tex.nest[tex.nest.ptr].prevdepth - h.height tex.nest[tex.nest.ptr].prevdepth = h.depth tex.nest[tex.nest.ptr].prevgraf = 1 local n if d < tex.lineskiplimit then n = 1 d = tex.lineskip else n = 2 end local s = node.new("glue_spec") local n = node.new("glue",n) s.width = d n.spec = s return node.insert_before(h,h,n) end
-- the function also has to take care of adding proper skips -- before (and if needed after) and setting some parameters
callback.register("linebreak_filter",oneliner)
I agree that this is what you need to do to get baselineskip etc being set. For my application it is not really necessary since I just want to get the paragrpah back as a single hline to be able to store it and thus am not at all interested in any of thoss. It makes sense to to set those parameters in any other situations (but then you could also think about taking out the inserts and vadjusts etc). However, I do not see you correcting the "tail" and if I understand it correctly that is something that can'T be done in "linebreak_filter" because the **wrong** setting is needed to find just_box the way the code currently works. So in my opinion the above is somehting that should be documented as part of the filter (that such values should be set by the routine) but the "tail" missing correction is in my opinion a bug and should be fixed in the code. So in my opinion the whole story (at the moment) also need to involve function fix_nest_tail (head) tex.nest[tex.nest.ptr].tail = node.tail(head) return true end callback.register("post_linebreak_filter",fix_nest_tail) cheers frank
participants (2)
-
Frank Mittelbach
-
Hans Hagen