29.05.2014 Views

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

The history of luaTEX 2006–2009 / v 0.50 - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

ef-fe<br />

This means that in the node list we eventually nd something:<br />

[char e] [disc (f-) (f) (skip 1)] [liga ff (components f f)] [char<br />

e]<br />

So, eventually we need to kern between the character sequences [e,f-], [e,ff], [ff,e] and<br />

[f,e].<br />

attributes<br />

We now arrive at attributes, a new property <strong>of</strong> nodes. Before we explain a bit more what<br />

can be done with them, we show how to dene a new attribute and toggle it. In the<br />

following example the \visualizenextnodes macro is part <strong>of</strong> ConTEXt MkIV.<br />

\newattribute\aa<br />

\newattribute\ab<br />

\visualizenextnodes \hbox {\aa1 T{\ab3\aa2 E}X}<br />

For the sake <strong>of</strong> this example, we start the allocation at 200 because we don't want to<br />

interfere with attributes already dened in ConTEXt. <strong>The</strong> node list resulting from the box<br />

is shown at the next page. As you can see here, internally attributes become a linked list<br />

assigned to the attr eld. This means that one has to do some work in order to inspect<br />

attributes.<br />

function has_attribute(n,a)<br />

if n and n.attr then<br />

n = n.attr.next<br />

while n do<br />

if n.number == a then<br />

return n.value<br />

end<br />

n = n.next<br />

end<br />

else<br />

return false<br />

end<br />

end<br />

<strong>The</strong> previous function can be used in tests like:<br />

local total = 0<br />

while n do<br />

Nodes and attributes 71

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!