[luatex] line break reassigns font id with expansion

Paul Isambert zappathustra at free.fr
Sun May 5 15:56:04 CEST 2013


Philipp Gesang <philipp.gesang at alumni.uni-heidelberg.de> a écrit:
> Hi all,
> 
> with expansion enabled, line breaking assigns new font ids to
> glyph nodes. Example for luatex-plain:
> 
> ·································································
> %\font\somefont=file:Iwona-Regular.otf
> \font\somefont=file:Iwona-Regular.otf:expansion=default;
> \somefont
> \pdfadjustspacing=2
> \catcode`\%=11
> 
> \directlua{
>   local glyph_t    = node.id"glyph"
>   local hlist_t    = node.id"hlist"
>   local vlist_t    = node.id"vlist"
>   local sub_box_t  = node.id"sub_box"
> 
>   local show_font_id
>   show_font_id = function (hd, when, nested)
>     for n in node.traverse(hd) do
>       local n_id = n.id
>       if n_id == glyph_t then
>         local n_font = n.font
>         local tfmdata = font.getfont(n_font)
>         print(string.format(
>               "(%s (rec %s) (byte %d) (chr %s) (font %s) (tfmdata %s))",
>               when,
>               nested,
>               n.char,
>               unicode.utf8.char(n.char),
>               n_font,
>               tfmdata))
>       elseif n_id == hlist_t or n_id == vlist_t or n_id == sub_box_t then
>         show_font_id(n.list, when, true)
>       end
>     end
>     return hd
>   end
>   callback.register(
>     "pre_linebreak_filter",
>     function (hd) return show_font_id(hd, "pre_line") end)
>   callback.register(
>     "post_linebreak_filter",
>     function (hd) return show_font_id(hd, "post_line") end)
>   callback.register(
>     "pre_output_filter",
>     function (hd) return show_font_id(hd, "pre_out") end)
> }
> 
> \hsize 1cm
> 
> foo bar
> 
> \bye
> ·································································
> 
> On my machine (version beta-0.76.0-2013040516), all glyphs have
> font 51 initially. During line breaking, those glyphs that are
> subject to expansion get reassigned font 53 or 54. I’m not sure
> whether this is caused by the font loader or the engine itself.
> Anyways, the font loader doesn’t create entries for font ids 53
> and 54 in fonts.hashes.identifiers.
> 
> My question is thus: is there a way to get the original font id
> of an expanded glyph after line breaking, or at least to get the
> corresponding tfmdata?

I can’t compile your example but it sounds like the original PDFTeX
implementation of expansion with several fonts (now triggered only if
“autoexpand” is missing in the \pdffontexpand call). Why it should be
so, I really don’t know, but at least you can test the idea with:

    \directlua{
      texio.write_nl(tostring(font.getfont(font.id("somefont")).auto_expand))
    }

(Note that I’d be surprised to be right.)

Best,
Paul



More information about the luatex mailing list