summaryrefslogtreecommitdiff
path: root/src/features/calt.fea
blob: d54af6bc47ca61b5f74339b73546c178b541f14d (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# -------------------------------------------------------------------------------------
# BEGIN glyph class definitions

@DASH = [
  hyphen
  endash
  emdash
];
@DASH_CASE = [
  hyphen.case
  endash.case
  emdash.case
];
@DASH_ANY = [ @DASH @DASH_CASE ];

# cap-height tall glyphs
@UC = [
  @Uppercase
  @Numeral

  # punctuation
  ampersand exclam exclamdbl exclamdown uni2049 question uni2047 uni2048
  questiondown interrobang invertedinterrobang bar paragraph

  # currency
  dollar cent yen sterling florin uni20BA uni20BD euro uni20B9 tenge peseta
  peso kip won lira austral hryvnia naira guarani coloncurrency cedi cruzeiro
  tugrik uni20AF mill afii57636 manat rupee lari franc

  # cap-tall symbols
  numero triagrt triagdn triagup warningSign blackleftpointingtriangle
  circleblack circlewhite
  diamondblack diamondblack_x diamondwhite diamondwhite_x
  sunWithRays blackSunWithRays
  heartWhiteSuit heartBlackSuit heavyBlackHeart
  upBlackArrow upWhiteArrow
  capslock placeofinterestsign control projective option alternativekeysymbol
  brokenCircleNorthWestArrow anticlockwiseOpenCircleArrow
  clockwiseOpenCircleArrow
  deleteleft deleteright clear ejectsymbol

  # percent and fractions
  onehalf onethird onequarter threequarters fivesixths onefraction seveneighths
  oneeighth fiveeighths threeeighths percent perthousand pertenthousand uni214D
  cadauna careof accountof addresssubject
];

# x-height tall glyphs
@LC = [
  @Lowercase
];

@CASE_L = [
  braceleft   braceright
  bracketleft bracketright
  parenleft   parenright
  asterisk
  at
  multiply
  minus
  plus
  plusminus
  divide
  equal
  notequal
  endash
  figuredash
  emdash
  hyphen
  bullet
  openbullet
  hyphenbullet
  trianglebullet
  blackleftbullet
  blackrightbullet
  blackSmallSquare
  leftArrow
  leftLongArrow
  leftLongArrow2
  leftDoubleArrow
  leftLongDoubleArrow
  rightArrow
  rightLongArrow
  rightLongArrow2
  rightDoubleArrow
  rightLongDoubleArrow
  leftRightArrow
  leftRightLongArrow
  leftRightDoubleArrow
  leftRightLongDoubleArrow
  northEastArrow
  southEastArrow
  southWestArrow
  northWestArrow
  colon
  approxequal
  asciitilde
  less
  greater
  lessequal
  greaterequal
];

@CASE_R = [
  braceleft.case   braceright.case
  bracketleft.case bracketright.case
  parenleft.case   parenright.case
  asterisk.case
  at.case
  multiply.case
  minus.case
  plus.case
  plusminus.case
  divide.case
  equal.case
  notequal.case
  endash.case
  figuredash.case
  emdash.case
  hyphen.case
  bullet.case
  openbullet.case
  hyphenbullet.case
  trianglebullet.case
  blackleftbullet.case
  blackrightbullet.case
  blackSmallSquare.case
  leftArrow.case
  leftLongArrow.case
  leftLongArrow2.case
  leftDoubleArrow.case
  leftLongDoubleArrow.case
  rightArrow.case
  rightLongArrow.case
  rightLongArrow2.case
  rightDoubleArrow.case
  rightLongDoubleArrow.case
  leftRightArrow.case
  leftRightLongArrow.case
  leftRightDoubleArrow.case
  leftRightLongDoubleArrow.case
  northEastArrow.case
  southEastArrow.case
  southWestArrow.case
  northWestArrow.case
  colon.case
  approxequal.case
  asciitilde.case
  less.case
  greater.case
  lessequal.case
  greaterequal.case
];

@Punctuation = [
  slash bar quoteleft quoteright quotesingle quotedbl
  quotedblleft quotedblright quotedblbase quotesinglbase prime doubleprime
  tripleprime quadrupleprime primerev doubleprimerev tripleprimerev primemod
  doubleprimemod comma period ellipsis twodotleader semicolon underscore
  asciicircum circumflex
  asterisk
];

# END glyph class definitions
# -------------------------------------------------------------------------------------
# BEGIN arrow replacements

# --->
sub @DASH @DASH @DASH greater by rightLongArrow2;
sub @DASH_ANY @DASH_ANY @DASH_ANY greater.case by rightLongArrow2.case;
# -->
sub @DASH @DASH greater by rightLongArrow;
sub @DASH_ANY @DASH_ANY greater.case by rightLongArrow.case;
# [endash emdash]-> (legacy)
sub [endash emdash] greater by rightLongArrow;
sub [endash emdash endash.case emdash.case] greater.case by rightLongArrow.case;
# ->
sub hyphen greater by rightArrow;
sub [hyphen hyphen.case] greater.case by rightArrow.case;
# <---
sub less @DASH @DASH @DASH by leftLongArrow2;
sub less.case @DASH_ANY @DASH_ANY @DASH_ANY by leftLongArrow2.case;
# <--
sub less @DASH @DASH by leftLongArrow;
sub less.case @DASH_ANY @DASH_ANY by leftLongArrow.case;
# <-[endash emdash] (legacy)
sub less [endash emdash] by leftLongArrow;
sub less.case [endash emdash endash.case emdash.case] by leftLongArrow.case;
# ignore e.g. "<-3" ("less than negative")
ignore sub less' hyphen' @Numeral;
ignore sub less.case' [hyphen hyphen.case]' @Numeral;
# <-
sub less' hyphen' by leftArrow;
sub less.case' [hyphen hyphen.case]' by leftArrow.case;
# <->
sub less rightArrow by leftRightArrow; #  <,->
sub [less less.case] rightArrow.case by leftRightArrow.case;
sub leftArrow greater by leftRightArrow; # <-,-
sub leftArrow.case [greater greater.case] by leftRightArrow.case;
# <-->
sub less rightLongArrow by leftRightLongArrow; # <,-->
sub [less less.case] rightLongArrow.case by leftRightLongArrow.case;
sub leftLongArrow greater by leftRightLongArrow; # <--,>
sub leftLongArrow.case [greater greater.case] by leftRightLongArrow.case;
# <=>
sub less equal greater by leftRightDoubleArrow;
sub less.case [equal equal.case] [greater greater.case] by leftRightDoubleArrow.case;
sub less equal equal greater by leftRightLongDoubleArrow;
sub less.case [equal equal.case] [equal equal.case] [greater greater.case] by leftRightLongDoubleArrow.case;
# =>
sub equal equal greater by rightLongDoubleArrow;
sub [equal equal.case] [equal equal.case] greater.case by rightLongDoubleArrow.case;
sub equal greater by rightDoubleArrow;
sub [equal equal.case] greater.case by rightDoubleArrow.case;
# <==
sub less equal equal by leftLongDoubleArrow;
sub less.case [equal equal.case] [equal equal.case] by leftLongDoubleArrow.case;
# Note: We do NOT (sub less equal by leftDoubleArrow) as that would
# interfere with "<=" (less than or equal to)

# END arrow replacements
# -------------------------------------------------------------------------------------
# BEGIN smiley
# :-)
sub colon' [ @DASH_ANY minus minus.case bullet ] [parenright parenright.case] by colon.case;
sub [colon colon.case] hyphen' [parenright parenright.case] by hyphen.case;
sub [colon colon.case] endash' [parenright parenright.case] by endash.case;
sub [colon colon.case] emdash' [parenright parenright.case] by emdash.case;
sub [colon colon.case] bullet' [parenright parenright.case] by bullet.case;
sub [colon colon.case] [ @DASH_ANY minus minus.case bullet ] parenright' by parenright.case;

# END smiley
# -------------------------------------------------------------------------------------
# BEGIN case

# Force lower-case parens if any one is lower case.
# I.e. right paren in "(abC)" is always lower case.
ignore sub parenleft @All @All parenright' ; # "(aB)"
ignore sub parenleft @All @All @All parenright' ; # "(abC)"
ignore sub parenleft @All @All @All @All parenright' ; # "(abcD)"
ignore sub parenleft @All @All @All @All @All parenright' ; # "(abcdE)"
ignore sub parenleft @All @All @All @All @All @All parenright' ; # "(abcdeF)"
ignore sub braceleft @All @All braceright' ; # "{aB}"
ignore sub braceleft @All @All @All braceright' ; # "{abC}"
ignore sub braceleft @All @All @All @All braceright' ; # "{abcD}"
ignore sub braceleft @All @All @All @All @All braceright' ; # "{abcdE}"
ignore sub braceleft @All @All @All @All @All @All braceright' ; # "{abcdeF}"
ignore sub bracketleft @All @All bracketright' ; # "[aB]"
ignore sub bracketleft @All @All @All bracketright' ; # "[abC]"
ignore sub bracketleft @All @All @All @All bracketright' ; # "[abcD]"
ignore sub bracketleft @All @All @All @All @All bracketright' ; # "[abcdE]"
ignore sub bracketleft @All @All @All @All @All @All bracketright' ; # "[abcdeF]"

# "3+" EXCEPT "3+<non-uc>"
ignore sub @UC @CASE_L' @LC;
ignore sub @UC @CASE_L' @Whitespace @LC;
ignore sub @UC @CASE_L' @Whitespace @Whitespace @LC;
sub @UC @CASE_L' by @CASE_R;

# "+3" EXCEPT "<non-uc>+3" (including backtrack, e.g. "---X")
ignore sub @LC @CASE_L' @UC; # "x-X"
ignore sub @LC @CASE_L @CASE_L' @UC; # "x--X"
ignore sub @LC @CASE_L @CASE_L @CASE_L' @UC; # "x---X"
ignore sub @LC @CASE_L @CASE_L @CASE_L @CASE_L' @UC; # "x---X"
ignore sub @LC @CASE_L @CASE_L @CASE_L @CASE_L @CASE_L' @UC; # "x----X"
ignore sub @LC @CASE_L' @CASE_L @UC; # "x-"
sub @CASE_L' @UC by @CASE_R;
sub @CASE_L' @CASE_L @UC by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @UC by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @UC by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L @UC by @CASE_R;

# "A-B", "A- B", "A-  B"
sub @UC @CASE_L' @UC                         by @CASE_R;
sub @UC @CASE_L' @Whitespace @UC             by @CASE_R;
sub @UC @CASE_L' @Whitespace @Whitespace @UC by @CASE_R;

# "A -B", "A - B", "A -  B"
sub @UC @Whitespace @CASE_L' @UC                         by @CASE_R;
sub @UC @Whitespace @CASE_L' @Whitespace @UC             by @CASE_R;
sub @UC @Whitespace @CASE_L' @Whitespace @Whitespace @UC by @CASE_R;

# "A  -B", "A  - B", "A  -  B"
sub @UC @Whitespace @Whitespace @CASE_L' @UC                         by @CASE_R;
sub @UC @Whitespace @Whitespace @CASE_L' @Whitespace @UC             by @CASE_R;
sub @UC @Whitespace @Whitespace @CASE_L' @Whitespace @Whitespace @UC by @CASE_R;

# cascade
sub @CASE_R @CASE_L' by @CASE_R;

# unconditional parenright.case if opening paren is parenleft.case
# e.g. "(Abc)" = /parenleft.case/A/b/c/parenright.case
sub parenleft.case @All @All parenright' by parenright.case;
sub parenleft.case @All @All @All parenright' by parenright.case;
sub parenleft.case @All @All @All @All parenright' by parenright.case;
sub parenleft.case @All @All @All @All @All parenright' by parenright.case;
sub parenleft.case @All @All @All @All @All @All parenright' by parenright.case;
sub braceleft.case @All @All braceright' by braceright.case;
sub braceleft.case @All @All @All braceright' by braceright.case;
sub braceleft.case @All @All @All @All braceright' by braceright.case;
sub braceleft.case @All @All @All @All @All braceright' by braceright.case;
sub braceleft.case @All @All @All @All @All @All braceright' by braceright.case;
sub bracketleft.case @All @All bracketright' by bracketright.case;
sub bracketleft.case @All @All @All bracketright' by bracketright.case;
sub bracketleft.case @All @All @All @All bracketright' by bracketright.case;
sub bracketleft.case @All @All @All @All @All bracketright' by bracketright.case;
sub bracketleft.case @All @All @All @All @All @All bracketright' by bracketright.case;

# END case
# -------------------------------------------------------------------------------------
# BEGIN NxN
# x surrounded by numbers, e.g:
#   3x4   -> 3×4
#   10x20 -> 10×20
#   0x10  -> 0x10   No substitution
#
@NumNoZero = [
  one          two          three        four         five
  six          seven        eight        nine         one.ss01
  three.1      four.ss01    six.ss01     nine.ss01

  one.tf       two.tf       three.tf     four.tf      five.tf
  six.tf       seven.tf     eight.tf     nine.tf      one.tf.ss01
  three.1.tf   four.tf.ss01 six.tf.ss01  nine.tf.ss01
];

sub @NumNoZero x' @Numeral by multiply.case; # "3x9" "1x0"
sub @Numeral @Numeral x' @Numeral by multiply.case; # "10x0"

sub @NumNoZero @Whitespace x' @Numeral by multiply.case; # "3 x9" "1 x0"
sub @NumNoZero @Whitespace x' @Whitespace @Numeral by multiply.case; # "3 x 9" "1 x 0"
sub @NumNoZero x' @Whitespace @Numeral by multiply.case; # "3x 9" "1x 0"

sub @Numeral @Numeral @Whitespace x' @Numeral by multiply.case; # "10 x0"
sub @Numeral @Numeral @Whitespace x' @Whitespace @Numeral by multiply.case; # "10 x 0"
sub @Numeral @Numeral x' @Whitespace @Numeral by multiply.case; # "10x 0"

# END NxN
# -------------------------------------------------------------------------------------