Thanks Patrick for your code.

Apparently we do the same things (except your code is simply better), so there is no simple hard-coded function to do that. Which function I think might be a good idea, especially if it can process real TeX input, e.g. string_tolist("a\kern1em b"), perhaps with catcodes declared beforehand. So I'm kind of feature-requesting here, yes, yes, can't deny.

Patrick, is it on purpose you don't set "n.prev = last"? Is it useless or are you sure you'll simply never manipulate those node lists?

Thanks for lang.hyphenate() -- I realize there are areas of the manual I still haven't laid an eye on.

Best,
Paul

Le 18/11/2010 22:49, Patrick Gundlach a écrit :
Hi Paul,

i do something like this (pseudo code):

   local match = unicode.utf8.match

   for s in string.utfvalues(str) do
     char = unicode.utf8.char(s)
     if match(char,"%s") and last and last.id == 10 then -- is it 10, the glue 
node??
       -- double whitespace, \relax
     elseif match(char,"%s") then -- ws
       n = node.new("glue")
       n.spec = node.new("glue_spec")
       n.spec.width   = space -- calculated somewhere else
       n.spec.shrink  = shrink
       n.spec.stretch = stretch

       if head then
         last.next = n
       else
         head = n
       end
       last = n

     else
       n = node.new("glyph")
       n.font = ... (set somewhere else)
       n.char = s
       n.lang = 0
       n.left = tex.lefthyphenmin
       n.right = tex.righthyphenmin

       if head then
         last.next = n
       else
         head = n
       end
       last = n
     end
   end


and then I use node.kerning() for kerning and lang.hyphenate() for inserting 
disc nodes.


Patrick


Reply via email to