[luatex] reverse node lists

Arno Trautmann Arno.Trautmann at gmx.de
Tue Nov 1 21:58:22 CET 2011


Heiko Oberdiek wrote:
> On Tue, Nov 01, 2011 at 06:07:59PM +0100, Arno Trautmann wrote:
>> Heiko Oberdiek wrote:
>>> A rotation using
>>> \rotatebox{...} with pdftex.def gives an example.
>>
>> There's no \rotatebox in pdftex.def, neither a \Grot at box@kv or
>> anything. But I guess that's not what you meant?
>
> Package graphics+pdftex.def.

Ok, I've tried to understand the definition of \rotatebox and what's 
going on, and partially was successfull … but I don't see how that can 
help me here now – if it's only about using pdf_save and _restore, I get 
along now.

Anyhow, for the following I stuck to pdf_literal (I want to use the last 
two parameters of cm later), but get the same result with _save, 
_setmatrix and _restore. And I don't like the result: In the first line 
of the second paragraph, I use the rotation once, which results in a 
shift of the /second/ line by the width of the rotated glpyh to the 
left. The third line is shifted even more, as in the second line I have 
more rotations (all uppercase letters). Something goes terribly wrong 
here, but I do not manage to understand my mistakes. So, I'd be happy 
for any explanation about what's going on here …

cheers
Arno

\documentclass{minimal}
\usepackage{luacode}

\begin{document}
Nicht geaenderter Absatz.\\
Mit zwei Zeilen.

\begin{luacode*}
function rotateglyph(head)

-- definition of the nodes used below
scor = node.new(11)      -- kern

rotstart = node.new(8,8) -- whatsit of type pdf_literal
rotstop = node.new(8,8) -- whatsit of type pdf_literal
rotstart.data = "q 0.87 -0.5 0.5 0.87 0 0 cm "
rotstop.data = " Q "
rotstart.mode = 0
rotstop.mode =  0
  -- with 1 or 2 for mode, the shift does not happen,
  -- but the glyphs are gone.

   for line in node.traverse_id(node.id"hhead",head) do
     for n in node.traverse_id(node.id"glyph",line.list) do
       if (n.char > 64 and n.char < 91) then -- uppercase letter
         scor.kern = n.width*0.87+n.height*0.5
         line.list =
           node.insert_before(line.list,n,node.copy(rotstart))
         node.insert_after(line.list,n,node.copy(scor))
         node.insert_after(line.list,n,node.copy(rotstop))
       end
     end
   end

   return head
end

luatexbase.add_to_callback("post_linebreak_filter",rotateglyph,"rotate")
\end{luacode*}

dies Hier ist ein blindtext zum testen von textausgaben.
wer diesen text liest, ist\\ selbst schuld.
Der Text gibt lediglich den Grauwert der Schrift
an. Ist das wirklich so oder kann auch ein anderer Text

\end{document}


More information about the luatex mailing list