[luatex] Kerning: when does it not work?

Heilmann, Till A. till.heilmann at unibas.ch
Fri May 6 08:45:49 CEST 2011

On 05/05/2011 10:38 AM, Ulrike Fischer wrote:

> I think you will get away with most problems with
> \def\url{%
> 	\begingroup
> 	\catcode`\%=12
> 	\URL
> 	}
> \def\URL#1{%
> 	\setbox\urlbox=\hbox{%
> 	\directlua{%
> 	tex.sprint(-2,"\luatexluaescapestring{\unexpanded{#1}}")}}%
> .....
> You will still not be able to use a % in a footnote-url!

With Ulrike's modifications, Paul's code works just fine for me (see  
below). No URLs in footnotes containing a % character so far in my  
document... Pheww!

Thank you all, once again, and best regards,

\def\makeother#1{\catcode`#1=12 }



      local box = tex.box["urlbox"].list
      local glyf, disc = node.id("glyph"), node.id("disc")
      for n in node.traverse_id(disc, box) do
        node.remove(box, n)
      for n in node.traverse_id(glyf, box) do
        local b = url.breakpoints[n.char]
        if b == "before" then
          url.before(box, n)
        elseif b == "after" then
          url.after(box, n)
        elseif b == "both" then
          url.before(box, n)
          url.after(box, n)

local id, copy, insert_before, insert_after = node.id, node.copy,  
node.insert_before, node.insert_after

url = {}
url.breakpoints = {}
local penalty = node.new(id("penalty"))
penalty.penalty = 0

function url.before (l, n)
    if n.prev then
      if n.prev.id == id("kern") and n.prev.subtype == 0 then
        n = n.prev
      insert_before(l, n, copy(penalty))

function url.after(l, n)
    if n.next then
      insert_after(l, n, copy(penalty))

    \directlua{url.breakpoints[\the\numexpr`#1] = "#2"}%


More information about the luatex mailing list