[texhax] visualize font expansion

Arno Trautmann Arno.Trautmann at gmx.de
Tue Jun 21 16:16:31 CEST 2011

Hi all,

I was just having some fun with Paul Isamert's nice article in the
TUGboat 31, 3. He posted some code to visualize the amount of badness of
a line via a color.
Now I wanted to extend that code to show the influence of font expansion
on the badness. It is already very impressive to see how the greyness of
the page is much smoother when working with mircotype. However, I'd like
to colorize the amount of stretching/shrinking directly for each line. I
tried to access the expansion_factor field for the first glyph node in
each line, but I always get a "0" as result. So I assume, I'm doing
something stupid. Is expansion_factor the correct field after all?

I tried the (not very elaborated) code below, registered in the
post_linebreak_filter, using lualatex, microtype and luatexbase from the
latest TeXlive2010 with TLcontrib.

print_expansion_factor = function(head)
  for line in node.traverse_id(HLIST,head) do
    first_glyph = line.head
    while not(first_glyph.next == nil) do
      first_glyph = first_glyph.next
      if first_glyph.id == 37 then
        exp_factor = first_glyph.expansion_factor
  return head

I'd be happy if anyone could point me to my mistakes,


-------------- 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/20110621/301feec2/attachment.bin>

More information about the texhax mailing list