[texhax] visualize font expansion

Arno Trautmann Arno.Trautmann at gmx.de
Wed Jun 22 10:21:09 CEST 2011


Paul Isambert wrote:
>   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

I did:

  for line in node.traverse_id(HLIST,head) do
    g = line.head
    while not(g.next == nil) do
      g = g.next
      if g.id == 37 then
        act_width = g.width
        normal_width =
font.getfont(font.current()).characters[g.char].width
        exp_factor = act_width / normal_width
      end
    end
  end

So, as far as I can see, the difference is that I load the font at each
comparison which seems to slow down things very much, especially for
some 30-line-paragraph. With your code, I don't see any speed loss, too.

Thanks again,

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/texhax/attachments/20110622/be751cd5/attachment.bin>


More information about the texhax mailing list