[texhax] visualize font expansion

Paul Isambert zappathustra at free.fr
Wed Jun 22 08:49:36 CEST 2011


Le 21/06/2011 19:42, Arno Trautmann a écrit :
> Paul Isambert wrote:
>> But you can compare your (expanded) glyph
>> node's width with its normal width in the font. Suppose you're
>> investigating node N, then:
> Yes, that works fine, thank you! However, it is horribly slow – for some
> 10 lines it takes half a minute …

Could you post your code? There's no (noticeable) speed loss for me. 
Here's what I do:

\directlua{
callback.register("post_linebreak_filter",
   function (head)
     local f = font.getfont(font.current()).characters
     for l in node.traverse_id(0, head) do
       local g = l.head
       while not(g.id == 37) do
         g = g.next
       end
       texio.write_nl("Expansion: " .. g.width / f[g.char].width)
     end
     return head
   end)}

Best,
Paul


More information about the texhax mailing list