[luatex] information about ligatures

Philipp Gesang philipp.gesang at alumni.uni-heidelberg.de
Sun Jan 5 19:03:37 CET 2014


···<date: 2014-01-05, Sunday>···<from: Paul Isambert>···

> Stephan Hennig <mailing_list at arcor.de> a écrit:
> > Am 31.12.2013 09:37, schrieb Paul Isambert:
> > > Stephan Hennig <mailing_list at arcor.de> a écrit:
> > > 
> > > Ligatures are char nodes (id 37) with special subtype 2, and they have
> > > a “components” field which is a nodelist containing the ligature’s
> > > components.
> > 
> > I have already read about subtype 2 and the components field, but have
> > never seen a glyph node of that subtype in pre_linebreak_filter.
> > Instead, I can see glyph nodes of subtype 256 corresponding to standard
> > Unicode ligatures, e.g., 0xfb02 (fl).  That is, bit 8 is set in subtype,
> > which I can't find any documentation about.  For that reason, I have
> > never checked the 'components' field, but it is indeed there.  Thanks!
> 
> [...]
> 
> > In fact, all top-level glyph nodes seem to be of subtype 256 in
> > pre_linebreak_filter.  What does that mean?  (You can find the full node
> > list corresponding to TeX input 'flavour specific office trick' at the
> > end of this mail.  With a proper font, the ck ligature is also present
> > there.)
> > 
> > Can somebody please provide TeX input that results in a glyph node with
> > bit 1 of subtype set?
> 
> My two cents is that you’re using luaotfload and that luaotfload sets
> “subtype” to 256 for some reason; you’ll see ligatures with proper
> subtype 2 if you let TeX do its job with fonts (so use TFM, obviously).
> E.g. this in plain TeX:
> 
>     \setbox0=\hbox{fi}
>     \directlua{%
>       texio.write_nl("This ligature has subtype " .. tex.box[0].head.subtype)
>     }
>     \bye
> 
> It should print “This ligature has subtype 2”.
> 
> Why luaotfload sets “subtype” to 256 – if that is indeed the case –, I
> really don’t know.

It depends on whether the “liga” feature is active and whether
you use base mode or node mode. E.g. in Context:

    \def \showligasubtype{%
      \fontname\font
      \setbox0=\hbox{fi}
      \startluacode
        context("This ligature has subtype " .. tex.box[0].head.subtype)
      \stopluacode
    }
    
    \definefontfeature [basemode]     [mode=base,liga=no]
    \definefontfeature [basemodeliga] [mode=base,liga=yes]
    \definefontfeature [nodemode]     [mode=node,liga=no]
    \definefontfeature [nodemodeliga] [mode=node,liga=yes]
    
    \starttext
      {\definedfont[file:lmroman10-regular.otf*basemode]\showligasubtype\endgraf}
      {\definedfont[file:lmroman10-regular.otf*basemodeliga]\showligasubtype\endgraf}
      {\definedfont[file:lmroman10-regular.otf*nodemode]\showligasubtype\endgraf}
      {\definedfont[file:lmroman10-regular.otf*nodemodeliga]\showligasubtype\endgraf}
    \stoptext
    
The values are:

      mode | liga
           |  -     +
      -----+--------
      base | 256     2
      node | 256   258

(Note that (node, +liga) = (base, +liga) + 256.) Outside Context
it depends on how you use the fontloader. E.g.:

    \ifdefined \luatexsuppresslongerror
      \input luaotfload.sty
    \fi
    \font \mainbase     = file:lmroman10-regular.otf:mode=base;-liga
    \font \mainbaseliga = file:lmroman10-regular.otf:mode=base;+liga
    \font \mainnode     = file:lmroman10-regular.otf:mode=node;-liga
    \font \mainnodeliga = file:lmroman10-regular.otf:mode=node;+liga
    
    \def \showligasubtype{%
      \fontname\font
      \setbox0=\hbox{fi}
      \directlua{
        tex.sprint("[", font.getfont(font.current()).properties.mode, "]")
        tex.sprint("This ligature has subtype " .. tex.box[0].head.subtype)
      }
    }
    
    {\mainbase     \showligasubtype \endgraf}
    {\mainbaseliga \showligasubtype \endgraf}
    {\mainnode     \showligasubtype \endgraf}
    {\mainnodeliga \showligasubtype \endgraf}
    
    \bye

Run this with the bare fontloader, you get

      mode | liga
           |  -     +
      -----+--------
      base | 256     2
      node | 256   256

With luaotfload, however, it’s

      mode | liga
           |  -     +
      -----+--------
      base | 256   258
      node | 256   256

Values >= 256 are due to the node processor calling
node.protect_glyphs() on the node list. (Grep the fontloader for
“protectglyphs”, Hans doesn’t like underscores.) I’m  not exactly
sure as to why Luaotfload differs from the bare fontloader, but
it’s likely due to some features being active by default.

Best regards,
Philipp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://tug.org/pipermail/luatex/attachments/20140105/a7523cae/attachment.bin>


More information about the luatex mailing list