1if not modules then modules = { } end modules ['font-imp-tex'] = {
2 version = 1.001,
3 comment = "companion to font-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9local next = next
10
11local fonts = fonts
12local otf = fonts.handlers.otf
13local registerotffeature = otf.features.register
14local addotffeature = otf.addfeature
15
16
17
18
19local tlig = {
20 type = "ligature",
21 order = { "tlig" },
22 prepend = true,
23 data = {
24 [0x2013] = { 0x002D, 0x002D },
25 [0x2014] = { 0x002D, 0x002D, 0x002D },
26 },
27}
28
29local tquo = {
30 type = "ligature",
31 order = { "tquo" },
32 prepend = true,
33 data = {
34 [0x201C] = { 0x0060, 0x0060 },
35 [0x201D] = { 0x0027, 0x0027 },
36 [0x201E] = { 0x002C, 0x002C },
37 },
38}
39
40local trep = {
41 type = "substitution",
42 order = { "trep" },
43 prepend = true,
44 data = {
45
46 [0x0027] = 0x2019,
47
48 },
49}
50
51addotffeature("trep",trep)
52addotffeature("tlig",tlig)
53addotffeature("tquo",tquo)
54
55registerotffeature { name = "tlig", description = "tex ligatures" }
56registerotffeature { name = "tquo", description = "tex quotes" }
57registerotffeature { name = "trep", description = "tex replacements" }
58
59
60
61
62
63local anum_arabic = {
64 [0x0030] = 0x0660,
65 [0x0031] = 0x0661,
66 [0x0032] = 0x0662,
67 [0x0033] = 0x0663,
68 [0x0034] = 0x0664,
69 [0x0035] = 0x0665,
70 [0x0036] = 0x0666,
71 [0x0037] = 0x0667,
72 [0x0038] = 0x0668,
73 [0x0039] = 0x0669,
74}
75
76local anum_persian = {
77 [0x0030] = 0x06F0,
78 [0x0031] = 0x06F1,
79 [0x0032] = 0x06F2,
80 [0x0033] = 0x06F3,
81 [0x0034] = 0x06F4,
82 [0x0035] = 0x06F5,
83 [0x0036] = 0x06F6,
84 [0x0037] = 0x06F7,
85 [0x0038] = 0x06F8,
86 [0x0039] = 0x06F9,
87}
88
89local function valid(data)
90 local features = data.resources.features
91 if features then
92 for k, v in next, features do
93 for k, v in next, v do
94 if v.arab then
95 return true
96 end
97 end
98 end
99 end
100end
101
102local specification = {
103 {
104 type = "substitution",
105 features = { arab = { urd = true, dflt = true } },
106 order = { "anum" },
107 data = anum_arabic,
108 valid = valid,
109 },
110 {
111 type = "substitution",
112 features = { arab = { urd = true } },
113 order = { "anum" },
114 data = anum_persian,
115 valid = valid,
116 },
117}
118
119addotffeature("anum",specification)
120
121registerotffeature {
122
123 name = "anum",
124 description = "arabic digits",
125}
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 |