GSUB LookupType 6 in fea file not working
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.... 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? Thanks to anyone who can shed some light.
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....
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?
the new font loaders doesn't support fea files (i have a basic parser but it's not included as i'm still not sure if it should be .. fea files assume stable fonts and so) \usemodule[oldotf] might work ok for you Hans ----------------------------------------------------------------- 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 -----------------------------------------------------------------
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....
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 -----------------------------------------------------------------
That's really cool.
I ended up directly patching the font, but the patch itself would
probably be easier to produce with some scripting. I'll definitely
play around with your code.
Thanks Hans!
2016-01-07 13:43 GMT+01:00 Hans Hagen
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....
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 ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On 1/9/2016 6:36 PM, Paolo Brasolin wrote:
That's really cool. I ended up directly patching the font, but the patch itself would probably be easier to produce with some scripting. I'll definitely play around with your code. Thanks Hans!
It's kind of a coincidence that Luigi needed some positional hacking so i also added pair positioning (examples in test suite). Then in order to avoid putting lua code in the tex files I aded this: return { name = "cambria", version = "1.00", comment = "Goodies that complement cambria.", author = "Hans Hagen", copyright = "ConTeXt development team", extensions = { { name = "kern", -- adds to kerns type = "pair", data = { [0x0153] = { [0x0301] = { false, { -500, 0, 0, 0 } } }, } } } } so when a goodie file is loaded with the font (see type-imp-cambria) you get it automatically. Here an existing feature is extended. The only thing still needed is a way to push such a patch into the right spot (currently we append but one can say prepend=true). In due time we can add more interesting things.
2016-01-07 13:43 GMT+01:00 Hans Hagen
: 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....
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 ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Paolo Brasolin