[Dev-luatex] Possible issue with input from external libraries (page break problem?)

Graham Douglas graham.douglas at readytext.co.uk
Tue Apr 13 20:23:51 CEST 2010

Hi Taco

I have been experimenting with external C libraries by writing
Lua bindings under Windows --- DLLs.

I have noticed something I'd like to ask about ---
to know if it is expected behavior.

When these DLLs return text I'm doing a lot of tex.write(...)
of the data returned from the DLL functions (for testing).

What I've noticed is that when the text data from the DLL calls
is output (by tex.write()) and a page break occurs in the middle
of the tex.write() outputs calls, then the text is lost across the

Here I am guessing....>

It looks like if the page break machinery is called whilst the
text from the DLL is being output by tex.write() then something
temporarily "forgets??" that text data is still coming and so the
page break is losing data --- actually it looks like the incoming
tex.write() text simply carries on and falls off the page so you
lose it. Perhaps the page bbreak machinery is getting out of synch
with the tex.write() input. This is purely
guesswork and I could easily be wrong of course.

I can e-mail you (personally?) a sample PDF which is easier than trying
to explain this.

Is this something to be expected?

A minimal code example may not be that helpful  but
here is one. Here I have a binding to FreeType (I call it luatype)
and in this example it just dumps the glyph names reported
by FreeType:

\directlua {
require "luatype"
local result = 
tex.print(result.glyphs) %can also say you["glyphs"], as the same thing
for k,v in pairs(result) do tex.print(v.."  "..k) end

Here is binding to an XML library

\directlua 0  {
require "lxp"
text = [[<note>
<heading>Reminder <urgent> yes, very</urgent></heading>
<body>Don't forget me this weekend!</body>
local x=0
callbacks = {

     StartElement = function (p, s)
	tex.print("Starting element: ".. "{bf " ..s.. "}" .. " call depth = ".. 
x.. "par")
     EndElement = function (p, s)
     		tex.sprint("Finishing element: " .. "{it " ..s.. "}" ..  " call 
depth = ".. x.. "par")
     CharacterData = function (p, s)
         tex.sprint("Character data (may be white space) =  " .. "{itbf 
" ..s.. "}" .. "par")




If the tex.write() from output of either DLLs goes near a page break it
"falls off the page" and gets lost.

Apologies if this is not explained very well.

Please let me know if you want a PDF sample.

All the best


More information about the dev-luatex mailing list