[luatex] callbacks in luatex 0.89

Hans Hagen pragma at wxs.nl
Fri Feb 12 12:38:55 CET 2016

On 2/12/2016 12:05 PM, Ulrike Fischer wrote:
> Am Thu, 11 Feb 2016 20:04:52 +0100 schrieb Hans Hagen:
>> 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)
> I'm feeling like the wild girl who spoils the wellbehaved children
> ;-)
>> well, as the latin mixed in chinese text often looks quite horrible i
>> assume basemode will do so you can make a file
>>     crapfont.lua
> This works fine in context but not with plain or latex in a current
> texlive, I get a "metric data not found or bad" error. So it
> problably uses either features not present in the generic fontloader
> of luaotfload, or features of a newer luatex. How stable is the

i don't know ... you should ask PG how to access the raw table (maybe 
it's wrapped, i don't know what luaotfload does)

> code? Will it still work in context in a year?

sure, it's rather basic code ... i just tested the plain version and i 
had to change a separator (context has a different specification interface)

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


     for k, v in ipairs(t) do
         local name, rest = string.match(v,"^(.-)%+(.*)$")

works ok (of course one need to be a bit careful not to overwrite shared 
tables so

    local c = chrs[u]

might become

   local c = table.copy(chrs[u])

(idem in the other branch) etc etc but it was just demo code anyway

> But beside this I think it doesn't address the real problem. This is
> obviously not a replacement for proper tagging as it simply wants to
> avoid the need by using a better (fuller) font. But when you switch
> from chinese to english, the font is only one of the things that
> users probably want to do. Perhaps they want to changes spaces
> (around punctuation), fixed names, hyphenations patterns, add some
> pdf specials etc ...

one could use lua node list juggling for that .. that's the concept of 
luatex ... so one can have a mix of font and nodelist stuff ...

injecting stuff (at the user level) in the input stream in an 
uncontrolled way is messy anyway but if one really wants to do that, one 
can easily kick in a callback when reading the file and then add 
commands or whatever at unmarked script/language boundaries (after all 
it's mostly trying to make structure from non structure we're talking of)

and otherwise keep using xetex as there's nothing wrogn with doing that 
if it suits the user

> luatexja has the ability to mix fonts (e.g.
> http://tex.stackexchange.com/a/68252/2388), but I have no idea how
> they do it (most documentation is in japan).

i have no time to look into it ... context can mix and mess anyway and 
it is already years ago that i did that kind of stuff


                                           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