[NTG-context] Addressing glyphs in Lua

Hans Hagen j.hagen at xs4all.nl
Wed Oct 10 10:26:14 CEST 2018


On 10/10/2018 8:46 AM, Marco Patzer wrote:
> On Tue, 9 Oct 2018 23:36:32 +0200
> Hans Hagen <j.hagen at xs4all.nl> wrote:
> 
>> On 10/9/2018 10:40 PM, Marco Patzer wrote:
>>> Hi!
>>>
>>> I have two questions regarding addressing glyphs in Lua:
>>>
>>> 1) How to address glyphs in slots as e.g. U+F0029?
>>> 2) How to address glyphs by name?
>>>
>>> Use:
>>>
>>> \startluacode
>>>     fonts.handlers.otf.addfeature {
>>>       name = "foo",
>>>       type = "substitution",
>>>       data      = { [0xF0029] = 0xF0030 }, -- ← doesn't work
>>>     }
>>> \stopluacode
>> this is a mnwe .. make a mwe with at least a font
> 
> Sorry, here it is:
> 
> \startluacode
>    fonts.handlers.otf.addfeature {
>      name = "phone",
>      type = "substitution",
>      data      = { [0x260E] = 0xF003A }, --  doens't work
>    }
> \stopluacode
> 
> \definefontfeature [phone] [phone=yes]
> 
> \definefallbackfamily [mainface] [serif] [MarVoSym] [range=0x260E,
> features=phone] \definefontfamily     [mainface] [serif] [TeX Gyre
> Pagella] \setupbodyfont        [mainface]
> 
> \starttext
>    substitution: \utfchar{"260E} %% black telephone
>    \blank direct:
>    \resolvedglyphdirect {name:marvosym}{n:Mobilefone} %% works
> \stoptext
> 
> %% glyph name and slot taken from
> %%
> %% \usemodule [fnt-10]
> %% \starttext
> %%   \ShowCompleteFont{name:marvosym}{10pt}{1}
> %% \stoptext
> 
>> ... anyway, glyph names should normally work (given that they are
>> sane ones, because in context we strip some)
> 
> The question is how to input the name in the Lua code (here:
> “Mobilefone”). And it seems like substitutions don't work beyond
> 0xFFFF.
(1) use glyph names, so Telefon here
(2) enable node mode
(3) force a nocheck

(in a next beta i'll also support the P<original private> lookup for 
feature extensions)

\startluacode
fonts.handlers.otf.addfeature {
     name    = "phone",
     type    = "substitution",
     nocheck = true,
     data    = { [0x260E] = "Telefon" },
}
\stopluacode

\definefontfeature [phone] [mode=node,phone=yes]

\definefallbackfamily [mainface] [serif] [MarVoSym] [range=0x260E, 
features=phone]
\definefontfamily     [mainface] [serif] [TeX Gyre Pagella]
\setupbodyfont        [mainface]

\starttext
   substitution: \utfchar{"260E}                      %% black telephone
   \blank direct:
   \resolvedglyphdirect {name:marvosym}{n:Mobilefone} %% works
   \resolvedglyphdirect {name:marvosym}{n:PF003A}     %% works
   \resolvedglyphdirect {name:marvosym}{n:Telefon}    %% works
\stoptext


-----------------------------------------------------------------
                                           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 ntg-context mailing list