\startluacode

-- Ṯṯ Ḥḥ Ḫḫ Ḏḏ Šš Ṣṣ Ḍḍ Ṭṭ Ẓẓ Ġġ Āā Īī Ūū ʿ ʾ

local function process(characters,target,value)
    if value == "force" then
        return true
    elseif characters[target] then
        return false
    else
        return true
    end
end

local function below(characters,value,target,base,accent,left,down,depth)
    if process(characters,target,value) then
        local data1 = characters[base]
        local data2 = characters[accent]
        if data1 and data2 then
            characters[target] = {
                height   = data1.height,
                depth    = depth*data2.height,
                width    = data1.width,
                unicode  = target,
                commands = {
                    { "slot", 0, base },
                    { "left", left*(data2.width  or 0) + 0.5*(data1.width  or 0) },
                    { "down", down*(data2.height or 0) +     (data2.height or 0) },
                    { "slot", 0, accent },
                },
            }
        end
    end
end

local function ccrap(characters,value,target,base,template,scale,mirror)
    if process(characters,target,value) then
        local data1 = characters[base]
        local data2 = characters[template]
        if data1 and data2 then
            local height1 = data1.height
            local height2 = data2.height
            local width1  = scale * data1.width
            characters[target] = {
                height   = height2,
                depth    = 0,
                width    = width1,
                unicode  = target,
                commands = {
                    {
                        "offset",
                        mirror and width1 or 0,
                        height2 - (mirror and 0 or scale*height1),
                        base,
                        mirror and -scale or scale,
                        mirror and -scale or scale
                    },
                },
            }
        end
    end
end

-- in principle one can have some extra parameters for shifts but this
-- is suboptimal anyway and only meant for minion

local function initialize(tfmdata,feature,value)
    if value then
        local characters = tfmdata.characters

        below (characters,value,0x1E6E,0x054,0x0AF,0.50,0.07,0.20) -- Tlinebelow
        below (characters,value,0x1E6F,0x074,0x0AF,0.45,0.07,0.20) -- tlinebelow
        below (characters,value,0x1E24,0x048,0x2D9,0.50,0.10,0.30) -- Hdotbelow
        below (characters,value,0x1E25,0x068,0x2D9,0.50,0.10,0.30) -- hdotbelow
        below (characters,value,0x1E2A,0x048,0x2D8,0.50,0.10,0.35) -- Hbrevebelow
        below (characters,value,0x1E2B,0x068,0x2D8,0.50,0.10,0.35) -- hbrevebelow
        below (characters,value,0x1E0E,0x044,0x0AF,0.50,0.07,0.20) -- Dlinebelow
        below (characters,value,0x1E0F,0x064,0x0AF,0.40,0.07,0.20) -- dlinebelow
        below (characters,value,0x1E62,0x053,0x2D9,0.50,0.12,0.30) -- Sdotbelow
        below (characters,value,0x1E63,0x073,0x2D9,0.40,0.12,0.30) -- sdotbelow
        below (characters,value,0x1E0C,0x044,0x2D9,0.50,0.12,0.30) -- Ddotbelow
        below (characters,value,0x1E0D,0x064,0x2D9,0.40,0.12,0.30) -- ddotbelow
        below (characters,value,0x1E6C,0x054,0x2D9,0.50,0.12,0.30) -- Tdotbelow
        below (characters,value,0x1E6D,0x074,0x2D9,0.40,0.12,0.30) -- tdotbelow
        below (characters,value,0x1E92,0x05A,0x2D9,0.50,0.12,0.30) -- Zdotbelow
        below (characters,value,0x1E93,0x07A,0x2D9,0.40,0.12,0.30) -- zdotbelow

        ccrap (characters,value,0x02BE,0x063,0x043,0.5,false) -- some fake
        ccrap (characters,value,0x02BF,0x063,0x043,0.5,true)  -- some fake
    end
end

local specification = {
    name        = "idrify",
    description = "idrify",
    manipulators = {
        base = initialize,
        node = initialize,
    }
}

fonts.handlers.otf.features.register(specification)
\stopluacode

% \definefontfeature[default][default][idrify=yes]
\definefontfeature[default][default][idrify=force]

\showglyphs

\startTEXpage[offset=1ts]
    \definedfont[MinionPro-Regular.otf*default @ 12pt]%
    Ṯṯ Ḥḥ Ḫḫ Ḏḏ Šš Ṣṣ Ḍḍ Ṭṭ Ẓẓ Ġġ Āā Īī Ūū ʿ ʾ
\stopTEXpage

\stoptext
