[XeTeX] Xetex equiv to luatex's \directlua{}

Mike Maxwell maxwell at umiacs.umd.edu
Sat Mar 24 16:37:04 CET 2018


On 3/24/2018 6:13 AM, Philip Taylor (RHUoL) wrote:
> maxwell wrote:
>> I'm just finishing up a project that involved typesetting text in 
>> several languages, while outputting an XML file that defined in X/Y 
>> coordinates the position and size of the bounding box surrounding each 
>> line of text in the PDF.  [...] [I]s there any way I could have done 
>> something similar using xetex?  That is, called another programming 
>> language to output box positions and sizes.  I suppose it's possible 
>> to write to an XML file in xetex natively, but I'm not sure how I 
>> could get the positions and sizes of boxes. 
> 
> Is it possible that these three PdfTeX/XeTeX primitives might help :
>   *
>>     \pdfsavepos
>>     Saves the current location of the page in the typesetting stream.
>   *
>>     \pdflastxpos
>>     Retrieves the horizontal position saved by \pdfsavepos.
>   *
>>     \pdflastypos
>>     Retrieves the vertical position saved by \pdfsavepos.

Thanks--playing around last night, I found a way (I think) to do what I 
wanted to do using the \zsavepos macro in the zref package.  In case 
anyone is interested, there's an example here:
    https://tex.stackexchange.com/questions/10343/
What I still can't do is determine in xetex what the text contents of a 
box is.  I can do that in luatex; the Lua function nodeText() here--
    https://tex.stackexchange.com/questions/228312/
does that.  I don't think there's an equivalent in xetex.

Combining luatex and xetex, I think I have an (untested) solution to my 
problem: first running my document through luatex to get the line boxes 
and their contents, and then running it through xetex to get the proper 
shaping, telling it where to put each line box and what to put in the 
box.  Very much a kludge, and I suppose the output won't be perfectly 
justified, but for our purposes that won't matter.
-- 
    Mike Maxwell
    "My definition of an interesting universe is
    one that has the capacity to study itself."
          --Stephen Eastmond


More information about the XeTeX mailing list