math-map.lua /size: 30 Kb    last modification: 2020-07-01 14:35
1
if
not
modules
then
modules
=
{
}
end
modules
[
'
math-map
'
]
=
{
2
version
=
1
.
001
,
3
comment
=
"
companion to math-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 9
-- todo: make sparse .. if self
10 11
--[[ldx-- 12<p>Remapping mathematics alphabets.</p> 13--ldx]]
--
14 15
-- oldstyle: not really mathematics but happened to be part of
16
-- the mathematics fonts in cmr
17
--
18
-- persian: we will also provide mappers for other
19
-- scripts
20 21
-- todo: alphabets namespace
22
-- maybe: script/scriptscript dynamic,
23 24
-- superscripped primes get unscripted !
25 26
-- to be looked into once the fonts are ready (will become font
27
-- goodie):
28
--
29
-- (U+2202,U+1D715) : upright
30
-- (U+2202,U+1D715) : italic
31
-- (U+2202,U+1D715) : upright
32
--
33
-- plus add them to the regular vectors below so that they honor \it etc
34 35
local
type
,
next
=
type
,
next
36
local
merged
,
sortedhash
=
table
.
merged
,
table
.
sortedhash
37
local
extract
=
bit32
.
extract
38 39
local
allocate
=
utilities
.
storage
.
allocate
40 41
local
otffeatures
=
fonts
.
constructors
.
features
.
otf
42
local
registerotffeature
=
otffeatures
.
register
43 44
local
setmetatableindex
=
table
.
setmetatableindex
45 46
local
texgetattribute
=
tex
.
getattribute
47
local
texsetattribute
=
tex
.
setattribute
48 49
local
trace_greek
=
false
trackers
.
register
(
"
math.greek
"
,
function
(
v
)
trace_greek
=
v
end
)
50
local
report_remapping
=
logs
.
reporter
(
"
mathematics
"
,
"
remapping
"
)
51 52
mathematics
=
mathematics
or
{
}
53
local
mathematics
=
mathematics
54 55
local
implement
=
interfaces
.
implement
56 57
-- Unfortunately some alphabets have gaps (thereby troubling all applications that
58
-- need to deal with math). Somewhat strange considering all those weird symbols that
59
-- were added afterwards. The following trickery (and data) is only to be used for
60
-- diagnostics and quick and dirty alphabet tracing (s-mat-10.mkiv) as we deal with
61
-- it otherwise.
62 63
-- todo: allocate
64 65
mathematics
.
styles
=
allocate
{
"
regular
"
,
"
sansserif
"
,
"
monospaced
"
,
"
fraktur
"
,
"
script
"
,
"
blackboard
"
}
66
mathematics
.
alternatives
=
allocate
{
"
normal
"
,
"
bold
"
,
"
italic
"
,
"
bolditalic
"
}
67
mathematics
.
sets
=
allocate
{
"
ucletters
"
,
"
lcletters
"
,
"
digits
"
,
"
ucgreek
"
,
"
lcgreek
"
,
"
symbols
"
}
68 69
mathematics
.
charactersets
=
allocate
{
70
ucletters
=
{
71
0x00041
,
0x00042
,
0x00043
,
0x00044
,
0x00045
,
72
0x00046
,
0x00047
,
0x00048
,
0x00049
,
0x0004A
,
73
0x0004B
,
0x0004C
,
0x0004D
,
0x0004E
,
0x0004F
,
74
0x00050
,
0x00051
,
0x00052
,
0x00053
,
0x00054
,
75
0x00055
,
0x00056
,
0x00057
,
0x00058
,
0x00059
,
76
0x0005A
,
77
}
,
78
lcletters
=
{
79
0x00061
,
0x00062
,
0x00063
,
0x00064
,
0x00065
,
80
0x00066
,
0x00067
,
0x00068
,
0x00069
,
0x0006A
,
81
0x0006B
,
0x0006C
,
0x0006D
,
0x0006E
,
0x0006F
,
82
0x00070
,
0x00071
,
0x00072
,
0x00073
,
0x00074
,
83
0x00075
,
0x00076
,
0x00077
,
0x00078
,
0x00079
,
84
0x0007A
,
85
}
,
86
digits
=
{
87
0x00030
,
0x00031
,
0x00032
,
0x00033
,
0x00034
,
88
0x00035
,
0x00036
,
0x00037
,
0x00038
,
0x00039
,
89
}
,
90
ucgreek
=
{
91
0x0391
,
0x0392
,
0x0393
,
0x0394
,
0x0395
,
92
0x0396
,
0x0397
,
0x0398
,
0x0399
,
0x039A
,
93
0x039B
,
0x039C
,
0x039D
,
0x039E
,
0x039F
,
94
0x03A0
,
0x03A1
,
0x03A3
,
0x03A4
,
0x03A5
,
95
0x03A6
,
0x03A7
,
0x03A8
,
0x03A9
96
}
,
97
lcgreek
=
{
98
0x03B1
,
0x03B2
,
0x03B3
,
0x03B4
,
0x03B5
,
99
0x03B6
,
0x03B7
,
0x03B8
,
0x03B9
,
0x03BA
,
100
0x03BB
,
0x03BC
,
0x03BD
,
0x03BE
,
0x03BF
,
101
0x03C0
,
0x03C1
,
0x03C2
,
0x03C3
,
0x03C4
,
102
0x03C5
,
0x03C6
,
0x03C7
,
0x03C8
,
0x03C9
,
103
0x03D1
,
0x03D5
,
0x03D6
,
0x03F0
,
0x03F1
,
104
0x03F4
,
0x03F5
105
}
,
106
}
107 108
mathematics
.
gaps
=
allocate
{
109
[
0x1D455
]
=
0x0210E
,
-- ℎ h
110
[
0x1D49D
]
=
0x0212C
,
-- ℬ script B
111
[
0x1D4A0
]
=
0x02130
,
-- ℰ script E
112
[
0x1D4A1
]
=
0x02131
,
-- ℱ script F
113
[
0x1D4A3
]
=
0x0210B
,
-- ℋ script H
114
[
0x1D4A4
]
=
0x02110
,
-- ℐ script I
115
[
0x1D4A7
]
=
0x02112
,
-- ℒ script L
116
[
0x1D4A8
]
=
0x02133
,
-- ℳ script M
117
[
0x1D4AD
]
=
0x0211B
,
-- ℛ script R
118
[
0x1D4BA
]
=
0x0212F
,
-- ℯ script e
119
[
0x1D4BC
]
=
0x0210A
,
-- ℊ script g
120
-- [0x1D4C1] = 0x02113, -- exception: liter
121
[
0x1D4C4
]
=
0x02134
,
-- ℴ script o
122
[
0x1D506
]
=
0x0212D
,
-- ℭ fraktur C
123
[
0x1D50B
]
=
0x0210C
,
-- ℌ fraktur H
124
[
0x1D50C
]
=
0x02111
,
-- ℑ fraktur I
125
[
0x1D515
]
=
0x0211C
,
-- ℜ fraktur R
126
[
0x1D51D
]
=
0x02128
,
-- ℨ fraktur Z
127
[
0x1D53A
]
=
0x02102
,
-- ℂ bb C
128
[
0x1D53F
]
=
0x0210D
,
-- ℍ bb H
129
[
0x1D545
]
=
0x02115
,
-- ℕ bb N
130
[
0x1D547
]
=
0x02119
,
-- ℙ bb P
131
[
0x1D548
]
=
0x0211A
,
-- ℚ bb Q
132
[
0x1D549
]
=
0x0211D
,
-- ℝ bb R
133
[
0x1D551
]
=
0x02124
,
-- ℤ bb Z
134
}
135 136
local
function
fillinmathgaps
(
tfmdata
,
key
,
value
)
137
local
mathgaps
=
mathematics
.
gaps
138
local
characters
=
tfmdata
.
characters
139
local
descriptions
=
tfmdata
.
descriptions
140
for
gap
,
original
in
next
,
mathgaps
do
141
if
characters
[
original
]
and
not
characters
[
gap
]
then
142
characters
[
gap
]
=
characters
[
original
]
143
descriptions
[
gap
]
=
descriptions
[
original
]
144
end
145
end
146
end
147 148
registerotffeature
{
149
name
=
"
mathgaps
"
,
150
description
=
"
plug gaps in math alphabets
"
,
151
comment
=
"
regular document sources should not depend on this
"
,
152
manipulators
=
{
153
base
=
fillinmathgaps
,
154
node
=
fillinmathgaps
,
155
}
156
}
157 158
-- we could use one level less and have tf etc be tables directly but the
159
-- following approach permits easier remapping of a-a, A-Z and 0-9 to
160
-- fallbacks; symbols is currently mostly greek
161 162
local
function
todigit
(
n
)
local
t
=
{
}
for
i
=
0
,
9
do
t
[
0x00030
+
i
]
=
n
+
i
end
return
t
end
163
local
function
toupper
(
n
)
local
t
=
{
}
for
i
=
0
,
25
do
t
[
0x00041
+
i
]
=
n
+
i
end
return
t
end
164
local
function
tolower
(
n
)
local
t
=
{
}
for
i
=
0
,
25
do
t
[
0x00061
+
i
]
=
n
+
i
end
return
t
end
165
local
function
tovector
(
t
)
return
t
end
166 167
-- how about 0x2A (ast) cq. 0x2217
168
-- 0x2D (hyphen) cq. 0x2212
169
-- 0x3A (colon) cq. 0x2236
170 171
local
regular_tf
=
{
172
digits
=
todigit
(
0x00030
)
,
173
ucletters
=
toupper
(
0x00041
)
,
174
lcletters
=
tolower
(
0x00061
)
,
175
ucgreek
=
{
176
[
0x0391
]
=
0x0391
,
[
0x0392
]
=
0x0392
,
[
0x0393
]
=
0x0393
,
[
0x0394
]
=
0x0394
,
[
0x0395
]
=
0x0395
,
177
[
0x0396
]
=
0x0396
,
[
0x0397
]
=
0x0397
,
[
0x0398
]
=
0x0398
,
[
0x0399
]
=
0x0399
,
[
0x039A
]
=
0x039A
,
178
[
0x039B
]
=
0x039B
,
[
0x039C
]
=
0x039C
,
[
0x039D
]
=
0x039D
,
[
0x039E
]
=
0x039E
,
[
0x039F
]
=
0x039F
,
179
[
0x03A0
]
=
0x03A0
,
[
0x03A1
]
=
0x03A1
,
[
0x03A3
]
=
0x03A3
,
[
0x03A4
]
=
0x03A4
,
[
0x03A5
]
=
0x03A5
,
180
[
0x03A6
]
=
0x03A6
,
[
0x03A7
]
=
0x03A7
,
[
0x03A8
]
=
0x03A8
,
[
0x03A9
]
=
0x03A9
,
181
}
,
182
lcgreek
=
{
183
[
0x03B1
]
=
0x03B1
,
[
0x03B2
]
=
0x03B2
,
[
0x03B3
]
=
0x03B3
,
[
0x03B4
]
=
0x03B4
,
[
0x03B5
]
=
0x03B5
,
184
[
0x03B6
]
=
0x03B6
,
[
0x03B7
]
=
0x03B7
,
[
0x03B8
]
=
0x03B8
,
[
0x03B9
]
=
0x03B9
,
[
0x03BA
]
=
0x03BA
,
185
[
0x03BB
]
=
0x03BB
,
[
0x03BC
]
=
0x03BC
,
[
0x03BD
]
=
0x03BD
,
[
0x03BE
]
=
0x03BE
,
[
0x03BF
]
=
0x03BF
,
186
[
0x03C0
]
=
0x03C0
,
[
0x03C1
]
=
0x03C1
,
[
0x03C2
]
=
0x03C2
,
[
0x03C3
]
=
0x03C3
,
[
0x03C4
]
=
0x03C4
,
187
[
0x03C5
]
=
0x03C5
,
[
0x03C6
]
=
0x03C6
,
[
0x03C7
]
=
0x03C7
,
[
0x03C8
]
=
0x03C8
,
[
0x03C9
]
=
0x03C9
,
188
[
0x03D1
]
=
0x03D1
,
[
0x03D5
]
=
0x03D5
,
[
0x03D6
]
=
0x03D6
,
[
0x03F0
]
=
0x03F0
,
[
0x03F1
]
=
0x03F1
,
189
[
0x03F4
]
=
0x03F4
,
[
0x03F5
]
=
0x03F5
,
190
}
,
191
symbols
=
{
192
[
0x2202
]
=
0x2202
,
[
0x2207
]
=
0x2207
,
193
[
0x0027
]
=
0x2032
,
-- prime
194
}
,
195
}
196 197
local
regular_it
=
{
198
digits
=
tovector
(
regular_tf
.
digits
)
,
199
ucletters
=
toupper
(
0x1D434
)
,
200
lcletters
=
{
-- H
201
[
0x00061
]
=
0x1D44E
,
[
0x00062
]
=
0x1D44F
,
[
0x00063
]
=
0x1D450
,
[
0x00064
]
=
0x1D451
,
[
0x00065
]
=
0x1D452
,
202
[
0x00066
]
=
0x1D453
,
[
0x00067
]
=
0x1D454
,
[
0x00068
]
=
0x0210E
,
[
0x00069
]
=
0x1D456
,
[
0x0006A
]
=
0x1D457
,
203
[
0x0006B
]
=
0x1D458
,
[
0x0006C
]
=
0x1D459
,
[
0x0006D
]
=
0x1D45A
,
[
0x0006E
]
=
0x1D45B
,
[
0x0006F
]
=
0x1D45C
,
204
[
0x00070
]
=
0x1D45D
,
[
0x00071
]
=
0x1D45E
,
[
0x00072
]
=
0x1D45F
,
[
0x00073
]
=
0x1D460
,
[
0x00074
]
=
0x1D461
,
205
[
0x00075
]
=
0x1D462
,
[
0x00076
]
=
0x1D463
,
[
0x00077
]
=
0x1D464
,
[
0x00078
]
=
0x1D465
,
[
0x00079
]
=
0x1D466
,
206
[
0x0007A
]
=
0x1D467
,
207
-- arabic
208
[
0x00627
]
=
0x1EE00
,
[
0x00628
]
=
0x1EE21
,
[
0x0062A
]
=
0x1EE15
,
[
0x0062B
]
=
0x1EE16
,
209
[
0x0062C
]
=
0x1EE22
,
[
0x0062D
]
=
0x1EE07
,
[
0x0062E
]
=
0x1EE17
,
[
0x0062F
]
=
0x1EE03
,
210
[
0x00630
]
=
0x1EE18
,
[
0x00631
]
=
0x1EE13
,
[
0x00632
]
=
0x1EE06
,
[
0x00633
]
=
0x1EE0E
,
211
[
0x00634
]
=
0x1EE14
,
[
0x00635
]
=
0x1EE11
,
[
0x00636
]
=
0x1EE19
,
[
0x00637
]
=
0x1EE08
,
212
[
0x00638
]
=
0x1EE1A
,
[
0x00639
]
=
0x1EE0F
,
[
0x0063A
]
=
0x1EE1B
,
[
0x00641
]
=
0x1EE10
,
213
[
0x00642
]
=
0x1EE12
,
[
0x00643
]
=
0x1EE0A
,
[
0x00644
]
=
0x1EE0B
,
[
0x00645
]
=
0x1EE0C
,
214
[
0x00646
]
=
0x1EE0D
,
[
0x00647
]
=
0x1EE24
,
[
0x00648
]
=
0x1EE05
,
[
0x0064A
]
=
0x1EE09
,
215
[
0x0066E
]
=
0x1EE1C
,
[
0x0066F
]
=
0x1EE1F
,
[
0x006A1
]
=
0x1EE1E
,
[
0x006BA
]
=
0x1EE1D
,
216
}
,
217
ucgreek
=
{
218
[
0x0391
]
=
0x1D6E2
,
[
0x0392
]
=
0x1D6E3
,
[
0x0393
]
=
0x1D6E4
,
[
0x0394
]
=
0x1D6E5
,
[
0x0395
]
=
0x1D6E6
,
219
[
0x0396
]
=
0x1D6E7
,
[
0x0397
]
=
0x1D6E8
,
[
0x0398
]
=
0x1D6E9
,
[
0x0399
]
=
0x1D6EA
,
[
0x039A
]
=
0x1D6EB
,
220
[
0x039B
]
=
0x1D6EC
,
[
0x039C
]
=
0x1D6ED
,
[
0x039D
]
=
0x1D6EE
,
[
0x039E
]
=
0x1D6EF
,
[
0x039F
]
=
0x1D6F0
,
221
[
0x03A0
]
=
0x1D6F1
,
[
0x03A1
]
=
0x1D6F2
,
[
0x03A3
]
=
0x1D6F4
,
[
0x03A4
]
=
0x1D6F5
,
[
0x03A5
]
=
0x1D6F6
,
222
[
0x03A6
]
=
0x1D6F7
,
[
0x03A7
]
=
0x1D6F8
,
[
0x03A8
]
=
0x1D6F9
,
[
0x03A9
]
=
0x1D6FA
,
223
}
,
224
lcgreek
=
{
225
[
0x03B1
]
=
0x1D6FC
,
[
0x03B2
]
=
0x1D6FD
,
[
0x03B3
]
=
0x1D6FE
,
[
0x03B4
]
=
0x1D6FF
,
[
0x03B5
]
=
0x1D700
,
226
[
0x03B6
]
=
0x1D701
,
[
0x03B7
]
=
0x1D702
,
[
0x03B8
]
=
0x1D703
,
[
0x03B9
]
=
0x1D704
,
[
0x03BA
]
=
0x1D705
,
227
[
0x03BB
]
=
0x1D706
,
[
0x03BC
]
=
0x1D707
,
[
0x03BD
]
=
0x1D708
,
[
0x03BE
]
=
0x1D709
,
[
0x03BF
]
=
0x1D70A
,
228
[
0x03C0
]
=
0x1D70B
,
[
0x03C1
]
=
0x1D70C
,
[
0x03C2
]
=
0x1D70D
,
[
0x03C3
]
=
0x1D70E
,
[
0x03C4
]
=
0x1D70F
,
229
[
0x03C5
]
=
0x1D710
,
[
0x03C6
]
=
0x1D711
,
[
0x03C7
]
=
0x1D712
,
[
0x03C8
]
=
0x1D713
,
[
0x03C9
]
=
0x1D714
,
230
[
0x03D1
]
=
0x1D717
,
[
0x03D5
]
=
0x1D719
,
[
0x03D6
]
=
0x1D71B
,
[
0x03F0
]
=
0x1D718
,
[
0x03F1
]
=
0x1D71A
,
231
[
0x03F4
]
=
0x1D6F3
,
[
0x03F5
]
=
0x1D716
,
232
}
,
233
symbols
=
{
234
[
0x2202
]
=
0x1D715
,
[
0x2207
]
=
0x1D6FB
,
235
[
0x0027
]
=
0x2032
,
-- prime
236
}
,
237
}
238 239
local
regular_bf
=
{
240
digits
=
todigit
(
0x1D7CE
)
,
241
ucletters
=
toupper
(
0x1D400
)
,
242
lcletters
=
tolower
(
0x1D41A
)
,
243
ucgreek
=
{
244
[
0x0391
]
=
0x1D6A8
,
[
0x0392
]
=
0x1D6A9
,
[
0x0393
]
=
0x1D6AA
,
[
0x0394
]
=
0x1D6AB
,
[
0x0395
]
=
0x1D6AC
,
245
[
0x0396
]
=
0x1D6AD
,
[
0x0397
]
=
0x1D6AE
,
[
0x0398
]
=
0x1D6AF
,
[
0x0399
]
=
0x1D6B0
,
[
0x039A
]
=
0x1D6B1
,
246
[
0x039B
]
=
0x1D6B2
,
[
0x039C
]
=
0x1D6B3
,
[
0x039D
]
=
0x1D6B4
,
[
0x039E
]
=
0x1D6B5
,
[
0x039F
]
=
0x1D6B6
,
247
[
0x03A0
]
=
0x1D6B7
,
[
0x03A1
]
=
0x1D6B8
,
[
0x03A3
]
=
0x1D6BA
,
[
0x03A4
]
=
0x1D6BB
,
[
0x03A5
]
=
0x1D6BC
,
248
[
0x03A6
]
=
0x1D6BD
,
[
0x03A7
]
=
0x1D6BE
,
[
0x03A8
]
=
0x1D6BF
,
[
0x03A9
]
=
0x1D6C0
,
249
}
,
250
lcgreek
=
{
251
[
0x03B1
]
=
0x1D6C2
,
[
0x03B2
]
=
0x1D6C3
,
[
0x03B3
]
=
0x1D6C4
,
[
0x03B4
]
=
0x1D6C5
,
[
0x03B5
]
=
0x1D6C6
,
252
[
0x03B6
]
=
0x1D6C7
,
[
0x03B7
]
=
0x1D6C8
,
[
0x03B8
]
=
0x1D6C9
,
[
0x03B9
]
=
0x1D6CA
,
[
0x03BA
]
=
0x1D6CB
,
253
[
0x03BB
]
=
0x1D6CC
,
[
0x03BC
]
=
0x1D6CD
,
[
0x03BD
]
=
0x1D6CE
,
[
0x03BE
]
=
0x1D6CF
,
[
0x03BF
]
=
0x1D6D0
,
254
[
0x03C0
]
=
0x1D6D1
,
[
0x03C1
]
=
0x1D6D2
,
[
0x03C2
]
=
0x1D6D3
,
[
0x03C3
]
=
0x1D6D4
,
[
0x03C4
]
=
0x1D6D5
,
255
[
0x03C5
]
=
0x1D6D6
,
[
0x03C6
]
=
0x1D6D7
,
[
0x03C7
]
=
0x1D6D8
,
[
0x03C8
]
=
0x1D6D9
,
[
0x03C9
]
=
0x1D6DA
,
256
[
0x03D1
]
=
0x1D6DD
,
[
0x03D5
]
=
0x1D6DF
,
[
0x03D6
]
=
0x1D6E1
,
[
0x03F0
]
=
0x1D6DE
,
[
0x03F1
]
=
0x1D6E0
,
257
[
0x03F4
]
=
0x1D6B9
,
[
0x03F5
]
=
0x1D6DC
,
258
}
,
259
symbols
=
{
260
[
0x2202
]
=
0x1D6DB
,
[
0x2207
]
=
0x1D6C1
,
261
[
0x0027
]
=
0x2032
,
-- prime
262
}
,
263
}
264 265
local
regular_bi
=
{
266
digits
=
tovector
(
regular_bf
.
digits
)
,
267
ucletters
=
toupper
(
0x1D468
)
,
268
lcletters
=
tolower
(
0x1D482
)
,
269
ucgreek
=
{
270
[
0x0391
]
=
0x1D71C
,
[
0x0392
]
=
0x1D71D
,
[
0x0393
]
=
0x1D71E
,
[
0x0394
]
=
0x1D71F
,
[
0x0395
]
=
0x1D720
,
271
[
0x0396
]
=
0x1D721
,
[
0x0397
]
=
0x1D722
,
[
0x0398
]
=
0x1D723
,
[
0x0399
]
=
0x1D724
,
[
0x039A
]
=
0x1D725
,
272
[
0x039B
]
=
0x1D726
,
[
0x039C
]
=
0x1D727
,
[
0x039D
]
=
0x1D728
,
[
0x039E
]
=
0x1D729
,
[
0x039F
]
=
0x1D72A
,
273
[
0x03A0
]
=
0x1D72B
,
[
0x03A1
]
=
0x1D72C
,
[
0x03A3
]
=
0x1D72E
,
[
0x03A4
]
=
0x1D72F
,
[
0x03A5
]
=
0x1D730
,
274
[
0x03A6
]
=
0x1D731
,
[
0x03A7
]
=
0x1D732
,
[
0x03A8
]
=
0x1D733
,
[
0x03A9
]
=
0x1D734
,
275
}
,
276
lcgreek
=
{
277
[
0x03B1
]
=
0x1D736
,
[
0x03B2
]
=
0x1D737
,
[
0x03B3
]
=
0x1D738
,
[
0x03B4
]
=
0x1D739
,
[
0x03B5
]
=
0x1D73A
,
278
[
0x03B6
]
=
0x1D73B
,
[
0x03B7
]
=
0x1D73C
,
[
0x03B8
]
=
0x1D73D
,
[
0x03B9
]
=
0x1D73E
,
[
0x03BA
]
=
0x1D73F
,
279
[
0x03BB
]
=
0x1D740
,
[
0x03BC
]
=
0x1D741
,
[
0x03BD
]
=
0x1D742
,
[
0x03BE
]
=
0x1D743
,
[
0x03BF
]
=
0x1D744
,
280
[
0x03C0
]
=
0x1D745
,
[
0x03C1
]
=
0x1D746
,
[
0x03C2
]
=
0x1D747
,
[
0x03C3
]
=
0x1D748
,
[
0x03C4
]
=
0x1D749
,
281
[
0x03C5
]
=
0x1D74A
,
[
0x03C6
]
=
0x1D74B
,
[
0x03C7
]
=
0x1D74C
,
[
0x03C8
]
=
0x1D74D
,
[
0x03C9
]
=
0x1D74E
,
282
[
0x03D1
]
=
0x1D751
,
[
0x03D5
]
=
0x1D753
,
[
0x03D6
]
=
0x1D755
,
[
0x03F0
]
=
0x1D752
,
[
0x03F1
]
=
0x1D754
,
283
[
0x03F4
]
=
0x1D72D
,
[
0x03F5
]
=
0x1D750
,
284
}
,
285
symbols
=
{
286
[
0x2202
]
=
0x1D74F
,
[
0x2207
]
=
0x1D735
,
287
[
0x0027
]
=
0x2032
,
-- prime
288
}
,
289
}
290 291
local
regular
=
{
292
tf
=
regular_tf
,
293
it
=
regular_it
,
294
bf
=
regular_bf
,
295
bi
=
regular_bi
,
296
}
297 298
local
sansserif_tf
=
{
299
digits
=
todigit
(
0x1D7E2
)
,
300
ucletters
=
toupper
(
0x1D5A0
)
,
301
lcletters
=
tolower
(
0x1D5BA
)
,
302
lcgreek
=
tovector
(
regular_tf
.
lcgreek
)
,
303
ucgreek
=
tovector
(
regular_tf
.
ucgreek
)
,
304
symbols
=
tovector
(
regular_tf
.
symbols
)
,
305
}
306 307
local
sansserif_it
=
{
308
digits
=
tovector
(
regular_tf
.
digits
)
,
309
ucletters
=
toupper
(
0x1D608
)
,
310
lcletters
=
tolower
(
0x1D622
)
,
311
lcgreek
=
tovector
(
regular_tf
.
lcgreek
)
,
312
ucgreek
=
tovector
(
regular_tf
.
ucgreek
)
,
313
symbols
=
tovector
(
regular_tf
.
symbols
)
,
314
}
315 316
local
sansserif_bf
=
{
317
digits
=
todigit
(
0x1D7EC
)
,
318
ucletters
=
toupper
(
0x1D5D4
)
,
319
lcletters
=
tolower
(
0x1D5EE
)
,
320
ucgreek
=
{
321
[
0x0391
]
=
0x1D756
,
[
0x0392
]
=
0x1D757
,
[
0x0393
]
=
0x1D758
,
[
0x0394
]
=
0x1D759
,
[
0x0395
]
=
0x1D75A
,
322
[
0x0396
]
=
0x1D75B
,
[
0x0397
]
=
0x1D75C
,
[
0x0398
]
=
0x1D75D
,
[
0x0399
]
=
0x1D75E
,
[
0x039A
]
=
0x1D75F
,
323
[
0x039B
]
=
0x1D760
,
[
0x039C
]
=
0x1D761
,
[
0x039D
]
=
0x1D762
,
[
0x039E
]
=
0x1D763
,
[
0x039F
]
=
0x1D764
,
324
[
0x03A0
]
=
0x1D765
,
[
0x03A1
]
=
0x1D766
,
[
0x03A3
]
=
0x1D768
,
[
0x03A4
]
=
0x1D769
,
[
0x03A5
]
=
0x1D76A
,
325
[
0x03A6
]
=
0x1D76B
,
[
0x03A7
]
=
0x1D76C
,
[
0x03A8
]
=
0x1D76D
,
[
0x03A9
]
=
0x1D76E
,
326
}
,
327
lcgreek
=
{
328
[
0x03B1
]
=
0x1D770
,
[
0x03B2
]
=
0x1D771
,
[
0x03B3
]
=
0x1D772
,
[
0x03B4
]
=
0x1D773
,
[
0x03B5
]
=
0x1D774
,
329
[
0x03B6
]
=
0x1D775
,
[
0x03B7
]
=
0x1D776
,
[
0x03B8
]
=
0x1D777
,
[
0x03B9
]
=
0x1D778
,
[
0x03BA
]
=
0x1D779
,
330
[
0x03BB
]
=
0x1D77A
,
[
0x03BC
]
=
0x1D77B
,
[
0x03BD
]
=
0x1D77C
,
[
0x03BE
]
=
0x1D77D
,
[
0x03BF
]
=
0x1D77E
,
331
[
0x03C0
]
=
0x1D77F
,
[
0x03C1
]
=
0x1D780
,
[
0x03C2
]
=
0x1D781
,
[
0x03C3
]
=
0x1D782
,
[
0x03C4
]
=
0x1D783
,
332
[
0x03C5
]
=
0x1D784
,
[
0x03C6
]
=
0x1D785
,
[
0x03C7
]
=
0x1D786
,
[
0x03C8
]
=
0x1D787
,
[
0x03C9
]
=
0x1D788
,
333
[
0x03D1
]
=
0x1D78B
,
[
0x03D5
]
=
0x1D78D
,
[
0x03D6
]
=
0x1D78F
,
[
0x03F0
]
=
0x1D78C
,
[
0x03F1
]
=
0x1D78E
,
334
[
0x03F4
]
=
0x1D767
,
[
0x03F5
]
=
0x1D78A
,
335
}
,
336
symbols
=
{
337
[
0x2202
]
=
0x1D789
,
[
0x2207
]
=
0x1D76F
,
338
[
0x0027
]
=
0x2032
,
-- prime
339
}
,
340
}
341 342
local
sansserif_bi
=
{
343
digits
=
tovector
(
sansserif_bf
.
digits
)
,
344
ucletters
=
toupper
(
0x1D63C
)
,
345
lcletters
=
tolower
(
0x1D656
)
,
346
ucgreek
=
{
347
[
0x0391
]
=
0x1D790
,
[
0x0392
]
=
0x1D791
,
[
0x0393
]
=
0x1D792
,
[
0x0394
]
=
0x1D793
,
[
0x0395
]
=
0x1D794
,
348
[
0x0396
]
=
0x1D795
,
[
0x0397
]
=
0x1D796
,
[
0x0398
]
=
0x1D797
,
[
0x0399
]
=
0x1D798
,
[
0x039A
]
=
0x1D799
,
349
[
0x039B
]
=
0x1D79A
,
[
0x039C
]
=
0x1D79B
,
[
0x039D
]
=
0x1D79C
,
[
0x039E
]
=
0x1D79D
,
[
0x039F
]
=
0x1D79E
,
350
[
0x03A0
]
=
0x1D79F
,
[
0x03A1
]
=
0x1D7A0
,
[
0x03A3
]
=
0x1D7A2
,
[
0x03A4
]
=
0x1D7A3
,
[
0x03A5
]
=
0x1D7A4
,
351
[
0x03A6
]
=
0x1D7A5
,
[
0x03A7
]
=
0x1D7A6
,
[
0x03A8
]
=
0x1D7A7
,
[
0x03A9
]
=
0x1D7A8
,
352
}
,
353
lcgreek
=
{
354
[
0x03B1
]
=
0x1D7AA
,
[
0x03B2
]
=
0x1D7AB
,
[
0x03B3
]
=
0x1D7AC
,
[
0x03B4
]
=
0x1D7AD
,
[
0x03B5
]
=
0x1D7AE
,
355
[
0x03B6
]
=
0x1D7AF
,
[
0x03B7
]
=
0x1D7B0
,
[
0x03B8
]
=
0x1D7B1
,
[
0x03B9
]
=
0x1D7B2
,
[
0x03BA
]
=
0x1D7B3
,
356
[
0x03BB
]
=
0x1D7B4
,
[
0x03BC
]
=
0x1D7B5
,
[
0x03BD
]
=
0x1D7B6
,
[
0x03BE
]
=
0x1D7B7
,
[
0x03BF
]
=
0x1D7B8
,
357
[
0x03C0
]
=
0x1D7B9
,
[
0x03C1
]
=
0x1D7BA
,
[
0x03C2
]
=
0x1D7BB
,
[
0x03C3
]
=
0x1D7BC
,
[
0x03C4
]
=
0x1D7BD
,
358
[
0x03C5
]
=
0x1D7BE
,
[
0x03C6
]
=
0x1D7BF
,
[
0x03C7
]
=
0x1D7C0
,
[
0x03C8
]
=
0x1D7C1
,
[
0x03C9
]
=
0x1D7C2
,
359
[
0x03D1
]
=
0x1D7C5
,
[
0x03D5
]
=
0x1D7C7
,
[
0x03D6
]
=
0x1D7C9
,
[
0x03F0
]
=
0x1D7C6
,
[
0x03F1
]
=
0x1D7C8
,
360
[
0x03F4
]
=
0x1D7A1
,
[
0x03F5
]
=
0x1D7C4
,
361
}
,
362
symbols
=
{
363
[
0x2202
]
=
0x1D7C3
,
[
0x2207
]
=
0x1D7A9
,
364
[
0x0027
]
=
0x2032
,
-- prime
365
}
,
366
}
367 368
local
sansserif
=
{
369
tf
=
sansserif_tf
,
370
it
=
sansserif_it
,
371
bf
=
sansserif_bf
,
372
bi
=
sansserif_bi
,
373
}
374 375
local
monospaced_tf
=
{
376
digits
=
todigit
(
0x1D7F6
)
,
377
ucletters
=
toupper
(
0x1D670
)
,
378
lcletters
=
tolower
(
0x1D68A
)
,
379
lcgreek
=
tovector
(
sansserif_tf
.
lcgreek
)
,
380
ucgreek
=
tovector
(
sansserif_tf
.
ucgreek
)
,
381
symbols
=
tovector
(
sansserif_tf
.
symbols
)
,
382
}
383 384
local
monospaced_it
=
tovector
(
sansserif_it
)
385
local
monospaced_bf
=
tovector
(
sansserif_bf
)
386
local
monospaced_bi
=
tovector
(
sansserif_bi
)
387 388
local
monospaced
=
{
389
tf
=
monospaced_tf
,
390
it
=
monospaced_tf
,
391
bf
=
monospaced_tf
,
392
bi
=
monospaced_bf
,
393
}
394 395
local
blackboard_tf
=
{
396
digits
=
todigit
(
0x1D7D8
)
,
397
ucletters
=
{
-- C H N P Q R Z
398
[
0x00041
]
=
0x1D538
,
[
0x00042
]
=
0x1D539
,
[
0x00043
]
=
0x02102
,
[
0x00044
]
=
0x1D53B
,
[
0x00045
]
=
0x1D53C
,
399
[
0x00046
]
=
0x1D53D
,
[
0x00047
]
=
0x1D53E
,
[
0x00048
]
=
0x0210D
,
[
0x00049
]
=
0x1D540
,
[
0x0004A
]
=
0x1D541
,
400
[
0x0004B
]
=
0x1D542
,
[
0x0004C
]
=
0x1D543
,
[
0x0004D
]
=
0x1D544
,
[
0x0004E
]
=
0x02115
,
[
0x0004F
]
=
0x1D546
,
401
[
0x00050
]
=
0x02119
,
[
0x00051
]
=
0x0211A
,
[
0x00052
]
=
0x0211D
,
[
0x00053
]
=
0x1D54A
,
[
0x00054
]
=
0x1D54B
,
402
[
0x00055
]
=
0x1D54C
,
[
0x00056
]
=
0x1D54D
,
[
0x00057
]
=
0x1D54E
,
[
0x00058
]
=
0x1D54F
,
[
0x00059
]
=
0x1D550
,
403
[
0x0005A
]
=
0x02124
,
404
}
,
405
lcletters
=
{
406
-- tolower(0x1D552) :
407
[
0x00061
]
=
0x1D552
,
[
0x00062
]
=
0x1D553
,
[
0x00063
]
=
0x1D554
,
[
0x00064
]
=
0x1D555
,
408
[
0x00065
]
=
0x1D556
,
[
0x00066
]
=
0x1D557
,
[
0x00067
]
=
0x1D558
,
[
0x00068
]
=
0x1D559
,
409
[
0x00069
]
=
0x1D55A
,
[
0x0006A
]
=
0x1D55B
,
[
0x0006B
]
=
0x1D55C
,
[
0x0006C
]
=
0x1D55D
,
410
[
0x0006D
]
=
0x1D55E
,
[
0x0006E
]
=
0x1D55F
,
[
0x0006F
]
=
0x1D560
,
[
0x00070
]
=
0x1D561
,
411
[
0x00071
]
=
0x1D562
,
[
0x00072
]
=
0x1D563
,
[
0x00073
]
=
0x1D564
,
[
0x00074
]
=
0x1D565
,
412
[
0x00075
]
=
0x1D566
,
[
0x00076
]
=
0x1D567
,
[
0x00077
]
=
0x1D568
,
[
0x00078
]
=
0x1D569
,
413
[
0x00079
]
=
0x1D56A
,
[
0x0007A
]
=
0x1D56B
,
414
-- arabic
415
[
0x00628
]
=
0x1EEA1
,
[
0x0062A
]
=
0x1EEB5
,
[
0x0062B
]
=
0x1EEB6
,
[
0x0062C
]
=
0x1EEA2
,
416
[
0x0062D
]
=
0x1EEA7
,
[
0x0062E
]
=
0x1EEB7
,
[
0x0062F
]
=
0x1EEA3
,
[
0x00630
]
=
0x1EEB8
,
417
[
0x00631
]
=
0x1EEB3
,
[
0x00632
]
=
0x1EEA6
,
[
0x00633
]
=
0x1EEAE
,
[
0x00634
]
=
0x1EEB4
,
418
[
0x00635
]
=
0x1EEB1
,
[
0x00636
]
=
0x1EEB9
,
[
0x00637
]
=
0x1EEA8
,
[
0x00638
]
=
0x1EEBA
,
419
[
0x00639
]
=
0x1EEAF
,
[
0x0063A
]
=
0x1EEBB
,
[
0x00641
]
=
0x1EEB0
,
[
0x00642
]
=
0x1EEB2
,
420
[
0x00644
]
=
0x1EEAB
,
[
0x00645
]
=
0x1EEAC
,
[
0x00646
]
=
0x1EEAD
,
[
0x00648
]
=
0x1EEA5
,
421
[
0x0064A
]
=
0x1EEA9
,
422
}
,
423
lcgreek
=
{
-- gamma pi
424
[
0x03B3
]
=
0x0213C
,
[
0x03C0
]
=
0x0213D
,
425
}
,
426
ucgreek
=
{
-- Gamma pi
427
[
0x0393
]
=
0x0213E
,
[
0x03A0
]
=
0x0213F
,
428
}
,
429
symbols
=
{
-- sum
430
[
0x2211
]
=
0x02140
,
431
[
0x0027
]
=
0x2032
,
-- prime
432
}
,
433
}
434 435
blackboard_tf
.
lcgreek
=
merged
(
regular_tf
.
lcgreek
,
blackboard_tf
.
lcgreek
)
436
blackboard_tf
.
ucgreek
=
merged
(
regular_tf
.
ucgreek
,
blackboard_tf
.
ucgreek
)
437
blackboard_tf
.
symbols
=
merged
(
regular_tf
.
symbols
,
blackboard_tf
.
symbols
)
438 439
local
blackboard
=
{
440
tf
=
blackboard_tf
,
441
it
=
blackboard_tf
,
442
bf
=
blackboard_tf
,
443
bi
=
blackboard_tf
,
444
}
445 446
local
fraktur_tf
=
{
447
digits
=
tovector
(
regular_tf
.
digits
)
,
448
ucletters
=
{
-- C H I R Z
449
[
0x00041
]
=
0x1D504
,
[
0x00042
]
=
0x1D505
,
[
0x00043
]
=
0x0212D
,
[
0x00044
]
=
0x1D507
,
[
0x00045
]
=
0x1D508
,
450
[
0x00046
]
=
0x1D509
,
[
0x00047
]
=
0x1D50A
,
[
0x00048
]
=
0x0210C
,
[
0x00049
]
=
0x02111
,
[
0x0004A
]
=
0x1D50D
,
451
[
0x0004B
]
=
0x1D50E
,
[
0x0004C
]
=
0x1D50F
,
[
0x0004D
]
=
0x1D510
,
[
0x0004E
]
=
0x1D511
,
[
0x0004F
]
=
0x1D512
,
452
[
0x00050
]
=
0x1D513
,
[
0x00051
]
=
0x1D514
,
[
0x00052
]
=
0x0211C
,
[
0x00053
]
=
0x1D516
,
[
0x00054
]
=
0x1D517
,
453
[
0x00055
]
=
0x1D518
,
[
0x00056
]
=
0x1D519
,
[
0x00057
]
=
0x1D51A
,
[
0x00058
]
=
0x1D51B
,
[
0x00059
]
=
0x1D51C
,
454
[
0x0005A
]
=
0x02128
,
455
}
,
456
lcletters
=
tolower
(
0x1D51E
)
,
457
lcgreek
=
tovector
(
regular_tf
.
lcgreek
)
,
458
ucgreek
=
tovector
(
regular_tf
.
ucgreek
)
,
459
symbols
=
tovector
(
regular_tf
.
symbols
)
,
460
}
461 462
local
fraktur_bf
=
{
463
digits
=
tovector
(
regular_bf
.
digits
)
,
464
ucletters
=
toupper
(
0x1D56C
)
,
465
lcletters
=
tolower
(
0x1D586
)
,
466
lcgreek
=
tovector
(
regular_bf
.
lcgreek
)
,
467
ucgreek
=
tovector
(
regular_bf
.
ucgreek
)
,
468
symbols
=
tovector
(
regular_bf
.
symbols
)
,
469
}
470 471
local
fraktur
=
{
-- ok
472
tf
=
fraktur_tf
,
473
bf
=
fraktur_bf
,
474
it
=
fraktur_tf
,
475
bi
=
fraktur_bf
,
476
}
477 478
local
script_tf
=
{
479
digits
=
tovector
(
regular_tf
.
digits
)
,
480
ucletters
=
{
-- B E F H I L M R -- P 2118
481
[
0x00041
]
=
0x1D49C
,
[
0x00042
]
=
0x0212C
,
[
0x00043
]
=
0x1D49E
,
[
0x00044
]
=
0x1D49F
,
[
0x00045
]
=
0x02130
,
482
[
0x00046
]
=
0x02131
,
[
0x00047
]
=
0x1D4A2
,
[
0x00048
]
=
0x0210B
,
[
0x00049
]
=
0x02110
,
[
0x0004A
]
=
0x1D4A5
,
483
[
0x0004B
]
=
0x1D4A6
,
[
0x0004C
]
=
0x02112
,
[
0x0004D
]
=
0x02133
,
[
0x0004E
]
=
0x1D4A9
,
[
0x0004F
]
=
0x1D4AA
,
484
[
0x00050
]
=
0x1D4AB
,
[
0x00051
]
=
0x1D4AC
,
[
0x00052
]
=
0x0211B
,
[
0x00053
]
=
0x1D4AE
,
[
0x00054
]
=
0x1D4AF
,
485
[
0x00055
]
=
0x1D4B0
,
[
0x00056
]
=
0x1D4B1
,
[
0x00057
]
=
0x1D4B2
,
[
0x00058
]
=
0x1D4B3
,
[
0x00059
]
=
0x1D4B4
,
486
[
0x0005A
]
=
0x1D4B5
,
487
}
,
488
lcletters
=
{
-- E G O -- L 2113
489
[
0x00061
]
=
0x1D4B6
,
[
0x00062
]
=
0x1D4B7
,
[
0x00063
]
=
0x1D4B8
,
[
0x00064
]
=
0x1D4B9
,
[
0x00065
]
=
0x0212F
,
490
[
0x00066
]
=
0x1D4BB
,
[
0x00067
]
=
0x0210A
,
[
0x00068
]
=
0x1D4BD
,
[
0x00069
]
=
0x1D4BE
,
[
0x0006A
]
=
0x1D4BF
,
491
[
0x0006B
]
=
0x1D4C0
,
[
0x0006C
]
=
0x1D4C1
,
[
0x0006D
]
=
0x1D4C2
,
[
0x0006E
]
=
0x1D4C3
,
[
0x0006F
]
=
0x02134
,
492
[
0x00070
]
=
0x1D4C5
,
[
0x00071
]
=
0x1D4C6
,
[
0x00072
]
=
0x1D4C7
,
[
0x00073
]
=
0x1D4C8
,
[
0x00074
]
=
0x1D4C9
,
493
[
0x00075
]
=
0x1D4CA
,
[
0x00076
]
=
0x1D4CB
,
[
0x00077
]
=
0x1D4CC
,
[
0x00078
]
=
0x1D4CD
,
[
0x00079
]
=
0x1D4CE
,
494
[
0x0007A
]
=
0x1D4CF
,
495
}
,
496
lcgreek
=
tovector
(
regular_tf
.
lcgreek
)
,
497
ucgreek
=
tovector
(
regular_tf
.
ucgreek
)
,
498
symbols
=
tovector
(
regular_tf
.
symbols
)
,
499
}
500 501
local
script_bf
=
{
502
digits
=
tovector
(
regular_bf
.
digits
)
,
503
ucletters
=
toupper
(
0x1D4D0
)
,
504
lcletters
=
tolower
(
0x1D4EA
)
,
505
lcgreek
=
tovector
(
regular_bf
.
lcgreek
)
,
506
ucgreek
=
tovector
(
regular_bf
.
ucgreek
)
,
507
symbols
=
tovector
(
regular_bf
.
symbols
)
,
508
}
509 510
local
script
=
{
511
tf
=
script_tf
,
512
bf
=
script_bf
,
513
it
=
script_tf
,
514
bi
=
script_bf
,
515
}
516 517
local
alphabets
=
allocate
{
518
regular
=
regular
,
519
sansserif
=
sansserif
,
520
monospaced
=
monospaced
,
521
blackboard
=
blackboard
,
522
fraktur
=
fraktur
,
523
script
=
script
,
524
}
525 526
alphabets
.
tt
=
tovector
(
monospaced
)
527
alphabets
.
ss
=
tovector
(
sansserif
)
528
alphabets
.
rm
=
tovector
(
regular
)
529
alphabets
.
bb
=
tovector
(
blackboard
)
530
alphabets
.
fr
=
tovector
(
fraktur
)
531
alphabets
.
sr
=
tovector
(
script
)
532 533
monospaced
.
normal
=
tovector
(
monospaced_tf
)
534
monospaced
.
italic
=
tovector
(
monospaced_it
)
535
monospaced
.
bold
=
tovector
(
monospaced_bf
)
536
monospaced
.
bolditalic
=
tovector
(
monospaced_bi
)
537 538
sansserif
.
normal
=
tovector
(
sansserif_tf
)
539
sansserif
.
italic
=
tovector
(
sansserif_it
)
540
sansserif
.
bold
=
tovector
(
sansserif_bf
)
541
sansserif
.
bolditalic
=
tovector
(
sansserif_bi
)
542 543
regular
.
normal
=
tovector
(
regular_tf
)
544
regular
.
italic
=
tovector
(
regular_it
)
545
regular
.
bold
=
tovector
(
regular_bf
)
546
regular
.
bolditalic
=
tovector
(
regular_bi
)
547 548
alphabets
.
serif
=
tovector
(
regular
)
549
alphabets
.
type
=
tovector
(
monospaced
)
550
alphabets
.
teletype
=
tovector
(
monospaced
)
551 552
mathematics
.
alphabets
=
alphabets
553 554
local
mathremap
=
allocate
{
}
555
mathematics
.
mapremap
=
mathremap
556 557
local
boldmap
=
allocate
{
}
558
mathematics
.
boldmap
=
boldmap
559 560
-- all math (a bit of redundancy here) (sorted for tracing)
561 562
for
alphabet
,
styles
in
sortedhash
(
alphabets
)
do
-- per 9/6/2011 we also have attr for missing
563
for
style
,
data
in
sortedhash
(
styles
)
do
564
-- let's keep the long names (for tracing)
565
local
n
=
#
mathremap
+
1
566
local
d
=
{
567
attribute
=
n
,
568
alphabet
=
alphabet
,
569
style
=
style
,
570
}
571
styles
[
style
]
=
d
572
setmetatableindex
(
d
,
data
)
-- we could use a alphadata table
573
mathremap
[
n
]
=
d
574
end
575
end
576 577
-- bold math
578 579
local
function
remapbold
(
tf
,
bf
)
580
local
styles
=
mathematics
.
styles
581
local
sets
=
mathematics
.
sets
582
for
i
=
1
,
#
styles
do
583
for
j
=
1
,
#
sets
do
584
local
one
=
styles
[
i
]
585
local
two
=
sets
[
j
]
586
local
a
=
alphabets
[
one
]
587
local
tf
=
a
[
tf
]
[
two
]
588
local
bf
=
a
[
bf
]
[
two
]
589
if
tf
and
bf
then
590
for
k
,
v
in
next
,
tf
do
591
boldmap
[
v
]
=
bf
[
k
]
592
end
593
end
594
end
595
end
596
end
597 598
remapbold
(
"
tf
"
,
"
bf
"
)
599
remapbold
(
"
it
"
,
"
bi
"
)
600 601
-- table.save("e:/tmp/a.lua",alphabets)
602
-- table.save("e:/tmp/b.lua",boldmap)
603 604
function
mathematics
.
tostyle
(
attribute
)
605
local
r
=
mathremap
[
attribute
]
606
return
r
and
r
.
style
or
"
tf
"
607
end
608 609
function
mathematics
.
toname
(
attribute
)
610
local
r
=
mathremap
[
attribute
]
611
return
r
and
r
.
alphabet
or
"
regular
"
612
end
613 614
-- of course we could do some div/mod trickery instead
615 616
local
mathalphabet
=
attributes
.
private
(
"
mathalphabet
"
)
617 618
function
mathematics
.
getboth
(
alphabet
,
style
)
619
local
data
=
alphabet
and
alphabets
[
alphabet
]
or
regular
620
data
=
data
[
style
or
"
tf
"
]
or
data
.
tf
621
return
data
and
data
.
attribute
622
end
623 624
function
mathematics
.
getstyle
(
style
)
625
local
r
=
mathremap
[
texgetattribute
(
mathalphabet
)
]
626
local
alphabet
=
r
and
r
.
alphabet
or
"
regular
"
627
local
data
=
alphabets
[
alphabet
]
[
style
]
628
return
data
and
data
.
attribute
629
end
630 631
function
mathematics
.
syncboth
(
alphabet
,
style
)
632
local
data
=
alphabet
and
alphabets
[
alphabet
]
or
regular
633
data
=
style
and
data
[
style
]
or
data
.
tf
634
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
635
end
636 637
function
mathematics
.
syncstyle
(
style
)
638
local
r
=
mathremap
[
texgetattribute
(
mathalphabet
)
]
639
local
alphabet
=
r
and
r
.
alphabet
or
"
regular
"
640
local
data
=
alphabets
[
alphabet
]
[
style
]
641
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
642
end
643 644
function
mathematics
.
syncname
(
alphabet
)
645
-- local r = mathremap[mathalphabet]
646
local
r
=
mathremap
[
texgetattribute
(
mathalphabet
)
]
647
local
style
=
r
and
r
.
style
or
"
tf
"
648
local
data
=
alphabets
[
alphabet
]
[
style
]
649
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
650
end
651 652
implement
{
653
name
=
"
setmathattribute
"
,
654
arguments
=
"
2 strings
"
,
655
actions
=
function
(
alphabet
,
style
)
656
local
data
=
alphabets
[
alphabet
]
or
regular
657
data
=
data
[
style
]
or
data
.
tf
658
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
659
end
660
}
661 662
implement
{
663
name
=
"
setmathstyle
"
,
664
arguments
=
"
string
"
,
665
actions
=
function
(
style
)
666
local
r
=
mathremap
[
texgetattribute
(
mathalphabet
)
]
667
local
alphabet
=
r
and
r
.
alphabet
or
"
regular
"
668
local
data
=
alphabets
[
alphabet
]
[
style
]
669
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
670
end
671
}
672 673
implement
{
674
name
=
"
setmathalphabet
"
,
675
arguments
=
"
string
"
,
676
actions
=
function
(
alphabet
)
677
-- local r = mathremap[mathalphabet]
678
local
r
=
mathremap
[
texgetattribute
(
mathalphabet
)
]
679
local
style
=
r
and
r
.
style
or
"
tf
"
680
local
data
=
alphabets
[
alphabet
]
[
style
]
681
texsetattribute
(
mathalphabet
,
data
and
data
.
attribute
or
texattribute
[
mathalphabet
]
)
682
end
683
}
684 685
local
islcgreek
=
regular_tf
.
lcgreek
686
local
isucgreek
=
regular_tf
.
ucgreek
687
local
issygreek
=
regular_tf
.
symbols
688
local
isgreek
=
merged
(
islcgreek
,
isucgreek
,
issygreek
)
689 690
local
greekremapping
=
{
691
[
1
]
=
{
what
=
"
unchanged
"
}
,
-- upright
692
[
2
]
=
{
what
=
"
upright
"
,
it
=
"
tf
"
,
bi
=
"
bf
"
}
,
-- upright
693
[
3
]
=
{
what
=
"
italic
"
,
tf
=
"
it
"
,
bf
=
"
bi
"
}
,
-- italic
694
}
695 696
local
usedremap
=
{
}
697 698
local
function
resolver
(
map
)
699
return
function
(
t
,
k
)
700
local
v
=
701
map
.
digits
[
k
]
or
702
map
.
lcletters
[
k
]
or
map
.
ucletters
[
k
]
or
703
map
.
lcgreek
[
k
]
or
map
.
ucgreek
[
k
]
or
704
map
.
symbols
[
k
]
or
k
705
t
[
k
]
=
v
706
return
v
707
end
708
end
709 710
for
k
,
v
in
next
,
mathremap
do
711
local
t
=
{
}
712
setmetatableindex
(
t
,
resolver
(
v
)
)
713
usedremap
[
k
]
=
t
714
end
715 716
local
function
remapgreek
(
mathalphabet
,
how
,
detail
,
char
)
717
local
r
=
mathremap
[
mathalphabet
]
-- what if 0
718
local
alphabet
=
r
and
r
.
alphabet
or
"
regular
"
719
local
style
=
r
and
r
.
style
or
"
tf
"
720
local
remapping
=
greekremapping
[
how
]
721
if
trace_greek
then
722
report_remapping
(
"
greek %s, %s char %C, alphabet %a %a, method %a
"
,
"
before
"
,
detail
,
char
,
alphabet
,
style
,
remapping
.
what
)
723
end
724
local
newstyle
=
remapping
[
style
]
725
if
newstyle
then
726
local
data
=
alphabets
[
alphabet
]
[
newstyle
]
-- always something
727
mathalphabet
=
data
and
data
.
attribute
or
mathalphabet
728
style
=
newstyle
729
end
730
if
trace_greek
then
731
report_remapping
(
"
greek %s, %s char %C, alphabet %a %a, method %a
"
,
"
after
"
,
detail
,
char
,
alphabet
,
style
,
remapping
.
what
)
732
end
733
return
mathalphabet
,
style
734
end
735 736
function
mathematics
.
remapalphabets
(
char
,
mathalphabet
,
mathgreek
)
737
if
not
mathalphabet
then
738
return
739
end
740
if
mathgreek
and
mathgreek
>
0
then
741
if
not
isgreek
[
char
]
then
742
-- nothing needed
743
elseif
islcgreek
[
char
]
then
744
local
lc
=
extract
(
mathgreek
,
4
,
4
)
-- (mathgreek >> 4) & ~(-1 << 4)
745
if
lc
>
1
then
746
mathalphabet
=
remapgreek
(
mathalphabet
,
lc
,
"
lowercase
"
,
char
)
747
end
748
elseif
isucgreek
[
char
]
then
749
local
uc
=
extract
(
mathgreek
,
0
,
4
)
-- (mathgreek >> 0) & ~(-1 << 4)
750
if
uc
>
1
then
751
mathalphabet
=
remapgreek
(
mathalphabet
,
uc
,
"
uppercase
"
,
char
)
752
end
753
elseif
issygreek
[
char
]
then
754
local
sy
=
extract
(
mathgreek
,
8
,
4
)
-- (mathgreek >> 8) & ~(-1 << 4)
755
if
sy
>
1
then
756
mathalphabet
=
remapgreek
(
mathalphabet
,
sy
,
"
symbol
"
,
char
)
757
end
758
end
759
end
760
if
mathalphabet
>
0
then
761
local
remap
=
usedremap
[
mathalphabet
]
-- redundant check
762
if
remap
then
763
local
newchar
=
remap
[
char
]
764
return
newchar
~
=
char
and
newchar
765
end
766
end
767
-- return nil
768
end
769 770
-- begin of experiment
771 772
local
fallback
=
{
773
tf
=
"
bf
"
,
774
it
=
"
bi
"
,
775
bf
=
"
tf
"
,
776
bi
=
"
it
"
,
777
}
778 779
function
mathematics
.
fallbackstyleattr
(
attribute
)
780
local
r
=
mathremap
[
attribute
]
781
local
alphabet
=
r
.
alphabet
or
"
regular
"
782
local
style
=
r
.
style
or
"
tf
"
783
local
fback
=
fallback
[
style
]
784
if
fback
then
785
local
data
=
alphabets
[
alphabet
]
[
fback
]
786
if
data
then
787
local
attr
=
data
.
attribute
788
return
attribute
~
=
attr
and
attr
789
end
790
end
791
end
792 793
-- end of experiment
794 795
local
function
checkedcopy
(
characters
,
child
,
parent
)
796
for
k
,
v
in
next
,
child
do
797
if
not
characters
[
v
]
then
798
characters
[
v
]
=
characters
[
parent
[
k
]
]
799
end
800
end
801
end
802 803
function
mathematics
.
addfallbacks
(
main
)
804
local
characters
=
main
.
characters
805
checkedcopy
(
characters
,
regular
.
bf
.
ucgreek
,
regular
.
tf
.
ucgreek
)
806
checkedcopy
(
characters
,
regular
.
bf
.
lcgreek
,
regular
.
tf
.
lcgreek
)
807
checkedcopy
(
characters
,
regular
.
bi
.
ucgreek
,
regular
.
it
.
ucgreek
)
808
checkedcopy
(
characters
,
regular
.
bi
.
lcgreek
,
regular
.
it
.
lcgreek
)
809
end
810