-- no longer ok for mkiv: digits are not antykwa

local fraction = .25

local badones = {
    summationtext         = fraction,
    producttext           = fraction,
    integraltext          = fraction,
    uniontext             = fraction,
    intersectiontext      = fraction,
    unionmultitext        = fraction,
    logicalandtext        = fraction,
    logicalortext         = fraction,
    summationdisplay      = fraction,
    productdisplay        = fraction,
    integraldisplay       = fraction,
    uniondisplay          = fraction,
    intersectiondisplay   = fraction,
    unionmultidisplay     = fraction,
    logicalanddisplay     = fraction,
    logicalordisplay      = fraction,
    coproducttext         = fraction,
    coproductdisplay      = fraction,

    braceleftBig          = fraction,
    braceleftBigg         = fraction,
    braceleftbig          = fraction,
    braceleftbigg         = fraction,
    parenleftBig          = fraction,
    parenleftBigg         = fraction,
    parenleftbig          = fraction,
    parenleftbigg         = fraction,
    bracketleftBig        = fraction,
    bracketleftBigg       = fraction,
    bracketleftbig        = fraction,
    bracketleftbigg       = fraction,
    ceilingleftBig        = fraction,
    ceilingleftBigg       = fraction,
    ceilingleftbig        = fraction,
    ceilingleftbigg       = fraction,
    floorleftBig          = fraction,
    floorleftBigg         = fraction,
    floorleftbig          = fraction,
    floorleftbigg         = fraction,
    anglebracketleftBig   = fraction,
    anglebracketleftBigg  = fraction,
    anglebracketleftbig   = fraction,
    anglebracketleftbigg  = fraction,

    bracerightBig         = fraction,
    bracerightBigg        = fraction,
    bracerightbig         = fraction,
    bracerightbigg        = fraction,
    parenrightBig         = fraction,
    parenrightBigg        = fraction,
    parenrightbig         = fraction,
    parenrightbigg        = fraction,
    bracketrightBig       = fraction,
    bracketrightBigg      = fraction,
    bracketrightbig       = fraction,
    bracketrightbigg      = fraction,
    ceilingrightBig       = fraction,
    ceilingrightBigg      = fraction,
    ceilingrightbig       = fraction,
    ceilingrightbigg      = fraction,
    floorrightBig         = fraction,
    floorrightBigg        = fraction,
    floorrightbig         = fraction,
    floorrightbigg        = fraction,
    anglebracketrightBig  = fraction,
    anglebracketrightBigg = fraction,
    anglebracketrightbig  = fraction,
    anglebracketrightbigg = fraction,

    backslashBig          = fraction,
    backslashBigg         = fraction,
    backslashbig          = fraction,
    backslashbigg         = fraction,
}

local uglyones = {
    braceleft     = true,
    braceright    = true,
    vextendsingle = true,
    vextenddouble = true,
}

local recipes = {
    ["antykwa-math"] = {
        { name = "file:LatinModern-Math", features = "virtualmath-antykwa", main = true, parameters = false },
        --
        { name = "rm-anttr.tfm",  vector = "tex-mr", skewchar=0x7F },
        { name = "mi-anttri.tfm", vector = "tex-mi", skewchar=0x7F },
        { name = "mi-anttri.tfm", vector = "tex-it", skewchar=0x7F },
        { name = "mi-anttbi.tfm", vector = "tex-bi", skewchar=0x7F },
        { name = "rm-anttb.tfm",  vector = "tex-bf", skewchar=0x7F },
        { name = "sy-anttrz.tfm", vector = "tex-sy", skewchar=0x30, parameters = true, ignore = uglyones }, -- jmn = true
        { name = "sy-anttrz.tfm", vector = "extensible-jmn-private", skewchar=0x30 },
        { name = "file:AntykwaTorunska-Regular", vector = "tex-ex-braces", backmap = false },
        { name = "ex-anttr.tfm",  vector = "tex-ex", extension = true, badones = badones, ignore = uglyones },
    },
    ["antykwa-light-math"] = {
        { name = "file:LatinModern-Math", features = "virtualmath-antykwa-light", main = true, parameters = false },
        --
        { name = "rm-anttl.tfm",  vector = "tex-mr", skewchar=0x7F },
        { name = "mi-anttli.tfm", vector = "tex-mi", skewchar=0x7F },
        { name = "mi-anttli.tfm", vector = "tex-it", skewchar=0x7F },
        { name = "mi-anttri.tfm", vector = "tex-bi", skewchar=0x7F },
        { name = "rm-anttr.tfm",  vector = "tex-bf", skewchar=0x7F },
        { name = "sy-anttlz.tfm", vector = "tex-sy", skewchar=0x30, parameters = true, ignore = uglyones }, -- jmn = true
        { name = "sy-anttlz.tfm", vector = "extensible-jmn-private", skewchar=0x30 },
        { name = "file:AntykwaTorunskaLight-Regular", vector = "tex-ex-braces", backmap = false },
        { name = "ex-anttl.tfm",  vector = "tex-ex", extension = true, badones = badones, ignore = uglyones },
    },
    ["antykwa-cond-math"] = {
        { name = "file:LatinModern-Math", features = "virtualmath-antykwa-cond", main = true, parameters = false },
        --
        { name = "rm-anttcr.tfm",  vector = "tex-mr", skewchar=0x7F },
        { name = "mi-anttcri.tfm", vector = "tex-mi", skewchar=0x7F },
        { name = "mi-anttcri.tfm", vector = "tex-it", skewchar=0x7F },
        { name = "mi-anttcbi.tfm", vector = "tex-bi", skewchar=0x7F },
        { name = "rm-anttcb.tfm",  vector = "tex-bf", skewchar=0x7F },
        { name = "sy-anttcrz.tfm", vector = "tex-sy", skewchar=0x30, parameters = true, ignore = uglyones }, -- jmn = true
        { name = "sy-anttcrz.tfm", vector = "extensible-jmn-private", skewchar=0x30 },
        { name = "file:AntykwaTorunskaCond-Regular", vector = "tex-ex-braces", backmap = false },
        { name = "ex-anttcr.tfm",  vector = "tex-ex", extension = true, badones = badones, ignore = uglyones },
    },
    ["antykwa-light-cond-math"] = {
        { name = "file:LatinModern-Math", features = "virtualmath-antykwa-lightcond", main = true, parameters = false },
        --
        { name = "rm-anttcl.tfm",  vector = "tex-mr", skewchar=0x7F },
        { name = "mi-anttcli.tfm", vector = "tex-mi", skewchar=0x7F },
        { name = "mi-anttcli.tfm", vector = "tex-it", skewchar=0x7F },
        { name = "mi-anttcri.tfm", vector = "tex-bi", skewchar=0x7F },
        { name = "rm-anttcr.tfm",  vector = "tex-bf", skewchar=0x7F },
        { name = "sy-anttclz.tfm", vector = "tex-sy", skewchar=0x30, parameters = true, ignore = uglyones }, -- jmn = true
        { name = "sy-anttclz.tfm", vector = "extensible-jmn-private", skewchar=0x30 },
        { name = "file:AntykwaTorunskaCondLight-Regular", vector = "tex-ex-braces", backmap = false },
        { name = "ex-anttcl.tfm",  vector = "tex-ex", extension = true, badones = badones, ignore = uglyones },
    },
}

local tweaks = nil
local common = fonts.goodies.load("common-math-jmn.lfg")

if common then

    tweaks = {
        {
            tweak  = "addmissing",
            action = common.mathematics.helpers.addmissing,
        },
        {
            tweak = "setoptions",
            set   = { "ignorekerndimensions" }
        }, -- we have dp > ht fences
        {
            tweak = "wipecues",
        },
        {
            tweak  = "fixprimes",
            factor = 1.0, -- accent base height
            fake   = 0.9, -- replace multiples with this width proportion
        },
        {
            tweak = "addequals",
            force = true,
        },
        {
            tweak = "addfourier",
        },
        {
            tweak = "addcomposites",
        },
        {
            tweak = "keepbases",
--             list  = { 0x302 }
            list  = "default"
        },
    }

    common.mathematics.helpers.copyrecipes(recipes)

end

return {
    name = "antykwa-math",
    version = "1.00",
    comment = "Goodies that complement antykwa math.",
    author = "Hans, Mojca, Aditya, Mikael",
    copyright = "ConTeXt development team",
    mathematics = {
parameters = {
    RadicalKernAfterExtensible = 100,
    RadicalKernBeforeExtensible = 100,
},
        mapfiles = {
            "antt-rm.map",
            "antt-mi.map",
            "antt-sy.map",
            "antt-ex.map",
         -- "mkiv-base.map",
        },
        variables = {
            notshiftfactor = 0.075,
        },
        virtuals = {
            ["antykwa-math"]               = { recipe = recipes["antykwa-math"],            tweaks = tweaks },
            ["antykwa-light-math"]         = { recipe = recipes["antykwa-light-math"],      tweaks = tweaks },
            ["antykwa-cond-math"]          = { recipe = recipes["antykwa-cond-math"],       tweaks = tweaks },
            ["antykwa-light-cond-math"]    = { recipe = recipes["antykwa-light-cond-math"], tweaks = tweaks },

            ["antykwa-math-nt"]            = common and { recipe = recipes["antykwa-math-nt"]            } or nil,
            ["antykwa-light-math-nt"]      = common and { recipe = recipes["antykwa-light-math-nt"]      } or nil,
            ["antykwa-cond-math-nt"]       = common and { recipe = recipes["antykwa-cond-math-nt"]       } or nil,
            ["antykwa-light-cond-math-nt"] = common and { recipe = recipes["antykwa-light-cond-math-nt"] } or nil,
        },
    }
}
