summaryrefslogtreecommitdiff
path: root/src/features/calt.fea
blob: 4374bb26df0eeb7a2558c2e6d96c5fe2dc2a2ba1 (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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# -------------------------------------------------------------------------------------
# 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_DELIM_L = [
  braceleft   braceright
  bracketleft bracketright
  parenleft   parenright
];
@CASE_NONDELIM_L = [
  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_L = [
  @CASE_DELIM_L
  @CASE_NONDELIM_L
];

@CASE_DELIM_R = [
  braceleft.case   braceright.case
  bracketleft.case bracketright.case
  parenleft.case   parenright.case
];
@CASE_NONDELIM_R = [
  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
];
@CASE_R = [
  @CASE_DELIM_R
  @CASE_NONDELIM_R
];

@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 ] [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] [ @DASH_ANY minus minus.case ] parenright' by parenright.case;

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

# A foo' -> A foo.case
#
# ignore subs adjacent to lower case
#
# h[1,3]
ignore sub @LC @CASE_DELIM_L @All @CASE_DELIM_L'; # h[X]
ignore sub @LC @CASE_DELIM_L @All @All @CASE_DELIM_L'; # h[XX]
ignore sub @LC @CASE_DELIM_L @All @All @All @CASE_DELIM_L'; # h[XXX]
ignore sub @LC @CASE_DELIM_L @All @All @All @All @CASE_DELIM_L'; # h[XXXX]
# x[]X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @UC;  # x[]X
ignore sub @LC @CASE_DELIM_L' @Whitespace @UC; # x[ X
ignore sub @LC @CASE_DELIM_L' @Whitespace @Whitespace @UC; # x[  X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @Whitespace @UC; # x[] X
ignore sub @LC @CASE_DELIM_L @CASE_DELIM_L' @Whitespace @Whitespace @UC; # x[]  X
ignore sub @LC @CASE_DELIM_L' @UC; # x[X

# short runs of uc-lc, e.g "(Xx)", "[xxX]"
ignore sub @CASE_DELIM_L' @UC @LC @CASE_DELIM_L; # (Xx)
ignore sub @CASE_DELIM_L' @UC @All @LC @CASE_DELIM_L; # (X.x)
ignore sub @CASE_DELIM_L @LC @UC @CASE_DELIM_L'; # (xX)
ignore sub @CASE_DELIM_L @LC @All @UC @CASE_DELIM_L'; # (x.X)

#
# e.g. "x-M"
ignore sub @LC @CASE_L'; # x-
ignore sub @LC @CASE_L @CASE_L'; # x--
ignore sub @LC @CASE_L @CASE_L @CASE_L'; # x---
# ignore sub @LC [@CASE_L @Whitespace] @CASE_L'; # x--, x -
# ignore sub @LC [@CASE_L @Whitespace] [@CASE_L @Whitespace] @CASE_L'; # x---, x --, x  -, x- -
# ignore sub @LC
#            [@CASE_L @Whitespace]
#            [@CASE_L @Whitespace]
#            [@CASE_L @Whitespace]
#            @CASE_L'; # x----, x ---, x  --, x   -, x- --, x-  -, x-- -
# ignore sub @LC
#            [@CASE_L @Whitespace]
#            [@CASE_L @Whitespace]
#            [@CASE_L @Whitespace]
#            [@CASE_L @Whitespace]
#            @CASE_L'; # x----- ...
#
# e.g. "x- "
# ignore sub @LC @CASE_L' @Whitespace; # "x- "
# ignore sub @LC @CASE_L' @Whitespace @Whitespace; # "x-  "
#
# e.g. "-x"
ignore sub @CASE_L' @LC; # -x
ignore sub @CASE_L' @CASE_L @LC; # --x
ignore sub @CASE_L' @CASE_L @CASE_L @LC; # ---x
# ignore sub @CASE_L @CASE_L @CASE_L @CASE_L @LC; # ----x
# ignore sub @CASE_L @CASE_L @CASE_L @CASE_L @CASE_L @LC; # -----x

#
# pairs with space, e.g. "( ) M" since we don't support subbing
# all on the left side.
ignore sub @CASE_DELIM_L @Whitespace @CASE_DELIM_L' @Whitespace [ @UC @CASE_R ];
#
# e.g. "A-", "A -", "A  -"
sub [ @UC @CASE_R ] @CASE_L' by @CASE_R;
sub [ @UC @CASE_R ] @Whitespace @CASE_L' by @CASE_R;
sub [ @UC @CASE_R ] @Whitespace @Whitespace @CASE_L' by @CASE_R;

# foo' foo foo foo foo A -> foo.case foo foo foo foo A
# foo' foo foo foo A -> foo.case foo foo foo A
# foo' foo foo A -> foo.case foo foo A
# foo' foo A -> foo.case foo A
# foo' A -> foo.case A
# Note: since we look quite far back, sequences like x{}[]M will case both
# the square brackets next to M _and_ the curly braces to become .case
#
# e.g. "-A", "--A", "---A", "----A", "-----A"
sub @CASE_L' [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L [ @CASE_R @UC ] by @CASE_R;
#
# e.g. "- A", "-- A", "--- A", "---- A", "----- A"
sub @CASE_L' @Whitespace [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L @Whitespace [ @CASE_R @UC ] by @CASE_R;
#
# e.g. "-  A", "--  A", "---  A", "----  A", "-----  A"
sub @CASE_L' @Whitespace @Whitespace [ @UC @CASE_R ] by @CASE_R;
sub @CASE_L' @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;
sub @CASE_L' @CASE_L @CASE_L @CASE_L @CASE_L @Whitespace @Whitespace [ @CASE_R @UC ] by @CASE_R;

# X(_)
sub @CASE_DELIM_R @Punctuation @CASE_DELIM_L' by @CASE_DELIM_R;

# in between number position adjustment, e.g. 3 /multiply 4 -> 3 multiply.case 4
@between_num_L = [
  multiply
  asterisk
];
@between_num_R = [
  multiply.case
  asterisk.case
];
sub @Numeral @between_num_L' @Numeral                                                 by @between_num_R; # 3*9
sub @Numeral @Whitespace @between_num_L' @Numeral                                     by @between_num_R; # 3 *9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Numeral                         by @between_num_R; # 3  *9
sub @Numeral @between_num_L' @Whitespace @Numeral                                     by @between_num_R; # 3* 9
sub @Numeral @Whitespace @between_num_L' @Whitespace @Numeral                         by @between_num_R; # 3 * 9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Whitespace @Numeral             by @between_num_R; # 3  * 9
sub @Numeral @between_num_L' @Whitespace @Whitespace @Numeral                         by @between_num_R; # 3*  9
sub @Numeral @Whitespace @between_num_L' @Whitespace @Whitespace @Numeral             by @between_num_R; # 3 *  9
sub @Numeral @Whitespace @Whitespace @between_num_L' @Whitespace @Whitespace @Numeral by @between_num_R; # 3  *  9

# END case
# -------------------------------------------------------------------------------------
# BEGIN NxN
# x surrounded by numbers, e.g:
#   3x4   -> 3×4
#   10x20 -> 10×20
#   0x10  -> 0x10   No substitution
#
@NumNoZero = [
  #
  # NOTE! Keep this up to date with @Whitespace
  #
  #   1. in glyphs, copy list from font into > features > Whitespace class
  #   2. paste & replace this list here
  #   3. remove all "zero" glyphs
  #
  one two twostroke three four five Tonefive 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
# -------------------------------------------------------------------------------------