[luatex] inserting

Arno Trautmann Arno.Trautmann at gmx.de
Sun Jun 26 12:44:58 CEST 2011


Paul Isambert wrote:
> Le 25/06/2011 21:20, Arno Trautmann a écrit :
>> uppercasecolor = function (head)
>>    for line in node.traverse_id(HLIST,head) do
>>      for letter in node.traverse_id(GLYPH,line.head) do
>>          color_push.data = math.random().." .5 .5 rg"
>>          node.insert_before(line.head,letter,node.copy(color_push))
>>          node.insert_after(line.head,letter,node.copy(color_pop))
>>      end
>>    end
>>    return head
>> end
>>
>> This works fine /except/ for the first letter of every line except the
>> first line. So the first line is fine, but for every following line in a
>> paragraph, the first letter is not colored.
> 
> As already remarked by Khaled, you have to do:
> line.head = node.insert_before...
> The thing is the node is inserted, but the head field of the hlist still
> points to the old head, so the new head is ignored.

Ok, now I understand, and the code works, thanks! (just to clarify: it
worked for the first line, because there is another node before the
first glyph node, so my whatsit is not inserted as the first node of
that list?)

>>   I also get warnings
>>
>> LuaTeX warning: pop empty color page stack 0
>>
>> so it seems that the color_push does not work in that cases?
> 
> It is simply ignored, so the color stack is still empty when the first
> pop occurs.

Now that makes sense …

>>   But I don't
>> see what I'm doing wrong …
>> To understand what mistake I'm making, I tried to use
>>
>> letter = node.first_glyph(line) [or line.head?]
>>
>> instead of the for loop, but then letter doesn't seem to be a node at
>> all.
> 
> That should be node.first_glyph(line.head) (otherwise you browse over
> the list of nodes of which the line is part, not the list of nodes which
> is the contents of the line). But anyway node.first_glyph only finds
> glyph nodes (id 37) with subtype 1 (real glyphs). It's not quite clear
> to me what's the difference between a glyph-character (subtype 0) and a
> glyph-glyph (subtype 1), but the function is concerned with the latter
> only.

So that is ment by “with a subtype indicating it is a
glyph”. Indeed, I thought what I had were glyphs, but appearently they
are not. Do you have a suggestion where I can find information about this?

Thanks for your help again (also to Khaled),

cheers
Arno

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://tug.org/pipermail/luatex/attachments/20110626/38cd8781/attachment.bin>


More information about the luatex mailing list