[luatex] inserting user-defined whatsit node
Stephan Hennig
sh-list at posteo.net
Mon Nov 17 18:19:58 CET 2014
Hi,
in the attached example, the hyphenate callback is used to scan for
glyph nodes corresponding to the character 'x'. If such nodes are
found, a copy of that node is inserted before the node in question
(effectively doubling all 'x'). This works fine.
It breaks, however, if a user-defined whatsit node is inserted instead
of a copy of a glyph node. Error message is
! Unidentified user defined whatsit.
The LuaTeX manual has this about user-defined whatsits:
The LuaTeX engine will simply step over such whatsits without
ever looking at the contents.
Why does the example break?
Best regards,
Stephan Hennig
% -*- coding: utf-8 -*-
\directlua{
% Declare constants.
local GLYPH = node.id('glyph')
local WHATSIT = node.id('whatsit')
local USER_DEFINED = node.subtype('user_defined')
local MYCHARCODE = string.byte('x')
local Ncopy = node.copy
local Nnew = node.new
local Ninsert_before = node.insert_before
local Ntraverse = node.traverse
% Create user-defined whatsit.
local what = Nnew(WHATSIT, USER_DEFINED)
what.user_id = 20141117
% Register callback.
callback.register('hyphenate',
function (head, tail)
for n in Ntraverse(head) do
if n.id == GLYPH and n.char == MYCHARCODE then
% Ninsert_before(head, n, Ncopy(n))
Ninsert_before(head, n, Ncopy(what))
end
end
lang.hyphenate(head, tail)
end
)
}
text
\bye
> This is LuaTeX, Version beta-0.79.1 (TeX Live 2014/W32TeX) (rev 4971) (format=luatex 2014.7.9) 17 NOV 2014 14:20
> restricted \write18 enabled.
> **udwhatsit.tex
> (./udwhatsit.tex [1{c:/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdftex.map
> }]
> ! Unidentified user defined whatsit.
> \plainoutput ...headline \pagebody \makefootline }
> \advancepageno \ifnum \out...
> <output> {\plainoutput
> }
> \supereject {-\par \penalty -\@MM
>
> \bye {-\par \vfill \supereject
> \end
> l.29 \bye
>
> ?
> )<<c:/texlive/2014/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
> Output written on udwhatsit.pdf (1 page, 10206 bytes).
>
> PDF statistics: 12 PDF objects out of 1000 (max. 8388607)
> 7 compressed objects within 1 object stream
> 0 named destinations out of 1000 (max. 131072)
> 1 words of extra memory for PDF output out of 10000 (max. 10000000)
>
More information about the luatex
mailing list