summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/fonts/amiri/sources/contextuals.fea
blob: 1e921e2400b54ab1eff67bee0e77ede2078e4146 (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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
// replace tashkil following shadda by smaller alternates

@ShaddaTashkil = [uni064E uni064B uni064C uni064F uni08F0 uni08F1 uni0657];
@ShaddaTashkil.small = [uni064E.small uni064B.small uni064C.small uni064F.small uni08F0.small uni08F1.small uni0657.small];

lookup SamallTashkil {
  sub @ShaddaTashkil by @ShaddaTashkil.small;
} SamallTashkil;

feature calt {
  sub [uni0651 uni06EC] @ShaddaTashkil' lookup SamallTashkil;
} calt;

#ifdef QURAN
// a rather ugly hack for the brain dead Unicode canonical reordering of some
// Arabic combining marks

lookup TashkilShaddaHack {
  sub uni064E by uni06EC uni064E.small;
  sub uni064B by uni06EC uni064B.small;
  sub uni064C by uni06EC uni064C.small;
  sub uni064F by uni06EC uni064F.small;
  sub uni08F0 by uni06EC uni08F0.small;
  sub uni08F1 by uni06EC uni08F1.small;
  sub uni0657 by uni06EC uni0657.small;
} TashkilShaddaHack;

feature calt {
  sub @ShaddaTashkil [uni06EC]' by dummy1;
} calt;

feature calt {
  sub @ShaddaTashkil' lookup TashkilShaddaHack dummy1;
} calt;

// non-hack
feature calt {
  sub [uni065C] [uni0650]' by [uni0650.small2];
} calt;

// hack
feature calt {
  sub [uni0650] [uni065C]' by dummy2;
} calt;

lookup uni065cHack {
  sub uni0650 by uni065C uni0650.small2;
} uni065cHack;

feature calt {
  sub [uni0650]' lookup uni065cHack dummy2;
} calt;

#endif

// replace tashkil following hamza by smaller alternates
feature calt {
  sub @AlefHamzaAbove [uni064E uni064F uni0652]' by [uni064E.small2 uni064F.small uni0652.small2];
  sub @AlefHamzaBelow [uni0650]'                 by [uni0650.small2];
  sub [uni0655]       [uni0650]'                 by [uni0650.small2];
} calt;

// replace hamza mark when following a final heh by a glyph that only have a
// HamzaAbove mark so it will be positioned correctly
feature calt {
  sub [uni0647 uni06D5 uni06C1 uni0647.fina uni06D5.fina uni06C1.fina] [uni0654]' by hamza.above;
} calt;

lookup BaaInitWide {
  sub @aBaa.init by @aBaa.init_Wide;
} BaaInitWide;

feature calt {
  sub @aBaa.init' lookup BaaInitWide @Tashkil.above' [@aGaf.medi @aGaf.fina]';
  sub @aBaa.init' lookup BaaInitWide @Tashkil.above' @Tashkil.above' [@aGaf.medi @aGaf.fina]';
  sub @aBaa.init' lookup BaaInitWide @Tashkil.above' @Tashkil.above' @Tashkil.above' [@aGaf.medi @aGaf.fina]';
} calt;

lookup AboveHaaInit {
  sub @aBaa.init by @aBaa.init_BaaHaaInit;
  sub @aHaa.medi by @aHaa.medi_SadHaaInit;
  sub @aHeh.init by @aHeh.init_HehHaaInit;
  sub @aMem.init by @aMem.init_MemHaaInit;
  sub @aSad.init by @aSad.init_SadHaaInit;
  sub @aSen.init by @aSen.init_SenHaaInit;
} AboveHaaInit;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.init @aHeh.init @aMem.init @aSad.init @aSen.init]' lookup AboveHaaInit
      [@aHaa.medi]' lookup AboveHaaInit;
} calt;

lookup BaaRaaFina {
  sub @aBaa.medi by @aBaa.medi_BaaRaaFina;
  sub @aRaa.fina by @aRaa.fina_BaaRaaFina;
} BaaRaaFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.medi]' lookup BaaRaaFina
      [@aRaa.fina]' lookup BaaRaaFina;
} calt;

lookup BaaNonFina {
  sub @aBaa.medi by @aBaa.medi_BaaNonFina;
  sub @aNon.fina by @aNon.fina_BaaNonFina;
} BaaNonFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.medi]' lookup BaaNonFina
      [@aNon.fina]' lookup BaaNonFina;
} calt;

lookup BaaMemFina {
  sub @aBaa.medi by @aBaa.medi_BaaMemFina;
  sub @aMem.fina by @aMem.fina_BaaMemFina;
} BaaMemFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.medi]' lookup BaaMemFina
      [@aMem.fina]' lookup BaaMemFina;
} calt;

lookup KafBaaAlfIsol {
  sub @aBaa.medi by @aBaa.medi_KafBaaInit;
  sub @aKaf.init by @aKaf.init_KafBaaInit;
} KafBaaAlfIsol;

lookup KafBaaAlfFina {
  sub @aBaa.medi by @aBaa.medi_KafBaaMedi;
  sub @aKaf.medi by @aKaf.medi_KafBaaMedi;
} KafBaaAlfFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aKaf.init]' lookup KafBaaAlfIsol
      [@aBaa.medi]' lookup KafBaaAlfIsol
      [@aAlf.fina @aLam.medi @aLam.fina];

  sub [@aKaf.medi]' lookup KafBaaAlfFina
      [@aBaa.medi]' lookup KafBaaAlfFina
      [@aAlf.fina @aLam.medi @aLam.fina];
} calt;

lookup BaaBaa {
  sub @aBaa.medi by @aBaa.medi_BaaBaaInit;
  sub @aBaa.fina by @aBaa.fina_BaaBaaIsol;
  sub @aBaa.init by @aBaa.init_BaaBaaIsol;
} BaaBaa;

lookup HighBaa {
  sub @aBaa.init by @aBaa.init_High;
  sub @aBaa.medi by @aBaa.medi_High;
} HighBaa;

feature calt {
  lookupflag IgnoreMarks;
  // hack to prevent double high baa in سببس and likes
  sub [@aSen.init @aSen.medi]'
      [@aBaa.medi]'
      [@aBaa.medi]' lookup HighBaa
      [@aSen.medi @aSen.fina]';

  // جرينتش
  sub [@aBaa.init]' lookup BaaBaa
      [@aBaa.medi]' lookup BaaBaa
      [@aBaa.medi]' lookup HighBaa
      [@aSen.fina @aSen.medi @aSen.medi_PreYaa];

  sub [@aBaa.medi @aSad.init @aSad.medi @aSen.init @aSen.medi @aBaa.medi_BaaBaaInit]
      [@aBaa.medi]' lookup HighBaa
      [@aBaa.fina @aBaa.medi @aSen.fina @aBaa.medi_BaaHehMedi @aSen.medi @aSen.medi_PreYaa];

  sub [@aBaa.medi]' lookup HighBaa
      [@aSen.fina @aSen.medi @aSen.medi_PreYaa];

  sub [@aBaa.init]' lookup HighBaa
      [@aBaa.medi]' lookup HighBaa
      [@aBaa.medi @aBaa.fina @aSen.medi @aSen.fina];
} calt;

lookup BaaHeh {
  sub @aBaa.init by @aBaa.init_BaaHehInit;
  sub @aMem.init_dots by @aMem.init_MemHehInit;
  sub @aBaa.medi by @aBaa.medi_BaaHehMedi;
  sub @aHeh.medi by @aHeh.medi_BaaHehMedi;
} BaaHeh;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.init @aBaa.medi @aMem.init_dots]' lookup BaaHeh
      [@aHeh.medi]' lookup BaaHeh;
} calt;

lookup BaaBaaHeh {
  sub @aBaa.init by @aBaa.init_BaaBaaHeh;
} BaaBaaHeh;

feature calt {
  lookupflag IgnoreMarks;
  sub @aBaa.init' lookup BaaBaaHeh
      @aBaa.medi_BaaHehMedi;
} calt;

lookup LamAlfFina {
  sub @aAlf.fina by @aAlf.fina_LamAlfFina;
  sub @aLam.medi by @aLam.medi_LamAlfFina;
} LamAlfFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aLam.medi]' lookup LamAlfFina
      [@aAlf.fina]' lookup LamAlfFina;
} calt;

lookup KafLamHeh {
  sub @aLam.medi by @aLam.medi_KafLamHehIsol;
} KafLamHeh;

lookup BaaSenAltInit {
  sub @aBaa.init by @aBaa.init_BaaSenAltInit;
  sub @aRaa.fina by @aRaa.fina_PostTooth;
  sub @aSen.medi by @aSen.medi_BaaSenAltInit;
  sub @aHeh.medi by @aHeh.medi_PostTooth;
  sub @aYaa.fina by @aYaa.fina_PostTooth;
  sub @aMem.fina by @aMem.fina_PostTooth;
} BaaSenAltInit;

lookup LamHaaHaaInit {
  sub @aHaa.medi by @aHaa.medi_1LamHaaHaaInit;
  sub @aLam.init by @aLam.init_LamHaaHaaInit;
} LamHaaHaaInit;

lookup LamHaaHaaInit2 {
  sub @aHaa.medi by @aHaa.medi_2LamHaaHaaInit;
} LamHaaHaaInit2;

lookup KafHeh {
  sub @aKaf.init by @aKaf.init_KafHeh;
  sub @aKaf.medi by @aKaf.medi_KafHeh;
  sub @aHeh.fina by @aHeh.fina_KafHeh;
  sub @aDal.fina by @aDal.fina_KafDal;
} KafHeh;

lookup LamMemFina {
  sub @aLam.medi by @aLam.medi_LamMemFina;
  sub @aMem.fina by @aMem.fina_LamMemFina;
} LamMemFina;

lookup SenMemInit {
  sub @aSen.init by @aSen.init_SenMemInit;
  sub @aSad.init by @aSad.init_SadMemInit;
  sub @aMem.init by @aMem.init_MemMemInit;
  sub @aMem.medi by @aMem.medi_SenMemInit;
} SenMemInit;

lookup AllYaaIsol {
  sub @aKaf.init by @aKaf.init_KafYaaIsol;
  sub @aBaa.init by @aBaa.init_BaaYaaIsol;
  sub @aFaa.init by @aFaa.init_FaaYaaIsol;
  sub @aLam.init by @aLam.init_LamYaaIsol;
  sub @aAyn.init by @aAyn.init_AynYaaIsol;
  sub @aHaa.init by @aHaa.init_HaaYaaIsol;
  sub @aHeh.init by @aHeh.init_HehYaaIsol;
  sub @aMem.init_dots by @aMem.init_MemYaaIsol;
  sub @aYaa.fina by @aYaa.fina_KafYaaIsol;
} AllYaaIsol;

lookup BaaRaaIsol {
  sub @aBaa.init by @aBaa.init_BaaRaaIsol;
  sub @aRaa.fina by @aRaa.fina_BaaRaaIsol;
} BaaRaaIsol;

lookup LamHehIsol {
  sub @aLam.init by @aLam.init_LamHeh;
  sub @aLam.medi by @aLam.medi_LamHeh;
  sub @aLam.medi_LamLamInit by @aLam.medi_LamLamHehIsol;
  sub @aHeh.fina by @aHeh.fina_LamHeh;
  sub @aDal.fina by @aDal.fina_LamDal;
} LamHehIsol;

lookup LamWawFina {
  sub @aLam.medi by @aLam.medi_LamWawFina;
  sub @aWaw.fina by @aWaw.fina_LamWawFina;
} LamWawFina;

lookup FaaYaaFina {
  sub @aFaa.medi by @aFaa.medi_FaaYaaFina;
  sub @aYaa.fina by @aYaa.fina_FaaYaaFina;
} FaaYaaFina;

lookup LamLamHaaInit {
  sub @aHaa.medi by @aHaa.medi_LamLamHaaInit;
  sub @aLam.init by @aLam.init_LamLamHaaInit;
  sub @aLam.medi by @aLam.medi_LamLamHaaInit;
} LamLamHaaInit;

lookup LamBaaMemInit {
  sub @aBaa.medi by @aBaa.medi_LamBaaMemInit;
  sub @aLam.init by @aLam.init_LamBaaMemInit;
  sub @aMem.medi by @aMem.medi_LamBaaMemInit;
} LamBaaMemInit;

lookup KafLamMemMedi {
  sub @aLam.medi by @aLam.medi_KafLamMemMedi;
} KafLamMemMedi;

lookup KafLamMemFina {
  sub @aLam.medi by @aLam.medi_KafLamMemFina;
  sub @aLam.medi_LamMemFina by @aLam.medi_KafLamMemFina;
} KafLamMemFina;

lookup BaaDalIsol {
  sub @aBaa.init by @aBaa.init_BaaDal;
  sub @aDal.fina by @aDal.fina_BaaDal;
} BaaDalIsol;

lookup BaaMemHaaInit {
  sub @aBaa.init by @aBaa.init_BaaMemHaaInit;
  sub @aHaa.medi by @aHaa.medi_BaaMemHaaInit;
  sub @aMem.medi by @aMem.medi_BaaMemHaaInit;
} BaaMemHaaInit;

lookup BaaBaaYaa {
  sub @aBaa.init by @aBaa.init_BaaBaaYaa;
  sub @aBaa.medi by @aBaa.medi_BaaBaaYaa;
  sub @aYaa.fina by @aYaa.fina_BaaBaaYaa;
} BaaBaaYaa;

@LamLamFoo = [@aLam.medi_LamMemMedi @aLam.medi_LamHeh @aLam.medi_LamYaaFina];

lookup LamLamInit {
  sub @aLam.init by @aLam.init_LamLamInit;
  sub @aLam.medi by @aLam.medi_LamLamInit;
  sub @aLam.fina by @aLam.fina_LamLamIsol;
  sub @aKaf.fina by @aKaf.fina_LamKafIsol;
  sub @aGaf.alt.fina by @aGaf.fina_LamKafIsol;
  sub @aLam.medi_LamAlfFina by @aLam.medi_LamLamAlfIsol;
  sub @LamLamFoo by [@aLam.medi_LamLamMemInit @aLam.medi_LamLamHehIsol @aLam.medi_LamLamYaaIsol];
} LamLamInit;

lookup LamLamMedi {
  sub @aLam.medi by @aLam.medi_LamLamMedi2;
  sub @aLam.fina by @aLam.fina_LamLamFina;
  sub @aKaf.fina by @aKaf.fina_LamKafFina;
  sub @aGaf.alt.fina by @aGaf.fina_LamKafFina;
  sub @aLam.medi_LamAlfFina by @aLam.medi_LamLamAlefFina;
  sub @LamLamFoo by [@aLam.medi_LamLamMemMedi @aLam.medi_LamLamHehFina @aLam.medi_LamLamYaaFina];
} LamLamMedi;

lookup LamLamMedi2 {
  sub @aLam.medi by @aLam.medi_LamLamMedi;
} LamLamMedi2;

lookup LamYaaFina {
  sub @aLam.medi by @aLam.medi_LamYaaFina;
  sub @aYaa.fina by @aYaa.fina_LamYaaFina;
} LamYaaFina;

lookup LamMemHaaInit {
  sub @aHaa.medi by @aHaa.medi_LamMemHaaInit;
  sub @aLam.init by @aLam.init_LamMemHaaInit;
  sub @aMem.medi by @aMem.medi_LamMemHaaInit;
} LamMemHaaInit;

#ifndef QURAN
lookup LamMemInit {
  sub @aLam.init by @aLam.init_LamMemInit;
  sub @aMem.medi by @aMem.medi_LamMemInit;
} LamMemInit;
#endif

lookup LamAlfIsol {
  sub @aAlf.fina by @aAlf.fina_LamAlfIsol;
  sub @aLam.init by @aLam.init_LamAlfIsol;
} LamAlfIsol;

#ifndef QURAN
lookup LamHaaMemInit {
  sub @aHaa.medi by @aHaa.medi_LamHaaMemInit;
  sub @aLam.init by @aLam.init_LamHaaMemInit;
  sub @aMem.medi by @aMem.medi_LamHaaMemInit;
} LamHaaMemInit;
#endif

lookup BaaBaaMemInit {
  sub @aBaa.init by @aBaa.init_BaaBaaMemInit;
  sub @aBaa.medi by @aBaa.medi_BaaBaaMemInit;
  sub @aMem.medi by @aMem.medi_BaaBaaMemInit;
} BaaBaaMemInit;

lookup BaaBaaHaaInit {
  sub @aBaa.init by @aBaa.init_BaaBaaHaaInit;
  sub @aBaa.medi by @aBaa.medi_BaaBaaHaaInit;
  sub @aHaa.medi by @aHaa.medi_BaaBaaHaaInit;
} BaaBaaHaaInit;

lookup MemRaaIsol {
  sub @aMem.init by @aMem.init_MemRaaIsol;
  sub @aRaa.fina by @aRaa.fina_MemRaaIsol;
} MemRaaIsol;

lookup HaaHaaInit {
  sub @aHaa.init by @aHaa.init_HaaHaaInit;
  sub @aHaa.medi by @aHaa.medi_HaaHaaInit;
} HaaHaaInit;

lookup KafMemIsol {
  sub @aKaf.init by @aKaf.init_KafMemIsol;
  sub @aLam.init by @aLam.init_LamMemIsol;
  sub @aBaa.init by @aBaa.init_BaaMemIsol;
  sub @aMem.fina by @aMem.fina_KafMemIsol;
} KafMemIsol;

lookup LamQafFina {
  sub @aLam.medi by @aLam.medi_LamQafFina;
  sub @aQaf.fina by @aQaf.fina_LamQafFina;
} LamQafFina;

lookup MemHaaMemInit {
  sub @aHaa.medi by @aHaa.medi_MemHaaMemInit;
  sub @aMem.init by @aMem.init_MemHaaMemInit;
  sub @aMem.init_MemHaaInit by @aMem.init_MemHaaMemInit;
  sub @aHaa.medi_SadHaaInit by @aHaa.medi_MemHaaMemInit;
} MemHaaMemInit;

lookup BaaNonIsol {
  sub @aBaa.init by @aBaa.init_BaaNonIsol;
  sub @aNon.fina by @aNon.fina_BaaNonIsol;
} BaaNonIsol;

lookup KafMemFina {
  sub @aKaf.medi by @aKaf.medi_KafMemFina;
  sub @aMem.fina by @aMem.fina_KafMemFina;
} KafMemFina;

lookup KafLamAlf {
  sub @aLam.medi by @aLam.medi_KafLamAlf;
  sub @aLam.medi_LamAlfFina by @aLam.medi_KafLamAlf;
} KafLamAlf;

lookup BaaSenInit {
  sub @aBaa.init by @aBaa.init_BaaSenInit;
  sub @aSen.fina by @aSen.fina_BaaSen;
  sub @aSen.medi by @aSen.medi_BaaSenInit;
} BaaSenInit;

lookup KafRaaFina {
  sub @aKaf.medi by @aKaf.medi_KafRaaFina;
  sub @aRaa.fina by @aRaa.fina_KafRaaFina;
} KafRaaFina;

lookup LamHehInit {
  sub @aHeh.medi by @aHeh.medi_LamHehInit;
  sub @aLam.init by @aLam.init_LamHehInit;
} LamHehInit;

lookup BaaMemInit {
  sub @aBaa.init by @aBaa.init_BaaMemInit;
  sub @aMem.medi by @aMem.medi_BaaMemInit;
} BaaMemInit;

lookup KafLam {
  sub @aKaf.init by @aKaf.init_KafLam;
  sub @aKaf.medi by @aKaf.medi_KafLam;
  sub @aKaf.fina by @aKaf.fina_KafKafFina;
  sub @aGaf.alt.fina by @aGaf.fina_KafKafFina;
  sub @aLam.medi by @aLam.medi_KafLam;
  sub @aLam.fina by @aLam.fina_KafLam;
  sub @aAlf.fina by @aAlf.fina_KafAlf;
} KafLam;

lookup KafRaaIsol {
  sub @aKaf.init by @aKaf.init_KafRaaIsol;
  sub @aRaa.fina by @aRaa.fina_KafRaaIsol;
} KafRaaIsol;

lookup AynHaaInit {
  sub @aAyn.init by @aAyn.init_AynHaaInit;
  sub @aHaa.medi by @aHaa.medi_AynHaaInit;
} AynHaaInit;

lookup KafYaaFina {
  sub @aKaf.medi by @aKaf.medi_KafYaaFina;
  sub @aAyn.medi by @aAyn.medi_AynYaaFina;
  sub @aYaa.fina by @aYaa.fina_KafYaaFina;
} KafYaaFina;

lookup LamMemMedi {
  sub @aLam.medi by @aLam.medi_LamMemMedi;
  sub @aMem.medi_dots by @aMem.medi_LamMemMedi;
} LamMemMedi;

lookup SenBaaMemInit {
  sub @aSen.init by @aSen.init_SenBaaMemInit;
  sub @aSad.init by @aSad.init_SenBaaMemInit;
  sub @aBaa.medi by @aBaa.medi_SenBaaMemInit;
  sub @aMem.medi by @aMem.medi_SenBaaMemInit;
} SenBaaMemInit;

lookup HaaRaaIsol {
  sub @aHaa.init by @aHaa.init_HaaRaaIsol;
  sub @aRaa.fina by @aRaa.fina_HaaRaaIsol;
} HaaRaaIsol;

lookup LamRaaIsol {
  sub @aLam.init by @aLam.init_LamRaaIsol;
  sub @aRaa.fina by @aRaa.fina_LamRaaIsol;
} LamRaaIsol;

lookup KafMemAlf {
  sub @aKaf.medi by @aKaf.medi_KafMemAlf;
  sub @aKaf.init by @aKaf.init_KafMemAlf;
  sub @aMem.medi by @aMem.medi_KafMemAlf;
  sub @aAlf.fina by @aAlf.fina_KafMemAlf;
  sub @aLam.fina by @aLam.fina_KafMemLam;
  sub @aLam.medi by @aLam.medi_KafMemLam;
} KafMemAlf;

lookup BaaHaaMemInit {
  sub @aBaa.init by @aBaa.init_BaaHaaMemInit;
  sub @aHaa.medi by @aHaa.medi_BaaHaaMemInit;
  sub @aHaa.medi_SadHaaInit by @aHaa.medi_BaaHaaMemInit;
  sub @aBaa.init_BaaHaaInit by @aBaa.init_BaaHaaMemInit;
} BaaHaaMemInit;

lookup AboveHaaIsol {
  sub @aAyn.init by @aAyn.init_AboveHaa;
  sub @aBaa.init by @aBaa.init_AboveHaa;
  sub @aFaa.init by @aFaa.init_FaaHaaInit;
  sub @aHaa.init by @aHaa.init_AboveHaa;
  sub @aHeh.init by @aHeh.init_AboveHaa;
  sub @aKaf.init by @aKaf.init_AboveHaa;
  sub @aLam.init by @aLam.init_LamHaaInit;
  sub @aMem.init by @aMem.init_AboveHaa;
  sub @aSad.init by @aSad.init_AboveHaa;
  sub @aSen.init by @aSen.init_AboveHaa;
  sub @aHaa.fina by @aHaa.fina_AboveHaaIsol;
} AboveHaaIsol;

lookup AboveHaaIsol2 {
  sub @aHaa.fina by @aHaa.fina_AboveHaaIsol2;
  sub @aHaa.medi by @aHaa.medi_FaaHaaInit;
} AboveHaaIsol2;

lookup SenYaaFina {
  sub @aRaa.fina by @aRaa.fina_PostTooth;
  sub @aSad.init by @aSad.init_PreYaa;
  sub @aSad.medi by @aSad.medi_PreYaa;
  sub @aSen.init by @aSen.init_PreYaa;
  sub @aSen.medi by @aSen.medi_PreYaa;
  sub @aYaa.fina by @aYaa.fina_PostTooth;
} SenYaaFina;

lookup KafMemInit {
  sub @aKaf.init by @aKaf.init_KafMemInit;
  sub @aKaf.medi by @aKaf.medi_KafMemMedi;
  sub @aAyn.init by @aAyn.init_AynMemInit;
  sub @aFaa.init by @aFaa.init_FaaMemInit;
  sub @aHaa.init by @aHaa.init_HaaMemInit;
  sub @aHeh.init by @aHeh.init_HehMemInit;
  sub @aMem.medi by @aMem.medi_KafMemMedi;
} KafMemInit;

// the Lam.medi+Mem.fina is too narrow for tashkil, so we use a wider (extended)
// meem when tashkil clash is anticipated.
lookup LamMemFinaExtended {
  sub @aMem.fina by @aMem.fina_LamMemFinaExtended;
} LamMemFinaExtended;

feature calt {
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.above'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above' @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.above'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above' @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.below' @Tashkil.above'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.above' @Tashkil.below'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.above';
  sub @aLam.medi' lookup LamMemFina
      @Tashkil.below'
      @aMem.fina' lookup LamMemFinaExtended
      @Tashkil.below';
} calt;

// ditto
lookup MemExtended {
  sub @aMem.fina by @aMem.fina_KafMemIsolExtended;
} MemExtended;

feature calt {
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.above'
      @aMem.fina' lookup MemExtended
      @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup MemExtended
      @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup MemExtended
      @Tashkil.above' @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.above'
      @aMem.fina' lookup MemExtended
      @Tashkil.above' @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.below' @Tashkil.above'
      @aMem.fina' lookup MemExtended
      @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.above' @Tashkil.below'
      @aMem.fina' lookup MemExtended
      @Tashkil.above';
  sub [@aLam.init @aKaf.init]' lookup KafMemIsol
      @Tashkil.below'
      @aMem.fina' lookup MemExtended
      @Tashkil.below';
} calt;

//ditto, but we don't have LamMemInit in Quran font
#ifndef QURAN
lookup LamMemInitTatweel {
  sub @aMem.medi by @aMem.medi_LamMemInitTatweel;
} LamMemInitTatweel;

feature calt {
  sub @aLam.init' lookup LamMemInit
      @Tashkil.above'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.above' @Tashkil.above'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.above' @Tashkil.above'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above' @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.above'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above' @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.below' @Tashkil.above'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.above' @Tashkil.below'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.above';
  sub @aLam.init' lookup LamMemInit
      @Tashkil.below'
      @aMem.medi' lookup LamMemInitTatweel
      @Tashkil.below';
} calt;
#endif

// ditto
lookup KafMemFinaExtended {
  sub @aMem.fina by @aMem.fina_KafMemFinaExtended;
} KafMemFinaExtended;

feature calt {
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.above'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above';
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above';
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.above' @Tashkil.above'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above' @Tashkil.above';
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.above'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above' @Tashkil.above';
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.below' @Tashkil.above'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above;
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.above' @Tashkil.below'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.above';
  sub @aKaf.medi' lookup KafMemFina
      @Tashkil.below'
      @aMem.fina' lookup KafMemFinaExtended
      @Tashkil.below';
} calt;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi]' lookup KafLamHeh
      [@aHeh.fina @aDal.fina]' lookup LamHehIsol;

  sub [@aKaf.init @aKaf.medi]' lookup KafMemAlf
      [@aMem.medi]' lookup KafMemAlf
      [@aLam.medi @aLam.fina @aAlf.fina]' lookup KafMemAlf;

  sub [@aBaa.init]' lookup BaaSenAltInit
      [@aSen.medi]' lookup BaaSenAltInit
      [@aHeh.medi @aRaa.fina @aYaa.fina @aMem.fina]' lookup BaaSenAltInit;

  sub [@aLam.init]' lookup LamHaaHaaInit
      [@aHaa.medi]' lookup LamHaaHaaInit
      [@aHaa.medi]' lookup LamHaaHaaInit2;

  sub [@aKaf.init @aKaf.medi]' lookup KafHeh
      [@aHeh.fina @aDal.fina]' lookup KafHeh;

  sub [@aLam.medi]' lookup LamMemFina
      [@aMem.fina]' lookup LamMemFina;

  sub [@aSen.init @aSad.init @aMem.init]' lookup SenMemInit
      [@aMem.medi]' lookup SenMemInit;

  sub [@aKaf.init @aBaa.init @aFaa.init @aLam.init @aAyn.init @aHaa.init @aHeh.init @aMem.init_dots]' lookup AllYaaIsol
      [@aYaa.fina]' lookup AllYaaIsol;

  sub [@aBaa.init]' lookup BaaRaaIsol
      [@aRaa.fina]' lookup BaaRaaIsol;

  sub [@aLam.init @aLam.medi @aLam.medi_LamLamInit]' lookup LamHehIsol
      [@aHeh.fina @aDal.fina]' lookup LamHehIsol;

  sub [@aLam.medi]' lookup LamWawFina
      [@aWaw.fina]' lookup LamWawFina;

  sub [@aFaa.medi]' lookup FaaYaaFina
      [@aYaa.fina]' lookup FaaYaaFina;

  sub [@aLam.init]' lookup LamLamHaaInit
      [@aLam.medi]' lookup LamLamHaaInit
      [@aHaa.medi]' lookup LamLamHaaInit;

  sub [@aLam.init]' lookup LamBaaMemInit
      [@aBaa.medi]' lookup LamBaaMemInit
      [@aMem.medi]' lookup LamBaaMemInit;

  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi]' lookup KafLamMemMedi
      [@aMem.medi_dots]' lookup LamMemMedi;

  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi @aLam.medi_LamMemFina]' lookup KafLamMemFina
      [@aMem.fina @aMem.fina_LamMemFinaExtended]' lookup LamMemFina;

  sub [@aBaa.init]' lookup BaaDalIsol
      [@aDal.fina]' lookup BaaDalIsol;

  sub [@aBaa.init]' lookup BaaMemHaaInit
      [@aMem.medi]' lookup BaaMemHaaInit
      [@aHaa.medi]' lookup BaaMemHaaInit;

  sub [@aBaa.init]' lookup BaaBaaYaa
      [@aBaa.medi]' lookup BaaBaaYaa
      [@aYaa.fina]' lookup BaaBaaYaa;

  sub [@aLam.medi]' lookup LamYaaFina
      [@aYaa.fina]' lookup LamYaaFina;

  sub [@aLam.init]' lookup LamMemHaaInit
      [@aMem.medi]' lookup LamMemHaaInit
      [@aHaa.medi]' lookup LamMemHaaInit;

#ifndef QURAN
  sub [@aLam.init]' lookup LamMemInit
      [@aMem.medi]' lookup LamMemInit;
#endif

  sub [@aLam.init]' lookup LamAlfIsol
      [@aAlf.fina]' lookup LamAlfIsol;

#ifndef QURAN
  sub [@aLam.init]' lookup LamHaaMemInit
      [@aHaa.medi]' lookup LamHaaMemInit
      [@aMem.medi]' lookup LamHaaMemInit;
#endif

  sub [@aBaa.init]' lookup BaaBaaMemInit
      [@aBaa.medi]' lookup BaaBaaMemInit
      [@aMem.medi]' lookup BaaBaaMemInit;

  sub [@aBaa.init]' lookup BaaBaaHaaInit
      [@aBaa.medi]' lookup BaaBaaHaaInit
      [@aHaa.medi]' lookup BaaBaaHaaInit;

  sub [@aMem.init]' lookup MemRaaIsol
      [@aRaa.fina]' lookup MemRaaIsol;

  sub [@aAyn.init]'
      [@aRaa.fina]' lookup MemRaaIsol;

  sub [@aHaa.init]' lookup HaaHaaInit
      [@aHaa.medi]' lookup HaaHaaInit;

  sub [@aKaf.init @aLam.init @aBaa.init]' lookup KafMemIsol
      [@aMem.fina]' lookup KafMemIsol;

  sub [@aLam.medi]' lookup LamQafFina
      [@aQaf.fina]' lookup LamQafFina;

  sub [@aMem.init @aMem.init_MemHaaInit]' lookup MemHaaMemInit
      [@aHaa.medi @aHaa.medi_SadHaaInit]' lookup MemHaaMemInit
      [@aMem.medi]' lookup KafMemInit;

  sub [@aBaa.init]' lookup BaaNonIsol
      [@aNon.fina]' lookup BaaNonIsol;

  sub [@aKaf.medi]' lookup KafMemFina
      [@aMem.fina]' lookup KafMemFina;

  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi @aLam.medi_LamAlfFina]' lookup KafLamAlf
      [@aAlf.fina @aAlf.fina_LamAlfFina];

  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi @aLam.medi_LamAlfFina]' lookup KafLamAlf
       // see float hamza in quran.fea
       uni0621.float'
      [@aAlf.fina @aAlf.fina_LamAlfFina];

  sub [@aBaa.init]' lookup BaaSenInit
      [@aSen.medi]' lookup BaaSenInit;

  sub [@aBaa.init]' lookup BaaSenAltInit
      [@aSen.fina]' lookup BaaSenInit;

  sub [@aKaf.medi]' lookup KafRaaFina
      [@aRaa.fina]' lookup KafRaaFina;

  sub [@aLam.init]' lookup LamHehInit
      [@aHeh.medi]' lookup LamHehInit;

  sub [@aBaa.init]' lookup BaaMemInit
      [@aMem.medi]' lookup BaaMemInit;

  sub [@aKaf.init @aKaf.medi]' lookup KafLam
      [@aLam.medi @aLam.fina @aAlf.fina @aKaf.fina]' lookup KafLam;

  sub [@aKaf.init]' lookup KafRaaIsol
      [@aRaa.fina]' lookup KafRaaIsol;

  sub [@aAyn.init]' lookup AynHaaInit
      [@aHaa.medi]' lookup AynHaaInit;

  sub [@aKaf.medi @aAyn.medi]' lookup KafYaaFina
      [@aYaa.fina]' lookup KafYaaFina;

  sub [@aLam.medi]' lookup LamMemMedi
      [@aMem.medi_dots]' lookup LamMemMedi;

  sub [@aSen.init @aSad.init]' lookup SenBaaMemInit
      [@aBaa.medi]' lookup SenBaaMemInit
      [@aMem.medi]' lookup SenBaaMemInit;

  sub [@aBaa.init]' lookup BaaBaa
      [@aBaa.medi @aBaa.fina]' lookup BaaBaa;

  sub [@aHaa.init]' lookup HaaRaaIsol
      [@aRaa.fina]' lookup HaaRaaIsol;

  sub [@aLam.init]' lookup LamRaaIsol
      [@aRaa.fina]' lookup LamRaaIsol;

  sub [@aBaa.init @aBaa.init_BaaHaaInit]' lookup BaaHaaMemInit
      [@aHaa.medi @aHaa.medi_SadHaaInit]' lookup BaaHaaMemInit
      [@aMem.medi]' lookup KafMemInit;

  sub [@aAyn.init @aBaa.init @aHaa.init @aHeh.init @aMem.init @aSad.init @aSen.init]' lookup AboveHaaIsol
      [@aHaa.fina]' lookup AboveHaaIsol;

  sub [@aFaa.init @aLam.init @aKaf.init]' lookup AboveHaaIsol
      [@aHaa.medi @aHaa.fina]' lookup AboveHaaIsol2;

  sub [@aSen.init @aSad.init @aSen.medi @aSad.medi]' lookup SenYaaFina
      [@aYaa.fina @aRaa.fina]' lookup SenYaaFina;
} calt;

lookup ToothYaaBari {
  sub @aSen.init by @aSen.init_YaaBari;
  sub @aSad.init by @aSad.init_YaaBari;
  sub @aYaaBari.fina by @aYaaBari.fina_PostTooth;
} ToothYaaBari;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aSen.init @aSad.init]' lookup ToothYaaBari
      [@aYaaBari.fina]'      lookup ToothYaaBari;
} calt;

lookup ToothYaaBariFina {
  sub @aBaa.medi            by @aBaa.medi_YaaBari;
  sub @aBaa.init_BaaBaaIsol by @aBaa.init_BaaBaaYaaBari;
  sub @aBaa.medi_BaaBaaInit by @aBaa.medi_YaaBari;
  sub @aHaa.init_DotBelow   by @aHaa.init_BaaYaaBari;
  sub @aYaaBari.fina      by @aYaaBari.fina_PostToothFina;
} ToothYaaBariFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aHaa.init_DotBelow]' lookup ToothYaaBariFina
      [@aBaa.medi]'          lookup ToothYaaBariFina
      [@aYaaBari.fina]'    lookup ToothYaaBariFina;

  sub [@aBaa.medi]'       lookup ToothYaaBariFina
      [@aYaaBari.fina]' lookup ToothYaaBariFina;

  sub [@aBaa.init_BaaBaaIsol]' lookup ToothYaaBariFina
      [@aBaa.medi_BaaBaaInit]' lookup ToothYaaBariFina
      [@aYaaBari.fina]'      lookup ToothYaaBariFina;
} calt;

lookup AscenderYaaBari {
  sub @aBaa.init by @aBaa.init_YaaBari;
  sub @aFaa.init by @aFaa.init_YaaBari;
  sub @aLam.init by @aLam.init_YaaBari;
  sub @aKaf.init by @aKaf.init_YaaBari;
  sub @aYaaBari.fina by @aYaaBari.fina_PostAscender;
} AscenderYaaBari;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.init @aFaa.init @aLam.init @aKaf.init]' lookup AscenderYaaBari
      [@aYaaBari.fina]'                            lookup AscenderYaaBari;
} calt;

lookup AynYaaBari {
  sub @aHaa.init by @aHaa.init_YaaBari;
  sub @aHeh.init by @aHeh.init_YaaBari;
  sub uni06BE.init by uni06BE.init_YaaBari;
  sub @aAyn.init by @aAyn.init_YaaBari;
  sub @aTaa.init by @aTaa.init_YaaBari;
  sub @aMem.init_dots by @aMem.init_YaaBari;
  sub @aYaaBari.fina by @aYaaBari.fina_PostAyn;
} AynYaaBari;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aHaa.init @aHeh.init @aAyn.init @aTaa.init @aMem.init_dots uni06BE.init]' lookup AynYaaBari
       @aYaaBari.fina'                                                          lookup AynYaaBari;
} calt;

// default Faa.init+Mem.medi ligature is too narrow leading to mark clash of
// both glyphs have marks above or both have marks bellow at the same time. So
// we use an alternate wider Meem in such cases.
// This covers فَمَا فَّمَا فَمَّا فَّمَّا فِّمَا فِمِا.
lookup FaaMemTatweel {
  sub @aMem.medi by @aMem.medi_KafMemMediTatweel;
} FaaMemTatweel;

feature calt {
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.above'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.above' @Tashkil.above'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.above' @Tashkil.above'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above' @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.above'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above' @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.below' @Tashkil.above'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.above' @Tashkil.below'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.above';
  sub @aFaa.init' lookup KafMemInit
      @Tashkil.below'
      @aMem.medi' lookup FaaMemTatweel
      @Tashkil.below';
} calt;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aKaf.init @aKaf.medi @aAyn.init @aFaa.init @aHaa.init @aHeh.init]' lookup KafMemInit
      [@aMem.medi]' lookup KafMemInit;
} calt;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aLam.init]' lookup LamLamInit
      [@LamLamFoo @aLam.medi @aKaf.fina @aLam.fina @aLam.medi_LamAlfFina]' lookup LamLamInit;

  sub [@aLam.medi]' lookup LamLamMedi2
      [@LamLamFoo @aLam.medi @aKaf.fina @aLam.fina @aLam.medi_LamAlfFina]' lookup LamLamMedi;
} calt;

lookup HehMediTooth {
  sub @aHeh.medi by @aHeh.medi_PostTooth;
  sub @aSad.init by @aSad.init_PreYaa;
  sub @aSad.medi by @aSad.medi_PreYaa;
  sub @aSen.init by @aSen.init_PreYaa;
  sub @aSen.medi by @aSen.medi_PreYaa;
} HehMediTooth;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aSad.init @aSad.medi @aSen.init @aSen.medi]' lookup HehMediTooth
      [@aHeh.medi]' lookup HehMediTooth;
} calt;

// replace final alef followed by madda by a wider one
feature calt {
  sub @Tashkil.above [uni0627.fina]' [uni0653 uni06E4] by [uni0627.fina_Wide];
} calt;

// Wider alef wasl and alef with hamza above after faa
feature calt {
  lookupflag IgnoreMarks;
  sub @aFaa.init
     [uni0671.fina uni0623.fina]'
  by [uni0671.fina_Wide uni0623.fina_Wide];
} calt;

// If there are no marks, revert the above substitution
feature calt {
  sub @aFaa.init
     [uni0671.fina_Wide uni0623.fina_Wide]'
  by [uni0671.fina uni0623.fina];
} calt;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aAyn.init @aHaa.init @aHaa.medi]'
      [@aAlf.fina @aDal.fina @aHeh.fina @aLam.fina @aLam.medi @aLam.medi_LamMemFina
       @aLam.medi_LamWawFina @aLam.medi_LamHeh @aLam.medi_LamYaaFina @aKaf.fina
       @aLam.medi_LamQafFina @aBaa.medi_BaaRaaFina @aLam.medi_LamAlfFina
       @aLam.medi_LamMemMedi @aLam.medi_LamLamMedi @aBaa.medi_BaaNonFina @aBaa.medi_High
       @aKaf.medi @aKaf.medi_KafMemAlf @aKaf.medi_KafMemMedi @aKaf.medi_KafMemFina
       @aKaf.medi_KafLam @aKaf.medi_KafHeh @aKaf.medi_KafBaaMedi @aKaf.medi_KafRaaFina
       @aKaf.medi_KafYaaFina]
  by  [@aAyn.init_Finjani @aHaa.init_Finjani @aHaa.medi_Finjani];
} calt;

lookup BaaYaaFina {
  sub @aBaa.medi by @aBaa.medi_BaaYaaFina;
  sub @aYaa.fina by @aYaa.fina_BaaYaaFina;
} BaaYaaFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aBaa.medi]' lookup BaaYaaFina
      [@aYaa.fina]' lookup BaaYaaFina;
} calt;

lookup ToothMem {
  sub @aMem.fina by @aMem.fina_PostTooth;
  sub @aSad.init by @aSad.init_PreYaa;
  sub @aSad.medi by @aSad.medi_PreYaa;
  sub @aSen.init by @aSen.init_PreYaa;
  sub @aSen.medi by @aSen.medi_PreYaa;
} ToothMem;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aSen.init @aSen.medi @aSad.init @aSad.medi]' lookup ToothMem
      [@aMem.fina]' lookup ToothMem;
} calt;

lookup KafLamYaa {
  sub @aLam.medi_KafLam by @aLam.medi_KafLamYaa;
} KafLamYaa;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aLam.medi_KafLam]' lookup KafLamYaa
      [@aYaa.fina]' lookup LamYaaFina;
} calt;

lookup LamKafInit {
// XXX: sync with classes.fea

  // @aLam.init
  sub uni06B5.init by uni06B5.init uni0640.1;
  sub uni06B7.init by uni06B7.init uni0640.1;
  sub uni0644.init by uni0644.init uni0640.1;
  sub uni06B8.init by uni06B8.init uni0640.1;
  sub uni06B6.init by uni06B6.init uni0640.1;
  sub uni076A.init by uni076A.init uni0640.1;

  // @aLam.medi by
  sub uni06B5.medi by uni06B5.medi uni0640.1;
  sub uni06B7.medi by uni06B7.medi uni0640.1;
  sub uni0644.medi by uni0644.medi uni0640.1;
  sub uni06B8.medi by uni06B8.medi uni0640.1;
  sub uni06B6.medi by uni06B6.medi uni0640.1;
  sub uni076A.medi by uni076A.medi uni0640.1;

  // @aLam.medi_KafLam
  sub uni06B5.medi_KafLam by uni06B5.medi_KafLam uni0640.1;
  sub uni06B7.medi_KafLam by uni06B7.medi_KafLam uni0640.1;
  sub uni0644.medi_KafLam by uni0644.medi_KafLam uni0640.1;
  sub uni06B8.medi_KafLam by uni06B8.medi_KafLam uni0640.1;
  sub uni06B6.medi_KafLam by uni06B6.medi_KafLam uni0640.1;
  sub uni076A.medi_KafLam by uni076A.medi_KafLam uni0640.1;

  // @aLam.medi_KafMemLam
  sub uni06B5.medi_KafMemLam by uni06B5.medi_KafMemLam uni0640.1;
  sub uni06B7.medi_KafMemLam by uni06B7.medi_KafMemLam uni0640.1;
  sub uni0644.medi_KafMemLam by uni0644.medi_KafMemLam uni0640.1;
  sub uni06B8.medi_KafMemLam by uni06B8.medi_KafMemLam uni0640.1;
  sub uni06B6.medi_KafMemLam by uni06B6.medi_KafMemLam uni0640.1;
  sub uni076A.medi_KafMemLam by uni076A.medi_KafMemLam uni0640.1;

  // @aLam.medi_LamLamInit
  sub uni06B5.medi_LamLamInit by uni06B5.medi_LamLamInit uni0640.1;
  sub uni06B7.medi_LamLamInit by uni06B7.medi_LamLamInit uni0640.1;
  sub uni0644.medi_LamLamInit by uni0644.medi_LamLamInit uni0640.1;
  sub uni06B8.medi_LamLamInit by uni06B8.medi_LamLamInit uni0640.1;
  sub uni06B6.medi_LamLamInit by uni06B6.medi_LamLamInit uni0640.1;
  sub uni076A.medi_LamLamInit by uni076A.medi_LamLamInit uni0640.1;

  sub @aMem.medi_LamMemInit   by @aMem.medi_LamMemInitTatweel;
} LamKafInit;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aLam.init @aLam.medi @aLam.medi_KafLam @aLam.medi_KafMemLam
       @aLam.medi_LamLamInit @aMem.medi_LamMemInit]' lookup LamKafInit
      [@aKaf.medi @aKaf.medi_KafHeh @aKaf.medi_KafMemFina @aKaf.medi_KafRaaFina
       @aKaf.medi_KafYaaFina @aKaf.medi_KafMemAlf @aGaf.fina];
} calt;

lookup LamAynTatweel {
// XXX: sync with classes.fea

  // @aLam.init
  sub uni06B5.init by uni06B5.init uni0640.2;
  sub uni06B7.init by uni06B7.init uni0640.2;
  sub uni0644.init by uni0644.init uni0640.2;
  sub uni06B8.init by uni06B8.init uni0640.2;
  sub uni06B6.init by uni06B6.init uni0640.2;
  sub uni076A.init by uni076A.init uni0640.2;

  // @aLam.medi by
  sub uni06B5.medi by uni06B5.medi uni0640.2;
  sub uni06B7.medi by uni06B7.medi uni0640.2;
  sub uni0644.medi by uni0644.medi uni0640.2;
  sub uni06B8.medi by uni06B8.medi uni0640.2;
  sub uni06B6.medi by uni06B6.medi uni0640.2;
  sub uni076A.medi by uni076A.medi uni0640.2;

  // @aLam.medi_KafLam
  sub uni06B5.medi_KafLam by uni06B5.medi_KafLam uni0640.2;
  sub uni06B7.medi_KafLam by uni06B7.medi_KafLam uni0640.2;
  sub uni0644.medi_KafLam by uni0644.medi_KafLam uni0640.2;
  sub uni06B8.medi_KafLam by uni06B8.medi_KafLam uni0640.2;
  sub uni06B6.medi_KafLam by uni06B6.medi_KafLam uni0640.2;
  sub uni076A.medi_KafLam by uni076A.medi_KafLam uni0640.2;

  // @aLam.medi_KafMemLam
  sub uni06B5.medi_KafMemLam by uni06B5.medi_KafMemLam uni0640.2;
  sub uni06B7.medi_KafMemLam by uni06B7.medi_KafMemLam uni0640.2;
  sub uni0644.medi_KafMemLam by uni0644.medi_KafMemLam uni0640.2;
  sub uni06B8.medi_KafMemLam by uni06B8.medi_KafMemLam uni0640.2;
  sub uni06B6.medi_KafMemLam by uni06B6.medi_KafMemLam uni0640.2;
  sub uni076A.medi_KafMemLam by uni076A.medi_KafMemLam uni0640.2;

  // @aLam.medi_LamLamInit
  sub uni06B5.medi_LamLamInit by uni06B5.medi_LamLamInit uni0640.2;
  sub uni06B7.medi_LamLamInit by uni06B7.medi_LamLamInit uni0640.2;
  sub uni0644.medi_LamLamInit by uni0644.medi_LamLamInit uni0640.2;
  sub uni06B8.medi_LamLamInit by uni06B8.medi_LamLamInit uni0640.2;
  sub uni06B6.medi_LamLamInit by uni06B6.medi_LamLamInit uni0640.2;
  sub uni076A.medi_LamLamInit by uni076A.medi_LamLamInit uni0640.2;

  sub @aMem.medi_LamMemInit   by @aMem.medi_LamMemInitTatweel;
} LamAynTatweel;

// lam [shadda] kasra ayn.fina
feature calt {
  sub [@aLam.init @aLam.medi @aLam.medi_KafLam @aLam.medi_KafMemLam
       @aLam.medi_LamLamInit @aMem.medi_LamMemInit]' lookup LamAynTatweel
      [uni064D uni0650 uni065C]
       @aAyn.fina;
  sub [@aLam.init @aLam.medi @aLam.medi_KafLam @aLam.medi_KafMemLam
       @aLam.medi_LamLamInit @aMem.medi_LamMemInit]' lookup LamAynTatweel
      [uni0651]
      [uni064D uni0650 uni065C]
       @aAyn.fina;
} calt;

#ifdef QURAN
// alef lam meem raa (with madda)
// we don't get plain aLam.init aMem.fina except in Quran font
feature calt {
  sub @aLam.init' lookup LamKafInit [uni0653 uni06E4]
      @aMem.medi [uni0653 uni06E4];
} calt;
#endif

lookup HehYaaFina {
  sub @aHeh.medi_BaaHehMedi by @aHeh.medi_HehYaaFina;
  sub @aHeh.medi_PostTooth by @aHeh.medi_PostToothHehYaa;
} HehYaaFina;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aHeh.medi_PostTooth @aHeh.medi_BaaHehMedi]' lookup HehYaaFina
      [@aYaa.fina]'                                 lookup BaaYaaFina;
} calt;

feature calt {
  lookupflag IgnoreMarks;
  sub @RaaWaw [uni0625 uni0673]' by @aAlf.isol_LowHamza;
} calt;


// insert tatweel between ح and ك in فحك[ملير]
lookup FaaHaaKaf {
// XXX: sync with classes.fea
// sub @aHaa.medi_FaaHaaInit   by @aHaa.medi_FaaHaaInit   uni0640.1;
  sub uni062E.medi_FaaHaaInit by uni062E.medi_FaaHaaInit uni0640.1;
  sub uni062D.medi_FaaHaaInit by uni062D.medi_FaaHaaInit uni0640.1;
  sub uni0681.medi_FaaHaaInit by uni0681.medi_FaaHaaInit uni0640.1;
  sub uni0687.medi_FaaHaaInit by uni0687.medi_FaaHaaInit uni0640.1;
  sub uni0685.medi_FaaHaaInit by uni0685.medi_FaaHaaInit uni0640.1;
  sub uni062C.medi_FaaHaaInit by uni062C.medi_FaaHaaInit uni0640.1;
  sub uni0682.medi_FaaHaaInit by uni0682.medi_FaaHaaInit uni0640.1;
  sub uni0757.medi_FaaHaaInit by uni0757.medi_FaaHaaInit uni0640.1;
  sub uni0684.medi_FaaHaaInit by uni0684.medi_FaaHaaInit uni0640.1;
  sub uni076F.medi_FaaHaaInit by uni076F.medi_FaaHaaInit uni0640.1;
  sub uni076E.medi_FaaHaaInit by uni076E.medi_FaaHaaInit uni0640.1;
  sub uni0683.medi_FaaHaaInit by uni0683.medi_FaaHaaInit uni0640.1;
  sub uni06BF.medi_FaaHaaInit by uni06BF.medi_FaaHaaInit uni0640.1;
  sub uni077C.medi_FaaHaaInit by uni077C.medi_FaaHaaInit uni0640.1;
  sub uni0758.medi_FaaHaaInit by uni0758.medi_FaaHaaInit uni0640.1;
  sub uni0772.medi_FaaHaaInit by uni0772.medi_FaaHaaInit uni0640.1;
  sub uni0686.medi_FaaHaaInit by uni0686.medi_FaaHaaInit uni0640.1;
} FaaHaaKaf;

feature calt {
  lookupflag IgnoreMarks;
  sub @aFaa.init_FaaHaaInit
      @aHaa.medi_FaaHaaInit' lookup FaaHaaKaf
     [@aKaf.medi_KafHeh @aKaf.medi_KafMemFina @aKaf.medi_KafRaaFina @aKaf.medi_KafYaaFina];
} calt;

// insert tatweel between ح and ت in [بمسصف]حت[رن]
lookup AboveHaaTatweel {
// XXX: sync with classes.fea
//sub @aHaa.medi_FaaHaaInit   by @aHaa.medi_FaaHaaInit   uni0640.05;
  sub uni062E.medi_FaaHaaInit by uni062E.medi_FaaHaaInit uni0640.05;
  sub uni062D.medi_FaaHaaInit by uni062D.medi_FaaHaaInit uni0640.05;
  sub uni0681.medi_FaaHaaInit by uni0681.medi_FaaHaaInit uni0640.05;
  sub uni0687.medi_FaaHaaInit by uni0687.medi_FaaHaaInit uni0640.05;
  sub uni0685.medi_FaaHaaInit by uni0685.medi_FaaHaaInit uni0640.05;
  sub uni062C.medi_FaaHaaInit by uni062C.medi_FaaHaaInit uni0640.05;
  sub uni0682.medi_FaaHaaInit by uni0682.medi_FaaHaaInit uni0640.05;
  sub uni0757.medi_FaaHaaInit by uni0757.medi_FaaHaaInit uni0640.05;
  sub uni0684.medi_FaaHaaInit by uni0684.medi_FaaHaaInit uni0640.05;
  sub uni076F.medi_FaaHaaInit by uni076F.medi_FaaHaaInit uni0640.05;
  sub uni076E.medi_FaaHaaInit by uni076E.medi_FaaHaaInit uni0640.05;
  sub uni0683.medi_FaaHaaInit by uni0683.medi_FaaHaaInit uni0640.05;
  sub uni06BF.medi_FaaHaaInit by uni06BF.medi_FaaHaaInit uni0640.05;
  sub uni077C.medi_FaaHaaInit by uni077C.medi_FaaHaaInit uni0640.05;
  sub uni0758.medi_FaaHaaInit by uni0758.medi_FaaHaaInit uni0640.05;
  sub uni0772.medi_FaaHaaInit by uni0772.medi_FaaHaaInit uni0640.05;
  sub uni0686.medi_FaaHaaInit by uni0686.medi_FaaHaaInit uni0640.05;

//sub @aHaa.medi_SadHaaInit   by @aHaa.medi_SadHaaInit   uni0640.05;
  sub uni062E.medi_SadHaaInit by uni062E.medi_SadHaaInit uni0640.05;
  sub uni062D.medi_SadHaaInit by uni062D.medi_SadHaaInit uni0640.05;
  sub uni0681.medi_SadHaaInit by uni0681.medi_SadHaaInit uni0640.05;
  sub uni0687.medi_SadHaaInit by uni0687.medi_SadHaaInit uni0640.05;
  sub uni0685.medi_SadHaaInit by uni0685.medi_SadHaaInit uni0640.05;
  sub uni062C.medi_SadHaaInit by uni062C.medi_SadHaaInit uni0640.05;
  sub uni0682.medi_SadHaaInit by uni0682.medi_SadHaaInit uni0640.05;
  sub uni0757.medi_SadHaaInit by uni0757.medi_SadHaaInit uni0640.05;
  sub uni0684.medi_SadHaaInit by uni0684.medi_SadHaaInit uni0640.05;
  sub uni076F.medi_SadHaaInit by uni076F.medi_SadHaaInit uni0640.05;
  sub uni076E.medi_SadHaaInit by uni076E.medi_SadHaaInit uni0640.05;
  sub uni0683.medi_SadHaaInit by uni0683.medi_SadHaaInit uni0640.05;
  sub uni06BF.medi_SadHaaInit by uni06BF.medi_SadHaaInit uni0640.05;
  sub uni077C.medi_SadHaaInit by uni077C.medi_SadHaaInit uni0640.05;
  sub uni0758.medi_SadHaaInit by uni0758.medi_SadHaaInit uni0640.05;
  sub uni0772.medi_SadHaaInit by uni0772.medi_SadHaaInit uni0640.05;
  sub uni0686.medi_SadHaaInit by uni0686.medi_SadHaaInit uni0640.05;
} AboveHaaTatweel;

feature calt {
  lookupflag IgnoreMarks;
  sub [@aHaa.medi_FaaHaaInit @aHaa.medi_SadHaaInit]' lookup AboveHaaTatweel
      [@aBaa.medi_BaaNonFina @aBaa.medi_BaaRaaFina];
} calt;


// When an initial Baa is followed by Alef, the dot clashes with the Hamza below
// Alef, Also the marks above the Baa clash with the Alef, so we replace the Baa
// with a wider variant.
feature calt {
  lookupflag IgnoreMarks;
  sub @aBaa.init' lookup BaaInitWide @aAlf.fina;
} calt;

// If the Alef has no Hamza below, or there is no marks above the Baa, revert to
// the original, non-wide form (notice there is no IgnoreMarks flag).
feature calt {
  sub [@aBaa.init_Wide]'
      [uni0622.fina uni0623.fina uni0627.fina uni0671.fina uni0672.fina
       uni0675.fina uni0773.fina uni0774.fina]
   by [@aBaa.init];
} calt;

// Replace teh init following teh/them medi by a teh init with two vertical
// dots
// XXX: use a different glyph for PDF text extraction
feature calt {
  lookupflag IgnoreMarks;
  script arab;
  language ARA;
  sub uni062A.init_BaaBaaIsol'
      [uni062A.medi_BaaBaaInit uni062B.medi_BaaBaaInit]
   by uni067A.init_BaaBaaIsol;

  sub uni062A.init_High'
      [uni062A.medi_High uni062B.medi_High]
   by uni067A.init_High;
} calt;