[luatex] lua equivalent of vbox...ht
luigi scarso
luigi.scarso at gmail.com
Mon Sep 14 00:06:20 CEST 2009
On Sun, Sep 13, 2009 at 9:21 PM, Patrick Gundlach <patrick at gundla.ch> wrote:
> Hello all,
>
>>> what would be the lua equivalent of
>>>
>>> \setbox0\vbox{hello world}
>>> \the\ht0
>>>
>>> ? That is, what would I write inside \directlua{ ... } to get the same
>>> effect?
>>>
>>> Pseudo code appreciated.
>>>
>>> Patrick
>>>
>>
>> download last source
>> luatex-beta-0.43.0/manual/luatexref-t.pdf
>> and see 4.1.5 Box registers
>
> OK, let's start with a simple hbox. This very naive approach does not work:
>
> \directlua{
> % create to glyph nodes
> a=node.new(37)
> a.char=144
> a.font=1
>
> b=node.new(37)
> b.char=145
> b.font=1
>
> h,n=node.insert_after(nil,a,b)
>
> % turn it into an hbox:
> p=node.hpack(h)
>
> tex.setbox(0,p)
>
> texio.write_nl(tex.wd[0])
> % result: 0
> }
>
>
> What should I do? Any idea? Probably this would be obvious if I knew TeX
> internals. But I don't.
>
> Patrick
>
>
\starttext
\directlua{
% create to glyph nodes
T=node.new(37)
T.char=84
T.font=1
E=node.new(37)
E.char=69
E.font=1
h,n=node.insert_after(nil,T,E)
% turn it into an hbox:
p=node.hpack(h)
tex.setbox(0,p)
texio.write_nl(tex.wd[0])
% result: 523764
}
\box0
\stoptext
There is something wrong: \box0 is 'E' , not 'TE'
maybe this is not ok :
h,n=node.insert_after(nil,T,E)
--
luigi
More information about the luatex
mailing list