[texhax] visualize font expansion

Paul Isambert zappathustra at free.fr
Tue Jun 21 17:05:01 CEST 2011

Le 21/06/2011 16:16, Arno Trautmann a écrit :
> Hi all,
> I was just having some fun with Paul Isamert's nice article in the
> TUGboat 31, 3.

`Isambert', actually, but thanks for the appreciation :)

> 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?

That's a field I've been wondering about for some time now, and perhaps 
even had an answer once (from Taco or my own investigations) and have 
forgotten it...

Anyway that's apparently not the right field, or there is some trouble 
with its value for the moment. But you can compare your (expanded) glyph 
node's width with its normal width in the font. Suppose you're 
investigating node N, then:

N.width % Expanded width in scaled points
font.getfont(font.current()).characters[N.char].width % Original width 
in scaled point.

Why not use N's font, i.e.:

? Because N's font isn't the original font, but a virtual expanded one 
(so to speak). So you have to make do with the current font, which of 
course is the current font at the end of the paragraph, so perhaps it's 
not the best one... (Or you can link real font to expanded ones at font 
loading time, but that's another thing.)

Hope I haven't said too many false things, I haven't investigated those 
things lately.


> 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
>        tex.write(exp_factor)
>        end
>      end
>    end
>    return head
> end
> I'd be happy if anyone could point me to my mistakes,
> cheers
> Arno
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/
> More links: http://tug.org/begin.html
> Automated subscription management: http://tug.org/mailman/listinfo/texhax
> Human mailing list managers: postmaster at tug.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/texhax/attachments/20110621/266a2fed/attachment.html>

More information about the texhax mailing list