[NTG-context] GSUB LookupType 6 in fea file not working

Hans Hagen pragma at wxs.nl
Thu Jan 7 13:43:02 CET 2016


On 1/6/2016 5:28 PM, Paolo Brasolin wrote:
> Hello.
>
> I am trying to add some custom ligatures to a font using a feature file.
> Everything works just fine, until I try what is called a chained
> contextual substitution, i.e. a GSUB lookup of type 6.
> I am studying the specs from
> http://www.adobe.com/devnet/opentype/afdko/topic_feature_file_syntax.html#5.f
>
> A simple example.fea that does not work for me is:
>
>
> languagesystem dflt dflt;
>
> lookup FOOBAR {
>    sub B by Q ;
> } FOOBAR;
>
> feature foba {
>    sub [A] B' lookup FOOBAR;
> } foba ;
>
>
> I'd expect it to replace B with Q only when preceeded by A.
> The same rule expressed with a lookup of type 8 works just fine:
>
>
> languagesystem dflt dflt;
>
> feature foba {
>    sub [A] B' by Q;
> } foba ;
>
>
> Ultimately I would need to use multiple inline lookups, something like
>    sub [A]' B' lookup FOO C' lookup BAR;
>
> Are inline lookups unsupported by the engine?
> That would seem strange to me.
> I'm probably missing some point, but I'm unable to find more documentation.
> Am I using the wrong syntax?

As we have a way to define additional features in context i played a bit 
with contextual lookups. As a result we now have an additional type 
chainsubstitution. In due time I will document this better (once it's 
settled). I still need to think of a way to kick this into place at a 
specific location in the sequence.

Btw, contrary to fea extensions (not supported in the new font loader 
anyway) these are runtime extensions i.e. not cached.

I'll upload a beta.

----------------------------------------------------------------------

\startluacode
     fonts.handlers.otf.addfeature {
         name = "stest",
         type = "substitution",
         data = {
             a = "X",
             b = "P",
         }
     }
\stopluacode

\startluacode
     fonts.handlers.otf.addfeature {
         name = "atest",
         type = "alternate",
         data = {
             a = { "X", "Y" },
             b = { "P", "Q" },
         }
     }
\stopluacode

\startluacode
     fonts.handlers.otf.addfeature {
         name = "mtest",
         type = "multiple",
         data = {
             a = { "X", "Y" },
             b = { "P", "Q" },
         }
     }
\stopluacode

\startluacode
     fonts.handlers.otf.addfeature {
         name = "ltest",
         type = "ligature",
         data = {
             ['1'] = { "a", "b" },
             ['2'] = { "d", "a" },
         }
     }
\stopluacode

\startluacode
     fonts.handlers.otf.addfeature {
         name = "ktest",
         type = "kern",
         data = {
             a = { b = -500 },
         }
     }
\stopluacode

\startluacode
     fonts.handlers.otf.addfeature {
         name    = "ytest",
         type    = "chainsubstitution",
      -- flags   = { false, false, false, false },
         lookups = {
             {
                 type = "substitution",
                 data = {
                     ["b"] = "B",
                     ["c"] = "C",
                 },
             },
         },
      -- steps    = {
      --     {
      --         rules = {
      --             {
      --                 before  = { { "a" } },
      --                 current = { { "b", "c" } },
      --                 lookups = { 1 },
      --             },
      --         },
      --     },
      -- },
         data = {
             rules = {
                 {
                     before  = { { "a" } },
                     current = { { "b", "c" } },
                     lookups = { 1 },
                 },
             },
         },
     }
\stopluacode

\definefontfeature[stest][stest=yes]
\definefontfeature[atest][atest=yes]
\definefontfeature[mtest][mtest=yes]
\definefontfeature[ltest][ltest=yes]
\definefontfeature[ktest][ktest=yes]
\definefontfeature[ytest][ytest=yes]

\starttext

\startTEXpage
     \definedfont[file:dejavu-serif.ttf*default]%
                   abracadabra\par
     {\addff{stest}abracadabra\par}
     {\addff{atest}abracadabra\par}
     {\addff{mtest}abracadabra\par}
     {\addff{ltest}abracadabra\par}
     {\addff{ktest}abracadabra\par}
     \enabletrackers[otf.*]
     {\addff{ytest}abracadabra\par}
     \disabletrackers[otf.*]
\stopTEXpage

\stoptext



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


More information about the ntg-context mailing list