[luatex] callbacks in luatex 0.89

Hans Hagen pragma at wxs.nl
Thu Feb 11 20:04:52 CET 2016

On 2/11/2016 6:00 PM, Ulrike Fischer wrote:
> Am Thu, 11 Feb 2016 14:53:11 +0100 schrieb Hans Hagen:
>>> Is there in context code which offers something similar to
>>> \XeTeXinterchartoks? That means can one declare (unicode)
>>> blocks/classes of characters and tokens (e.g. font switches,
>>> language switches etc) which should be inserted between character of
>>> different blocks?
>>> If yes, where is it?
>> No, because it's not the way context does things (or at least I never
>> needed it so I never bothered to look into writing it). I would probably
>> look into it when there was demand for some feature not supported yet.
>> Even then I'd probably not rely interpreting unicode characters but on
>> proper tagging because one never knows what the intended use/rendering
>> of some character at some point it.

> Proper tagging is naturally always more reliable. But I can
> understand that people who write e.g. a mix of chinese with some
> english/ascii and need to switch fonts don't want to tag all the
> time. That can get a bit tiring, also it is error prone.

(context users are advised to quit reading here)

well, as the latin mixed in chinese text often looks quite horrible i 
assume basemode will do so you can make a file


containing this

return function(specification)
     local t = { }
     for k, v in pairs(specification.features.normal) do
         local n = tonumber(k)
         if n then
             t[n] = v
     for k, v in ipairs(t) do
         local name, rest = string.match(v,"^(.-):(.*)$")
         if rest then
             t[k] = { name = name, list = { } }
             for s in string.gmatch(rest,"([^%+]+)") do
                 local b, e = string.match(s,"^(.-)%-(.*)$")
                 if b and e then
                     b = tonumber(b)
                     e = tonumber(e)
                     b = tonumber(s)
                     e = b
                 if b and e then
                     table.insert(t[k].list,{ b = b, e = e })
             t[k] = { name = v }
     local ids = { }
     for k, v in ipairs(t) do
         local f, id
         if tonumber(v.name) then
             id = tonumber(v.name)
             f = fonts.hashes.identifiers[id]
             f, id = 
         v.f = f
         ids[k] = { id = id }
     local one = t[1].f
     if one then
         one.properties.name = specification.name
         one.properties.virtualized = true
         one.fonts = ids
         local chr = one.characters
         for n, v in ipairs(t) do
             if n == 1 then
                 -- use font 1 as base
             elseif v.list and #v.list > 0 then
                 local chrs = v.f.characters
                 for k, v in ipairs(v.list) do
                     for u=v.b,v.e do
                         local c = chrs[u]
                         if c then
                             c.commands = {
                                 { 'slot', n, u },
                             chr[u] = c
                 for u, c in ipairs(v.f.characters) do
                     c.commands = {
                         { 'slot', n, u },
                     chr[u] = c
     return one

after which you can do something

   \font\crapa=lmroman10-regular:mode=base;liga=yes; at 12pt
     \font\crapb=lmsans10-regular:mode=base;liga=yes;  at 30pt
at 12pt
at 12pt

     \mine Zomaar een eindje fiets! En dan weer terug.

or worse (but let's assume some proper interfacing)

> The second case where \XeTeXinterchartoks is used is for spacing at
> punctuation, e.g. in french. This can be done with attributes
> (frenchb.ldf in latex uses it). The main difference is to the xetex
> method is that almost every normal user can unterstand
> \XeTeXinterchartoks and set it up, while the lua method needs more
> knowledge.

that is a matter of interfacing, just add some tex wrapper code; and 
when one chooses for an engine one also chooses for its methods (so of a 
user likes \XeTeXinterchartoks more that that user should use xetex as 
it fits the mindset best)

(the xetex method probably also has its confusions like where/when 
applied/expanded and such just as a luatex method has its characteristics)


                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl

More information about the luatex mailing list