summaryrefslogtreecommitdiff
path: root/otfl-font-oti.lua
blob: e531ba8b2f9b0307d0e7c83d0fcabbf64e0a093f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
if not modules then modules = { } end modules ['font-oti'] = {
    version   = 1.001,
    comment   = "companion to font-ini.mkiv",
    author    = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
    copyright = "PRAGMA ADE / ConTeXt Development Team",
    license   = "see context related readme files"
}

local lower = string.lower

local fonts = fonts

local otf          = fonts.otf
local initializers = fonts.initializers

local languages    = otf.tables.languages
local scripts      = otf.tables.scripts

local function set_language(tfmdata,value)
    if value then
        value = lower(value)
        if languages[value] then
            tfmdata.language = value
        end
    end
end

local function set_script(tfmdata,value)
    if value then
        value = lower(value)
        if scripts[value] then
            tfmdata.script = value
        end
    end
end

local function set_mode(tfmdata,value)
    if value then
        tfmdata.mode = lower(value)
    end
end

local base_initializers = initializers.base.otf
local node_initializers = initializers.node.otf

base_initializers.language = set_language
base_initializers.script   = set_script
base_initializers.mode     = set_mode
base_initializers.method   = set_mode

node_initializers.language = set_language
node_initializers.script   = set_script
node_initializers.mode     = set_mode
node_initializers.method   = set_mode

otf.features.register("features",true)     -- we always do features
table.insert(fonts.processors,"features")  -- we need a proper function for doing this