[Dev-luatex] The hpack_filter callback

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Tue Apr 29 10:11:35 CEST 2008

Hello,

in the following PlainTeX example, I try to access all \hboxes
created by TeX by using the hpack_filter callback:

---------------------------------------------------------------

%&luatex
\directlua0{
ptype)
print()
print(group, size / 65536, ptype)
return true
end)
}

% From Wikipedia:
Beneath a Steel Sky is a British 1994 science fiction point and click
adventure game in the cyberpunk genre. It featured comedy elements and
Interactive Entertainment. It was initially released for DOS and
Amiga. Underworld was its working title.

The game was the second to use Revolution Software's Virtual Theatre
engine, the first being Lure of the Temptress.

The game's backgrounds and introduction sequence were designed by Dave
Gibbons. The introduction sequence was also included as a separate
promotional comic book in some releases of the game.

The game is considered to be among the true classics in the early era
of graphic adventure games for the early 1990s. This, in part, is
related to the mature science fiction theme that was chosen for this
game as compared to other games of the same era where fantasy themes
(a la King's Quest) had been dominant. Some critics have attributed
this difference to the different visions of the adventure game genre
between American and European developers.

\bye

This results in:

This is LuaTeX, Version snapshot-0.25.2-2008041019 (Web2C 7.5.6)
(HPackFilter.tex

[1] )
Output written on HPackFilter.dvi (1 page, 2152 bytes).
Transcript written on HPackFilter.log.

---------------------------------------------------------------

Why does the filter not get called more often, namely once for every
line in the output file?

Background: I want to calculate the width of the last line of a
paragraph so I can adjust spacing following this paragraph
accordingly (a bit like display math does it). I tried the
buildpage_filter but did not know how to calculate the width of
the last \hbox in the list without the \parfillskip glue at the
end.

Which leads me to another question: When having a \hbox node list,
how to I determine the horizontal (when typesetting horizontally)
resp. vertical (when typesetting vertically) position of a node
relative to the left/top edge of the \hbox? I would think that
after line breaking, each node should know this position, but
how do I access it?

Jonathan