On 3/21/2017 5:44 PM, Csikos Bela wrote:
Dear context users:

Is it possible to disable a specific ligature in a whole document in mkiv?
I would like to disable fi ligature.
Does it make a difference if I use a true type font installed on my
system?

normally that is done by setting a language feature in the font

you can also cook up a new feature, like

    fonts.handlers.otf.addfeature {
        name    = "nofiligature1",
        type    = "chainsubstitution",
        nocheck = true,
        prepend = true,
        lookups = {
            {
                type = "multiple",
                data = {
                    ["f"] = { "f", 0x200C },
                 -- ["i"] = { "i" },
                },
            },
        },
        data = {
            rules = {
                {
                 -- current = { { "f" }, { "i" } },
                 -- lookups = { 1, 1 },
                    current = { { "f" } },
                    after   = { { "i" } },
                    lookups = { 1 },
                },
            },
        }
    }

    fonts.handlers.otf.addfeature {
        name    = "nofiligature2",
        type    = "chainsubstitution",
        nocheck = true,
        append  = true,
        lookups = {
            {
                type = "ligature",
                data = {
                    ["f"] = { "f", 0x200C },
                },
            },
         -- {
         --     type = "substitution",
         --     data = {
         --         ["i"] = "i"
         --     },
         -- },
        },
        data = {
            rules = {
                {
                 -- current = { { "f" }, { 0x200C }, { "i" } },
                 -- lookups = { 1, 2 },
                    current = { { "f" }, { 0x200C } },
                    after   = { { "i" } },
                    lookups = { 1 },
                },
            },
        }
    }

Here the two step approach is needed to make sure you get proper kerning (given that a font has it, e.g pagella has between fe but not between ffe so ...).

Anyway, I've added a helper to the upcoming so that it's a bit easier:

\blockligatures[fi,ff]
\blockligatures[fl]

\definefontfeature
  [default]
  [default]
  [blockligatures=yes]

\setupbodyfont[pagella]

The only thing you need to keep in mind is that the \blockligature commands have to come before fonts get defined (has to do with shared resources and optimizations and such) and of course that you need to
enable the feature.

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
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to