[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
break.

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 = 
luatype.fontname("c:/msys/1.0/trunk/build/texk/fonts/type1/lucida/LBD.PFB")
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>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder <urgent> yes, very</urgent></heading>
<body>Don't forget me this weekend!</body>
</note>]]
local x=0
callbacks = {

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

p=lxp.new(callbacks)

}

\directlua{p:parse(text)}!.
\directlua{p:close()}


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

Graham












More information about the dev-luatex mailing list