summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/font-imp-tex.lua
blob: b4b9a7b6943bd7d989c3e9f36bf21b068ff8796c (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
if not modules then modules = { } end modules ['font-imp-tex'] = {
    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 next = next

local fonts              = fonts
local otf                = fonts.handlers.otf
local registerotffeature = otf.features.register
local addotffeature      = otf.addfeature

-- tlig (we need numbers for some fonts so ...)

local specification = {
    type     = "ligature",
    order    = { "tlig" },
    prepend  = true,
    data     = {
     -- endash        = "hyphen hyphen",
     -- emdash        = "hyphen hyphen hyphen",
        [0x2013]      = { 0x002D, 0x002D },
        [0x2014]      = { 0x002D, 0x002D, 0x002D },
     -- quotedblleft  = "quoteleft quoteleft",
     -- quotedblright = "quoteright quoteright",
     -- quotedblleft  = "grave grave",
     -- quotedblright = "quotesingle quotesingle",
     -- quotedblbase  = "comma comma",
    },
}

addotffeature("tlig",specification)

registerotffeature {
    -- this makes it a known feature (in tables)
    name        = "tlig",
    description = "tex ligatures",
}

-- trep

local specification = {
    type      = "substitution",
    order     = { "trep" },
    prepend   = true,
    data      = {
     -- [0x0022] = 0x201D,
        [0x0027] = 0x2019,
     -- [0x0060] = 0x2018,
    },
}

addotffeature("trep",specification)

registerotffeature {
    -- this makes it a known feature (in tables)
    name        = "trep",
    description = "tex replacements",
}

-- some day this will be moved to font-imp-scripts.lua

-- anum

local anum_arabic = {
    [0x0030] = 0x0660,
    [0x0031] = 0x0661,
    [0x0032] = 0x0662,
    [0x0033] = 0x0663,
    [0x0034] = 0x0664,
    [0x0035] = 0x0665,
    [0x0036] = 0x0666,
    [0x0037] = 0x0667,
    [0x0038] = 0x0668,
    [0x0039] = 0x0669,
}

local anum_persian = {
    [0x0030] = 0x06F0,
    [0x0031] = 0x06F1,
    [0x0032] = 0x06F2,
    [0x0033] = 0x06F3,
    [0x0034] = 0x06F4,
    [0x0035] = 0x06F5,
    [0x0036] = 0x06F6,
    [0x0037] = 0x06F7,
    [0x0038] = 0x06F8,
    [0x0039] = 0x06F9,
}

local function valid(data)
    local features = data.resources.features
    if features then
        for k, v in next, features do
            for k, v in next, v do
                if v.arab then
                    return true
                end
            end
        end
    end
end

local specification = {
    {
        type     = "substitution",
        features = { arab = { urd = true, dflt = true } },
        order    = { "anum" },
        data     = anum_arabic,
        valid    = valid,
    },
    {
        type     = "substitution",
        features = { arab = { urd = true } },
        order    = { "anum" },
        data     = anum_persian,
        valid    = valid,
    },
}

addotffeature("anum",specification)

registerotffeature {
    -- this makes it a known feature (in tables)
    name        = "anum",
    description = "arabic digits",
}

-- -- example:
--
-- fonts.handlers.otf.addfeature {
--     name     = "hangulfix",
--     type     = "substitution",
--     features = { ["hang"] = { ["*"] = true } },
--     data     = {
--         [0x1160] = 0x119E,
--     },
--     order    = { "hangulfix" },
--     flags    = { },
--     prepend  = true,
-- })