[luatex] How to insert mathkerns?

Hans Hagen j.hagen at xs4all.nl
Sat Sep 15 10:53:49 CEST 2018


On 9/15/2018 7:50 AM, Henri Menke wrote:
> Dear list,
> 
> I'm trying to add mathkerns to a font on the fly.  I adapted the code
> from ConTeXt in good-mth.lua but nothing happens.  How can I make this
> work?  MWE below.
> N.B. I'm using 1.09.0 svn6938 with Ulrike's fontloader 2018-09-01
> 
> Cheers, Henri
> 
> ---
> 
> \input luaotfload.sty
> \directlua{
> function kern_right_fence(tfmdata)
>      if tfmdata.mathparameters then
>          local characters = tfmdata.characters
>          if characters[0x1D44E] then % we have at least an italic a
>              print("PATCHING FONT " .. tfmdata.psname)
>              characters[0x1D453].mathkerns = {
>                  force = true,
>                  bottomright = { { kern = 1000 } },
>              }
>          end
>      end
> end
> %
> luatexbase.add_to_callback("luaotfload.patch_font",
>                             kern_right_fence,
>                             "kern right fence")
> }
> 
> \font\lmmath="Latin Modern Math:script=math;" at 10pt
> \textfont0=\lmmath
> 
> \Umathcodenum`e="1D452
> \Umathcodenum`f="1D453
> \Umathcodenum`g="1D454
> 
> $efg$

I don't know how the plugs in otfload work but it's more something like

characters[0x1D453].math =
   { kerns = { bottomright = { { kern = 1000 } } }

where of course you need to make sure that when there is already a math 
table you add instead of replace; eventually that becomes something scaled

characters[0x1D453].mathkern.bottom_right = ...

don't confuse a higher level context interface with low level font 
properties

Hans


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


More information about the luatex mailing list