summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/font-ini.lmt
blob: dcec8594eab63529d49631b9a37c45fc5e7db9f1 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
if not modules then modules = { } end modules ['font-ini'] = {
    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 sortedhash, setmetatableindex = table.sortedhash, table.setmetatableindex
local allocate = utilities.storage.allocate

fonts             = fonts or { }
local fonts       = fonts

local identifiers = allocate()

fonts.hashes      = fonts.hashes     or { identifiers = identifiers }
fonts.tables      = fonts.tables     or { }
fonts.helpers     = fonts.helpers    or { }
fonts.tracers     = fonts.tracers    or { } -- for the moment till we have move to moduledata
fonts.specifiers  = fonts.specifiers or { } -- in format !

fonts.analyzers   = { } -- not needed here
fonts.readers     = { }
fonts.definers    = { methods = { } }
fonts.loggers     = { register = function() end }

fonts.privateoffsets = {
    textbase      = 0xF0000, -- used for hidden (opentype features)
    textextrabase = 0xFD000, -- used for visible by name
    mathextrabase = 0xFE000, -- used for visible by code
    mathbase      = 0xFF000, -- used for hidden (virtual math)
    keepnames     = false,   -- when set to true names are always kept (not for context)
}

local effects = setmetatableindex(
    function(t,slant)
        local v = setmetatableindex(
            function(t,squeeze)
                local v = setmetatableindex(
                    function(t,extend)
                        local v = setmetatableindex(
                            function(t,mode)
                                local v = setmetatableindex(
                                    function(t,line)
                                        local v = {
                                            slant   = slant,
                                            squeeze = squeeze,
                                            extend  = extend,
                                            mode    = mode,
                                            line    = line * 1000,
                                        }
                                        t[line] = v
                                        return v
                                    end)
                                t[mode] = v
                                return v
                            end)
                        t[extend] = v
                        return v
                    end)
                t[squeeze] = v
                return v
            end)
        t[slant] = v
        return v
    end)

-- This is an experiment, part of math engine project (MS and HH) where we wondered
-- how to deal with bad or missing alphabets. One solution is a character specific
-- effect which is supported by the engine (in fact the backend). By using a table
-- cache we limit checking. We use tweaks in font goodies to achieve it.
--
-- character.effect = fonts.effects[slant][squeeze][extend][mode][line]
-- character.effect = fonts.toeffect { slant = .2 }

fonts.effects = effects

fonts.effects[0][1][1][0][0] = false

function fonts.toeffect(t)
    local slant   = t.slant   or 0
    local squeeze = t.squeeze or 1
    local extend  = t.extend  or 1
    local mode    = t.mode    or 0
    local line    = t.line    or 0
    if slant or squeeze or extend or mode or line then
        local effect = effects[slant][squeeze][extend][mode][line]
        if effect then
            return effect
        end
    end
end

-- Also here now: