summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/fontspec/fontspec-doc-opentype.tex
blob: a21d7f80cf32bce388f2a6a700eb96853f30aa3f (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
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
%%^^A%%  fontspec-doc-opentype.tex -- part of FONTSPEC <wspr.io/fontspec>


\documentclass[a4paper]{l3doc}
\usepackage{fontspec-doc-style}
\showexamplesfalse
\begin{document}

\part{OpenType}
\label{sec:opentype-features}

\section{Introduction}
\label{sec:opentype-features-intro}

OpenType fonts (and other `smart' font technologies such as AAT and Graphite) can change the appearance of text in many different ways.
These changes are referred to as font features.
When the user applies a feature~--- for example, small capitals~--- to a run of text, the code inside the font makes appropriate substitutions and small capitals appear in place of lowercase letters.
However, the use of such features does not affect the underlying text.
In our small caps example, the lowercase letters are still stored in the document; only the appearance has been changed by the OpenType feature.
This makes it possible to search and copy text without difficulty.
If the user selected a different font that does not support small caps, the `plain' lowercase letters would appear instead.

Some OpenType features are required to support particular scripts, and these features are often applied automatically.
The Indic scripts, for example, often require that characters be reshaped and reordered after they are typed by the user, in order to display them in the traditional ways that readers expect.
Other features can be applied to support a particular language.
The Junicode font for medievalists uses by default the Old English shape of the letter thorn, while in modern Icelandic thorn has a more rounded shape.
If a user tags some text as being in Icelandic, Junicode will automatically change to the Icelandic shape through an OpenType feature that localises the shapes of letters.

There are a large group of OpenType features, designed to support high quality typography a multitude of languages and writing scripts.
Examples of some font features have already been shown in previous sections; the complete set of OpenType font features supported by \pkg{fontspec} is described below in \ref{sec:ot-feat}.

The OpenType specification provides four-letter codes (e.g., \texttt{smcp} for small capitals) for each feature.  The four-letter codes are given below along with the \pkg{fontspec} names for various features, for the benefit of people who are already familiar with OpenType.  You can ignore the codes if they don't mean anything to you.


\subsection{How to select font features}

Font features are selected by a series of \meta{feature}=\meta{option}
selections. Features are (usually) grouped logically; for example, all
font features relating to ligatures are accessed by writing \verb|Ligatures={...}| with the appropriate argument(s), which could be \texttt{TeX}, \texttt{Rare}, etc., as shown below in \ref{sec:ot-feat-liga}.

Multiple options may be given to
any feature that accepts non-numerical input, although doing so will
not always work. Some options will override others in generally
obvious ways; \Verb|Numbers={OldStyle,Lining}| doesn't make much
sense because the two options are mutually exclusive, and \XeTeX\
will simply use the last option that is specified (in this case
using \opt{Lining} over \opt{OldStyle}).

If a feature or an option is requested that the font does not have,
a warning is given in the console output. As mentioned in \vref{sec:quiet-warnings}
these warnings can be suppressed by selecting the \texttt{[quiet]} package option.

\subsection{How do I know what font features are supported by my fonts?}

Although I've long desired to have a feature within \pkg{fontspec} to display the OpenType features within a font, it's never been high on my priority list.
One reason for that is the existence of the document |opentype-info.tex|, which is available on \textsc{ctan} or typing |kpsewhich opentype-info.tex| in a Terminal window.
Make a copy of this file and place it somewhere convenient.
Then open it in your regular \TeX\ editor and change the font name to the font you'd like to query; after running through plain \XeTeX, the output \textsc{pdf} will look something like this:

\begin{framed}

%%% From OpenType-info.tex %%%
\DeleteShortVerb\"
\def\myfontname{[Asana-Math.otf]}
\font\testfont="\myfontname/OT" at 10pt\relax

\rightskip=0pt plus 1fil

\font\titlefont=ec-lmssbx10 at 12pt
\font\tenrm=ec-lmss10 at 9pt \tenrm
\font\tentt=ec-lmtt10 at 9pt

\def\fourcharcode#1{\begingroup
 \count0=#1\count1=\count0
 \ifnum\count0=0
  $\langle$default$\rangle$%
 \else
  \tentt
  '%
  \divide\count0 by "1000000
  \char\count0
  \multiply\count0 by "1000000
  \advance\count1 by -\count0
  \count0=\count1
  \divide\count0 by "10000
  \char\count0
  \multiply\count0 by "10000
  \advance\count1 by -\count0
  \count0=\count1
  \divide\count0 by "100
  \char\count0
  \multiply\count0 by "100
  \advance\count1 by -\count0
  \ifnum\count1=32 \ \else \char\count1 \fi
  '%
 \fi
 \endgroup
}

\newcount\scriptcount
\newcount\scriptindex
\newcount\scripttag
\newcount\langcount
\newcount\langindex
\newcount\langtag
\newcount\featurecount
\newcount\featureindex
\newcount\featuretag

\leftline{\titlefont OpenType Layout features found in `\myfontname'}
\nobreak

\scriptcount=\XeTeXOTcountscripts\testfont
\ifnum\scriptcount=0 \noindent None\par\fi

\loop
 \ifnum\scriptindex<\scriptcount
  \smallskip
  \scripttag=\XeTeXOTscripttag\testfont\scriptindex
  \noindent script = \fourcharcode{\scripttag}\endgraf\nobreak
  \langcount=\XeTeXOTcountlanguages\testfont\scripttag
  \advance\langcount by 1 % one extra to get the default language system
  {\loop
    \langtag=\XeTeXOTlanguagetag\testfont\scripttag\langindex
    \indent language = \fourcharcode{\langtag}\endgraf\nobreak
    \featurecount=\XeTeXOTcountfeatures\testfont\scripttag\langtag
    {\indent\indent \hangindent=3\parindent \hangafter=1 features = \loop
      \featuretag=\XeTeXOTfeaturetag\testfont\scripttag\langtag\featureindex
      \fourcharcode{\featuretag}
      \advance\featureindex by 1
      \ifnum\featureindex<\featurecount \repeat\endgraf}
    \advance\langindex by 1
  \ifnum\langindex<\langcount \medskip \repeat}
  \advance\scriptindex by 1
\repeat
\end{framed}

\noindent I intentionally picked a font above that by design contains few font features; `regular' text fonts such as Latin Modern Roman contain many more, and I didn't want to clutter up the document too much.
After finding the scripts, languages, and features contained within the font, you'll then need to cross-check the OpenType tags with the `logical' names used by \pkg{fontspec}.

\paragraph{otfinfo}
Alternatively, and more simply, you can use the command line tool |otfinfo|, which is distributed with \TeX{}Live.
Simply type in a Terminal window, say:
\begin{Verbatim}
  otfinfo -f `kpsewhich lmromandunh10-oblique.otf`
\end{Verbatim}
which results in:
\begin{Verbatim}[frame=single]
aalt	Access All Alternates
cpsp	Capital Spacing
dlig	Discretionary Ligatures
frac	Fractions
kern	Kerning
liga	Standard Ligatures
lnum	Lining Figures
onum	Oldstyle Figures
pnum	Proportional Figures
size	Optical Size
tnum	Tabular Figures
zero	Slashed Zero
\end{Verbatim}


\section{OpenType scripts and languages}\label{sec:ot}

Fonts that include glyphs for various scripts and languages may contain different font features for the different character sets and languages they support, and different font features may behave differently depending on the script or language chosen.
When multilingual fonts are used, it is important to select which language
they are being used for, and more importantly what script is being used.

The `script' refers to the alphabet in use; for example, both English
and French use the Latin script. Similarly, the Arabic script can be used
to write in both the Arabic and Persian languages.

The
\feat{Script} and \feat{Language} features are used to designate this information. The possible options are
tabulated in \vref{tab:ot-scpt} and \vref{tab:ot-lang},
respectively. When a script or language is requested that is not
supported by the current font, a warning is printed in the console output.
See \vref{sec:newscriptlang} for methods to create new \feat{Script} or \feat{Language}
options if required.

Because these font features can
change which features are able to be selected for the font, the \feat{Script} and \feat{Language}
settings are automatically selected
by \pkg{fontspec} before all others, and, if \XeTeX\ is being used, will
specifically select the \opt{OpenType}
renderer for this font, as described in \vref{sec:renderer-xetex}.

OpenType fonts can make available different font features depending on the Script and
Language chosen.
In addition, these settings can also set up their own font behaviour
and glyph selection (one example is differences in style between some of the letters in the
alphabet used for Bulgarian, Serbian, and Russian).
The \pkg{fontspec} feature \feat{LocalForms} \texttt{=} \opt{Off} will disable some of
these substitutions if desired for some reason.
It is important to note that \feat{LocalForms} \texttt{=} \opt{On} is a default not of \pkg{fontspec}
but of the underlying font shaping engines in both \XeTeX\ and \LuaTeX/\pkg{otfload}.


\subsection{\feat{Script} and \feat{Language} examples}

In the examples shown in \exref{script-lang},
the Code2000 font\note{\url{http://www.code2000.net/}}
is used to typeset various input texts with and without the OpenType Script
applied for various alphabets.
The text is only rendered correctly in the second case;
many examples of incorrect diacritic spacing as
well as a lack of contextual ligatures and rearrangement can be
seen.
Thanks to \name{Jonathan Kew}, \name{Yves Codet} and
\name{Gildas Hamel} for their contributions towards these examples.

\begin{Xexample}[firstline=14,lastline=23]{script-lang}{An example of various Scripts and Languages.}
\def\testfeature#1#2{%^^A
  \fontspec{\examplefont}#2 & \fontspec[#1]{\examplefont}#2\\[1ex]}
\def \examplefont{CODE2000.TTF}
\def \arabictext{العربي}
\def \devanagaritext{हिन्दी}
\def \bengalitext{লেখ}
\def \gujaratitext{મર્યાદા-સૂચક નિવેદન}
\def \malayalamtext{നമ്മുടെ പാരബര്യ}
\def \gurmukhitext{ਆਦਿ ਸਚੁ ਜੁਗਾਦਿ ਸਚੁ}
\def \tamiltext{தமிழ் தேடி}
\def \hebrewtext{רִדְתָּֽהּ}
\def \vietnamesetext{cấp số mỗi}
\begin{tabular}{r@{\quad}l}
  \testfeature{Script=Arabic}{\arabictext}
  \testfeature{Script=Devanagari}{\devanagaritext}
  \testfeature{Script=Bengali}{\bengalitext}
  \testfeature{Script=Gujarati}{\gujaratitext}
  \testfeature{Script=Malayalam}{\malayalamtext}
  \testfeature{Script=Gurmukhi}{\gurmukhitext}
  \testfeature{Script=Tamil}{\tamiltext}
  \testfeature{Script=Hebrew}{\hebrewtext}
  \def\examplefont{DoulosSILR.ttf}
  \testfeature{Language=Vietnamese}{\vietnamesetext}
\end{tabular}
\end{Xexample}



\begin{table}[!hbp]
  \caption{Defined \opt{Script}s for OpenType fonts. Aliased names are shown in adjacent positions marked with red pilcrows ({\sffamily\textcolor{red}{\P}}).}
  \label{tab:ot-scpt}
\def\dup{\makebox[0pt][r]{\textcolor{red}{\P}}}
\setlength\columnseprule{0pt}
  \hrule
  \begin{multicols}{4}\setlength\parindent{0pt}
    \sffamily\scriptsize
    Adlam \par
    Ahom \par
    Anatolian Hieroglyphs \par
    Arabic \par
    Armenian \par
    Avestan \par
    Balinese \par
    Bamum \par
    Bassa Vah \par
    Batak \par
    Bengali \par
    Bhaiksuki \par
    Bopomofo \par
    Brahmi \par
    Braille \par
    Buginese \par
    Buhid \par
    Byzantine Music \par
    Canadian Syllabics \par
    Carian \par
    Caucasian Albanian \par
    Chakma \par
    Cham \par
    Cherokee \par
    \dup CJK \par
    \dup CJK Ideographic \par
    Coptic \par
    Cypriot Syllabary \par
    Cyrillic \par
    Default \par
    Deseret \par
    Devanagari \par
    Duployan \par
    Egyptian Hieroglyphs \par
    Elbasan \par
    Ethiopic \par
    Georgian \par
    Glagolitic \par
    Gothic \par
    Grantha \par
    Greek \par
    Gujarati \par
    Gurmukhi \par
    Hangul Jamo \par
    Hangul \par
    Hanunoo \par
    Hatran \par
    Hebrew \par
    \dup Hiragana and Katakana \par
    \dup Kana \par
    Imperial Aramaic \par
    Inscriptional Pahlavi \par
    Inscriptional Parthian \par
    Javanese \par
    Kaithi \par
    Kannada \par
    Kayah Li \par
    Kharosthi \par
    Khmer \par
    Khojki \par
    Khudawadi \par
    Lao \par
    Latin \par
    Lepcha \par
    Limbu \par
    Linear A \par
    Linear B \par
    Lisu \par
    Lycian \par
    Lydian \par
    Mahajani \par
    Malayalam \par
    Mandaic \par
    Manichaean \par
    Marchen \par
    \dup Math \par
    \dup Maths \par
    Meitei Mayek \par
    Mende Kikakui \par
    Meroitic Cursive \par
    Meroitic Hieroglyphs \par
    Miao \par
    Modi \par
    Mongolian \par
    Mro \par
    Multani \par
    Musical Symbols \par
    Myanmar \par
    \dup N'Ko \par
    \dup N'ko \par
    Nabataean \par
    Newa \par
    Ogham \par
    Ol Chiki \par
    Old Italic \par
    Old Hungarian \par
    Old North Arabian \par
    Old Permic \par
    Old Persian Cuneiform \par
    Old South Arabian \par
    Old Turkic \par
    \dup Oriya \par
    \dup Odia \par
    Osage \par
    Osmanya \par
    Pahawh Hmong \par
    Palmyrene \par
    Pau Cin Hau \par
    Phags-pa \par
    Phoenician \par
    Psalter Pahlavi \par
    Rejang \par
    Runic \par
    Samaritan \par
    Saurashtra \par
    Sharada \par
    Shavian \par
    Siddham \par
    Sign Writing \par
    Sinhala \par
    Sora Sompeng \par
    Sumero-Akkadian Cuneiform \par
    Sundanese \par
    Syloti Nagri \par
    Syriac \par
    Tagalog \par
    Tagbanwa \par
    Tai Le \par
    Tai Lu \par
    Tai Tham \par
    Tai Viet \par
    Takri \par
    Tamil \par
    Tangut \par
    Telugu \par
    Thaana \par
    Thai \par
    Tibetan \par
    Tifinagh \par
    Tirhuta \par
    Ugaritic Cuneiform \par
    Vai \par
    Warang Citi \par
    Yi
  \end{multicols}
  \hrule
\end{table}

\begin{table}[p]
  \vspace*{-3cm}
  \hspace{-3cm}
  \def\dup{\makebox[0pt][r]{\textcolor{red}{\P}}}
  \begin{minipage}{\linewidth+4cm}
  \caption{Defined \opt{Language}s for OpenType fonts. Aliased names are shown in adjacent positions marked with red pilcrows ({\sffamily\textcolor{red}{\P}}).}
  \label{tab:ot-lang}
  \setlength\columnseprule{0pt}
  \hrule
  \begin{multicols}{6}
    \everypar{\setlength\parindent{0pt}\setlength\hangindent{2em}}
    \sffamily\footnotesize\raggedright
    Abaza \par
    Abkhazian \par
    Adyghe \par
    Afrikaans \par
    Afar \par
    Agaw \par
    Altai \par
    Amharic \par
    Arabic \par
    Aari \par
    Arakanese \par
    Assamese \par
    Athapaskan \par
    Avar \par
    Awadhi \par
    Aymara \par
    Azeri \par
    Badaga \par
    Baghelkhandi \par
    Balkar \par
    Baule \par
    Berber \par
    Bench \par
    Bible Cree \par
    Belarussian \par
    Bemba \par
    Bengali \par
    Bulgarian \par
    Bhili \par
    Bhojpuri \par
    Bikol \par
    Bilen \par
    Blackfoot \par
    Balochi \par
    Balante \par
    Balti \par
    Bambara \par
    Bamileke \par
    Breton \par
    Brahui \par
    Braj Bhasha \par
    Burmese \par
    Bashkir \par
    Beti \par
    Catalan \par
    Cebuano \par
    Chechen \par
    Chaha Gurage \par
    Chattisgarhi \par
    Chichewa \par
    Chukchi \par
    Chipewyan \par
    Cherokee \par
    Chuvash \par
    Comorian \par
    Coptic \par
    Cree \par
    Carrier \par
    Crimean Tatar \par
    Church Slavonic \par
    Czech \par
    Danish \par
    Dargwa \par
    Woods Cree \par
    German \par
    Default \par
    Dogri \par
    Divehi \par
    Djerma \par
    Dangme \par
    Dinka \par
    Dungan \par
    Dzongkha \par
    Ebira \par
    Eastern Cree \par
    Edo \par
    Efik \par
    Greek \par
    English \par
    Erzya \par
    Spanish \par
    Estonian \par
    Basque \par
    Evenki \par
    Even \par
    Ewe \par
    French Antillean \par
    \dup Farsi \par
    \dup Parsi \par
    \dup Persian \par
    Finnish \par
    Fijian \par
    Flemish \par
    Forest Nenets \par
    Fon \par
    Faroese \par
    French \par
    Frisian \par
    Friulian \par
    Futa \par
    Fulani \par
    Ga \par
    Gaelic \par
    Gagauz \par
    Galician \par
    Garshuni \par
    Garhwali \par
    Ge'ez \par
    Gilyak \par
    Gumuz \par
    Gondi \par
    Greenlandic \par
    Garo \par
    Guarani \par
    Gujarati \par
    Haitian \par
    Halam \par
    Harauti \par
    Hausa \par
    Hawaiin \par
    Hammer-Banna \par
    Hiligaynon \par
    Hindi \par
    High Mari \par
    Hindko \par
    Ho \par
    Harari \par
    Croatian \par
    Hungarian \par
    Armenian \par
    Igbo \par
    Ijo \par
    Ilokano \par
    Indonesian \par
    Ingush \par
    Inuktitut \par
    Irish \par
    Irish Traditional \par
    Icelandic \par
    Inari Sami \par
    Italian \par
    Hebrew \par
    Javanese \par
    Yiddish \par
    Japanese \par
    Judezmo \par
    Jula \par
    Kabardian \par
    Kachchi \par
    Kalenjin \par
    Kannada \par
    Karachay \par
    Georgian \par
    Kazakh \par
    Kebena \par
    Khutsuri Georgian \par
    Khakass \par
    Khanty-Kazim \par
    Khmer \par
    Khanty-Shurishkar \par
    Khanty-Vakhi \par
    Khowar \par
    Kikuyu \par
    Kirghiz \par
    Kisii \par
    Kokni \par
    Kalmyk \par
    Kamba \par
    Kumaoni \par
    Komo \par
    Komso \par
    Kanuri \par
    Kodagu \par
    Korean Old Hangul \par
    Konkani \par
    Kikongo \par
    Komi-Permyak \par
    Korean \par
    Komi-Zyrian \par
    Kpelle \par
    Krio \par
    Karakalpak \par
    Karelian \par
    Karaim \par
    Karen \par
    Koorete \par
    Kashmiri \par
    Khasi \par
    Kildin Sami \par
    Kui \par
    Kulvi \par
    Kumyk \par
    Kurdish \par
    Kurukh \par
    Kuy \par
    Koryak \par
    Ladin \par
    Lahuli \par
    Lak \par
    Lambani \par
    Lao \par
    Latin \par
    Laz \par
    L-Cree \par
    Ladakhi \par
    Lezgi \par
    Lingala \par
    Low Mari \par
    Limbu \par
    Lomwe \par
    Lower Sorbian \par
    Lule Sami \par
    Lithuanian \par
    Luba \par
    Luganda \par
    Luhya \par
    Luo \par
    Latvian \par
    Majang \par
    Makua \par
    Malayalam Traditional \par
    Mansi \par
    Marathi \par
    Marwari \par
    Mbundu \par
    Manchu \par
    Moose Cree \par
    Mende \par
    Me'en \par
    Mizo \par
    Macedonian \par
    Male \par
    Malagasy \par
    Malinke \par
    Malayalam Reformed \par
    Malay \par
    Mandinka \par
    Mongolian \par
    Manipuri \par
    Maninka \par
    Manx Gaelic \par
    Moksha \par
    Moldavian \par
    Mon \par
    Moroccan \par
    Maori \par
    Maithili \par
    Maltese \par
    Mundari \par
    Naga-Assamese \par
    Nanai \par
    Naskapi \par
    N-Cree \par
    Ndebele \par
    Ndonga \par
    Nepali \par
    Newari \par
    Nagari \par
    Norway House Cree \par
    Nisi \par
    Niuean \par
    Nkole \par
    N'ko \par
    Dutch \par
    Nogai \par
    Norwegian \par
    Northern Sami \par
    Northern Tai \par
    Esperanto \par
    Nynorsk \par
    Oji-Cree \par
    Ojibway \par
    Oriya \par
    Oromo \par
    Ossetian \par
    Palestinian Aramaic \par
    Pali \par
    Punjabi \par
    Palpa \par
    Pashto \par
    Polytonic Greek \par
    Pilipino \par
    Palaung \par
    Polish \par
    Provencal \par
    Portuguese \par
    Chin \par
    Rajasthani \par
    R-Cree \par
    Russian Buriat \par
    Riang \par
    Rhaeto-Romanic \par
    Romanian \par
    Romany \par
    Rusyn \par
    Ruanda \par
    Russian \par
    Sadri \par
    Sanskrit \par
    Santali \par
    Sayisi \par
    Sekota \par
    Selkup \par
    Sango \par
    Shan \par
    Sibe \par
    Sidamo \par
    Silte Gurage \par
    Skolt Sami \par
    Slovak \par
    Slavey \par
    Slovenian \par
    Somali \par
    Samoan \par
    Sena \par
    Sindhi \par
    Sinhalese \par
    Soninke \par
    Sodo Gurage \par
    Sotho \par
    Albanian \par
    Serbian \par
    Saraiki \par
    Serer \par
    South Slavey \par
    Southern Sami \par
    Suri \par
    Svan \par
    Swedish \par
    Swadaya Aramaic \par
    Swahili \par
    Swazi \par
    Sutu \par
    Syriac \par
    Tabasaran \par
    Tajiki \par
    Tamil \par
    Tatar \par
    TH-Cree \par
    Telugu \par
    Tongan \par
    Tigre \par
    Tigrinya \par
    Thai \par
    Tahitian \par
    Tibetan \par
    Turkmen \par
    Temne \par
    Tswana \par
    Tundra Nenets \par
    Tonga \par
    Todo \par
    Turkish \par
    Tsonga \par
    Turoyo Aramaic \par
    Tulu \par
    Tuvin \par
    Twi \par
    Udmurt \par
    Ukrainian \par
    Urdu \par
    Upper Sorbian \par
    Uyghur \par
    Uzbek \par
    Venda \par
    Vietnamese \par
    Wa \par
    Wagdi \par
    West-Cree \par
    Welsh \par
    Wolof \par
    Tai Lue \par
    Xhosa \par
    Yakut \par
    Yoruba \par
    Y-Cree \par
    Yi Classic \par
    Yi Modern \par
    Chinese Hong Kong \par
    Chinese Phonetic \par
    Chinese Simplified \par
    Chinese Traditional \par
    Zande \par
    Zulu
  \end{multicols}
  \hspace{4pt}
  \hrule
 \end{minipage}
\end{table}


\section{OpenType font features}
\label{sec:ot-feat}

There are a finite set of OpenType font features, and \pkg{fontspec} provides an
interface to around half of them.
Full documentation will be presented in the following sections, including how to
enable and disable individual features, and how they interact.

A brief reference is provided (\vref{tab:all-ot}) but note that this is an incomplete
listing --- only the `enable' keys are shown, and where alternative interfaces are
provided for convenience only the first is shown.
(E.g., |Numbers=OldStyle| is the same as |Numbers=Lowercase|.)

For completeness, the complete list of OpenType features \emph{not} provided with
a \pkg{fontspec} interface is shown in \vref{tab:none-ot}.
Features omitted are partially by design and partially by oversight;
for example, the |aalt| feature is largely useless in \TeX\ since it is designed
for providing a textsc{gui} interface for selecting `all alternates' of a glyph.
Others, such as optical bounds for example, simply haven't yet been considered
due to a lack of fonts available for testing.
Suggestions welcome for how/where to add these missing features to the package.

\ExplSyntaxOn
\def\allOTfeat{
  \prop_map_inline:Nn \g__fontspec_all_opentype_feature_names_prop
    { \opentypefeature{##1}{##2} }
}
\newcommand\opentypefeature[2]{
  \prop_get:NnNT \g__fontspec_OT_features_prop {#1} \tmpa
      {
        \raggedright
        \hangindent=5.2cm
        \makebox[1cm][l]{\textsc{#1}}
        \makebox[4.2cm][l]{
          \int_compare:nT { \tl_count:N \tmpa > 25 } {\ttcondensed} {\ttfamily}
          \tmpa
        }
        \textit{#2}
        \par
        \vspace{2pt}
     }
}
\ExplSyntaxOff

\begin{table}
\caption{Summary of OpenType features in \textsf{fontspec}, alphabetic by feature tag.}
\label{tab:all-ot}
\centerline{%
\begin{minipage}{18cm}
\small
\hrule\smallskip
\begin{multicols}{2}
\parindent =0pt
\allOTfeat
\end{multicols}
\vspace*{-\smallskipamount}
\hrule
\end{minipage}}
\end{table}

\ExplSyntaxOn
\renewcommand\opentypefeature[2]{
  \prop_get:NnNF \g__fontspec_OT_features_prop {#1} \tmpa
      {
        \raggedright
        \hangindent=0.9cm
        \makebox[0.9cm][l]{\textsc{#1}}%
        \textit{#2}
        \par
     }
}
\ExplSyntaxOff

\begin{table}
\caption{List of \emph{unsupported} OpenType features.}
\label{tab:none-ot}
\bigskip
\centerline{%
\begin{minipage}{15cm}
\hrule\smallskip
\begin{multicols}{3}
\parindent =0pt
\allOTfeat
\end{multicols}
\vspace*{-\smallskipamount}
\hrule
\end{minipage}}
\end{table}

\subsection{Tag-based features}


\subsubsection{Alternates --- \texttt{salt}}

The \feat{Alternate} feature, alias \feat{StylisticAlternates}, is used to access alternate font glyphs when variations exist in the font, such as in \exref{salt}.
It uses a numerical selection, starting from zero, that will be different for each font.
Note that the \texttt{Style=Alternate} option is equivalent
to \texttt{Alternate=0} to access the default case.

\begin{Xexample}[firstline=2]{salt}{The \feat{Alternate} feature.}
  \huge
  \fontspec{LinLibertine_R.otf}
  \textsc{a} \& h \\
  \addfontfeature{Alternate=0}
  \textsc{a} \& h
\end{Xexample}

Note that the indexing starts from zero.
With the \LuaTeX\ engine, |Alternate=Random| selects a random alternate.

See \vref{sec:newfeatures} for a way to assign names to alternates if desired.


\subsubsection{Character Variants --- \texttt{cvNN}}

`Character Variations' are selected
numerically to adjust the output of (usually) a single character for the
particular font. These correspond to the OpenType features |cv01| to |cv99|.

For each character that can be varied, it is possible to select among
possible options for that particular glyph.
For example, in the example below, variants are chosen for glyphs `4' and `5',
and the trailing |:|\meta{n} corresponds to which variety to choose.
\begin{Verbatim}
  \fontspec{EB Garamond 12 Italic}[CharacterVariant={4,5:2}] \& violet
\end{Verbatim}
The numbering is entirely font-soecific. Glyph `5' might be the character `v', for example.
Character variants are specifically designed not to conflict with each
other, so you can enable them individually per character.
(Unlike stylistic alternates, say.)
Note that the indexing starts from zero.


\subsubsection{Contextuals}
This feature refers to substitutions of glyphs that vary `contextually' by their relative position in a word or string of characters;
features such as contextual swashes are accessed via the options shown in \ref{feat:Contextuals}.

\begin{features}{Contextuals}
\otf*{Swash}{cswh}
\otf*{Alternate}{calt}
\otf*{WordInitial}{init}
\otf*{WordFinal}{fina}
\otf*{LineFinal}{falt}
\otf*{Inner}{medi}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

Historic forms are accessed in OpenType
fonts via the feature \feat{Style=Historic}; this is generally \emph{not}
contextual in OpenType, which is why it is not included in this feature.


\subsubsection{Diacritics}

Specifies how combining diacritics should be placed.
These will usually be controlled automatically
according to the Script setting.

\begin{features}{Diacritics}
\otf*{MarkToBase}{mark}
\otf*{MarkToMark}{mkmk}
\otf*{AboveBase}{abvm}
\otf*{BelowBase}{blwm}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}


\subsubsection{Fractions --- \texttt{frac}}

\begin{features}{Fractions}
\otf{On}{+frac}
\otf{Off}{-frac}
\otf{Reset}{}
\cmidrule{2-4}
\otf*{Alternate}{afrc}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

For OpenType fonts use a regular text slash to create fractions, but
the \feat{Fraction} feature must be explicitly activated.
Some (Asian fonts predominantly) also provide for the
\opt{Alternate} feature. These are both shown in \exref{ot-frac}.

\begin{Xexample}{ot-frac}{The \feat{Fractions} feature.}
  \fontspec{Hiragino Maru Gothic Pro W4}
   1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
  \addfontfeature{Fractions=On}
   1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
  \addfontfeature{Fractions=Alternate}
   1/2 \quad 1/4 \quad 5/6 \quad 13579/24680 \\
\end{Xexample}



\subsubsection{Kerning --- \texttt{kern}}
\label{sec:kerning}

Specifies how inter-glyph spacing should behave.
Well-made fonts include information for how differing
amounts of space should be inserted between separate character pairs.
This kerning space is inserted automatically but in rare
circumstances you may wish to turn it off.

\begin{features}{Kerning}
\otf{On}{+kern}
\otf{Off}{-kern}
\otf{Reset}{}
\cmidrule{2-4}
\otf*{Uppercase}{cpsp}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

As briefly mentioned previously at the end of \vref{sec:letters},
the \opt{Uppercase} option will add a small amount of tracking between
uppercase letters, seen in \exref{kernup}, which uses the Romande
fonts\note{\url{http://arkandis.tuxfamily.org/adffonts.html}}
(thanks to Clea F. Rees for the suggestion).
The \opt{Uppercase} option acts separately to the regular kerning
controlled by the \opt{On}/\opt{Off} options.

\begin{Xexample}[firstline=2]{kernup}{Adding extra kerning for uppercase letters. (The difference is usually very small.)}
  \large
  \fontspec{RomandeADFStd-DemiBold.otf}
   UPPERCASE EXAMPLE \\
  \addfontfeature{Kerning=Uppercase}
   UPPERCASE EXAMPLE
\end{Xexample}


\subsubsection{Letters} \label{sec:letters}
The \opt{Letters} feature specifies how the letters in the current font
will look. OpenType fonts may contain the following options:
\opt{Uppercase}, \opt{SmallCaps}, \opt{PetiteCaps},
\opt{UppercaseSmallCaps}, \opt{UppercasePetiteCaps}, and
\opt{Unicase}.

\begin{features}{Letters}
\otf*{Uppercase}{case}
\otf*{SmallCaps}{smcp}
\otf*{PetiteCaps}{pcap}
\otf*{UppercaseSmallCaps}{c2sc}
\otf*{UppercasePetiteCaps}{c2pc}
\otf*{Unicase}{unic}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

Petite caps are smaller than small caps.
\opt{SmallCaps} and \opt{PetiteCaps}
turn lowercase letters into the smaller caps letters,
whereas the \opt{Uppercase...} options turn the \emph{capital} letters into
the smaller
caps (good, \eg, for applying to already uppercase acronyms like
`NASA').
This difference is shown in \exref{caps}.
`Unicase' is a weird hybrid of upper and lower case letters.

\begin{Lexample}{caps}{Small caps from lowercase or uppercase letters.}
  \fontspec{texgyreadventor-regular.otf}[Letters=SmallCaps]
   THIS SENTENCE no verb                \\
  \fontspec{texgyreadventor-regular.otf}[Letters=UppercaseSmallCaps]
   THIS SENTENCE no verb
\end{Lexample}

Note that the \opt{Uppercase} option will (probably)
not actually map letters to uppercase.
 \note{If you want automatic uppercase letters, look to \LaTeX's
      \cmd\MakeUppercase\ command.}
It is designed to select various
uppercase forms for glyphs such as accents and dashes, such as shown
in \exref{letters-uppercase}; note the raised position of the hyphen
to better match the surrounding letters.

\begin{Lexample}{letters-uppercase}{An example of the \opt{Uppercase} option of the \feat{Letters} feature.}
  \fontspec{LinLibertine_R.otf}
   UPPER-CASE example \\
  \addfontfeature{Letters=Uppercase}
   UPPER-CASE example
\end{Lexample}

The \feat{Kerning} feature also contains an \opt{Uppercase} option,
which adds a small amount of spacing in between letters (see \vref{sec:kerning}).


\subsubsection{Ligatures}
\label{sec:ot-feat-liga}

\feat{Ligatures} refer to the replacement of two separate characters
with a specially drawn glyph for functional or \ae sthetic reasons.
The list of options, of which multiple may be selected at one time,
is shown in \ref{feat:Ligatures}.
A demonstration with the Linux Libertine fonts\note{\url{http://www.linuxlibertine.org/}} is shown in \exref{lig}.

Note the additional features accessed with \verb|Ligatures=TeX|. These are
not actually real OpenType features, but additions provided by \pkg{luaotfload} (i.e., \LuaTeX\ only) to emulate \TeX's behaviour for \textsc{ascii} input of curly quotes and punctuation. In \XeTeX\ this is achieved with the \feat{Mapping} feature (see \vref{sec:mapping}) but for consistency \verb|Ligatures=TeX| will perform the same function as \verb|Mapping=tex-text|.

\begin{features}{Ligatures}
\otf*{Required}{rlig}
\otf*{Common}{liga}
\otf*{Contextual}{clig}
\otf*{Rare/Discretionary}{dlig}
\otf*{Historic}{hlig}
\otf*{TeX}{tlig}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

\begin{Lexample}[firstline=2]{lig}{An example of the \feat{Ligatures} feature.}
   \Huge\centering
   \def\test#1#2{%
     #2 $\to$ {\addfontfeature{#1} #2}\\}
   \fontspec{LinLibertine_R.otf}
   \test{Ligatures=Historic}{strict}
   \test{Ligatures=Rare}{wurtzite}
   \test{Ligatures=CommonOff}{firefly}
\end{Lexample}


\subsubsection{Localised Forms --- \texttt{locl}}

\begin{features}{LocalForms}
\otf{On}{+locl}
\otf{Off}{-locl}
\otf{Reset}{}
\end{features}

This feature enables and disables glyph substitutions, etc., that are specific to the
\feat{Language} selected in the font.
This feature is automatically activated by default when present,
so it should not be generally necessary to use \feat{LocalForms} \texttt{=} \opt{On}.
In certain scenarios it may be important to turn it \opt{Off} (although nothing specifically springs to mind).


\subsubsection{Numbers}

The \feat{Numbers} feature defines how numbers will look in the
selected font, accepting options shown in \ref{feat:Numbers}.

\begin{features}{Numbers}
\otf*{Uppercase}{lnum}
\otf*{Lowercase}{onum}
\otf*{Lining}{lnum}
\otf*{OldStyle}{onum}
\otf*{Proportional}{pnum}
\otf*{Monospaced}{tnum}
\otf*{SlashedZero}{zero}
\otf*{Arabic}{anum}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

The synonyms
\opt{Uppercase} and \opt{Lowercase} are equivalent to \opt{Lining} and
\opt{OldStyle}, respectively.
The differences have been shown previously
in \vref{sec:addfontfeatures}.
The \opt{Monospaced} option is useful for tabular material when digits need
to be vertically aligned.

The \opt{SlashedZero} option
replaces the default zero with a slashed version to prevent
confusion with an uppercase `O', shown in \exref{slashzero}.

\begin{Lexample}{slashzero}{The effect of the \opt{SlashedZero} option.}
  \fontspec[Numbers=Lining]{texgyrebonum-regular.otf}
   0123456789
  \fontspec[Numbers=SlashedZero]{texgyrebonum-regular.otf}
   0123456789
\end{Lexample}

The \opt{Arabic} option (with tag \verb|anum|) maps regular numerals to their Arabic script or Persian equivalents
based on the current \opt{Language} setting (see \vref{sec:ot}).
This option is based on a \LuaTeX\ feature of the \pkg{luaotfload} package,
not an OpenType feature. (Thus, this feature is unavailable in \XeTeX.)
This feature should be considered deprecated; while there are no plans to remove it from this package,
if its support is dropped from the font loader it could disappear from \pkg{fontspec} with little notice.


\subsubsection{Ornament --- \texttt{ornm}}

Ornaments are selected with the \feat{Ornament} feature (OpenType feature |ornm|),
selected numerically such as for the \feat{Annotation} feature.


\subsubsection{Style}
\label{sec:ot-feat-style}

\begin{features}{Style}
\otf*{Alternate}{salt}
\otf*{Italic}{ital}
\otf*{Ruby}{ruby}
\otf*{Swash}{swsh}
\otf*{Cursive}{curs}
\otf*{Historic}{hist}
\otf*{TitlingCaps}{titl}
\otf*{HorizontalKana}{hkna}
\otf*{VerticalKana}{vkna}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

`Ruby' refers to a small optical size, used in
Japanese typography for annotations.
For fonts with multiple |salt| OpenType features,
use the fontspec \feat{Alternate} feature instead.

\Exref{style-alt} shows an example of a font feature that involves glyph substitution
for particular letters within an alphabet.
Other options in these categories operate in similar ways, with the choice of how
particular substitutions are organised with which feature largely up to the font designer.

 \begin{Xexample}[firstline=2]{style-alt}{Example of the \opt{Alternate} option of the \feat{Style} feature.}
  \Large
  \fontspec{Quattrocento.otf}
   M Q W                      \\
  \addfontfeature{Style=Alternate}
   M Q W
\end{Xexample}

In other features, larger breadths of changes can be seen, covering
the style of an entire alphabet.
See \exref{style-itrub}; here, the \opt{Italic} option affects the Latin text
and the \opt{Ruby} option the Japanese.

\begin{Xexample}[firstline=2]{style-itrub}{Example of the \opt{Italic} and \opt{Ruby} options of the \feat{Style} feature.}
  \Large \def\kana{ようこそ ワカヨタレソ}
  \fontspec{Hiragino Mincho Pro}
   Latin \kana        \\
  \addfontfeature{Style={Italic, Ruby}}
   Latin \kana
\end{Xexample}

Note the difference here between the default and the horizontal style kana
in \exref{style-hvkana}: the horizontal style is slightly wider.

\begin{Xexample}[firstline=2]{style-hvkana}{Example of the \opt{HorizontalKana} and \opt{VerticalKana} options of the \feat{Style} feature.}
  \Large \def\kana{ようこそ ワカヨタレソ}
   \fontspec{Hiragino Mincho Pro}
    \kana   \\
  {\addfontfeature{Style=HorizontalKana}
    \kana } \\
  {\addfontfeature{Style=VerticalKana}
    \kana }
\end{Xexample}


\subsubsection{Stylistic Set variations --- \texttt{ssNN}}
\label{sec:ot-ss}

This feature selects a `Stylistic Set' variation,
which usually corresponds to an alternate glyph style for a range of
characters (usually an alphabet or subset thereof).
This feature is specified numerically. These correspond to OpenType
features |ss01|, |ss02|, etc.

Two demonstrations from the Junicode
font\note{\url{http://junicode.sf.net}}
are shown in \exref{ss} and \exref{ss2}; thanks to Adam
Buchbinder for the suggestion.

\begin{Lexample}{ss}{Insular letterforms, as used in medieval Northern Europe, for the Junicode font accessed with the \feat{StylisticSet} feature.}
  \fontspec{Junicode}
   Insular forms. \\
  \addfontfeature{StylisticSet=2}
   Insular forms. \\
\end{Lexample}

\begin{Lexample}{ss2}{Enlarged minuscules (capital letters remain unchanged) for the Junicode font, accessed with the \feat{StylisticSet} feature.}
  \fontspec{Junicode}
   ENLARGED Minuscules. \\
  \addfontfeature{StylisticSet=6}
   ENLARGED Minuscules. \\
\end{Lexample}

Multiple stylistic sets may be selected simultaneously by writing, e.g.,
|StylisticSet={1,2,3}|.

The |StylisticSet| feature is a synonym of the \feat{Variant} feature for \AAT\ fonts.
See \vref{sec:newfeatures} for a way to assign names to stylistic sets, which should be done on a per-font basis.


\subsubsection{Vertical Position}

\begin{features}{VerticalPosition}
\otf*{Superior}{sups}
\otf*{Inferior}{subs}
\otf*{Numerator}{numr}
\otf*{Denominator}{dnom}
\otf*{ScientificInferior}{sinf}
\otf*{Ordinal}{ordn}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

The \feat{VerticalPosition} feature is used to access things like
subscript (\opt{Inferior}) and superscript (\opt{Superior}) numbers and
letters (and a small amount of punctuation, sometimes).
The \opt{Ordinal} option will only raise characters that are used
in some languages directly after a number.
The \opt{ScientificInferior} feature will move glyphs
further below the baseline than the \opt{Inferior} feature.
These are shown in \exref{vertpos}

\opt{Numerator} and \opt{Denominator} should only be used for creating
arbitrary fractions (see next section).

\begin{Lexample}{vertpos}{The \feat{VerticalPosition} feature.}
  \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Superior]
   Superior: 1234567890                                   \\
  \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Numerator]
   Numerator: 12345                                       \\
  \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=Denominator]
   Denominator: 12345                                     \\
  \fontspec{LibreCaslonText-Regular.otf}[VerticalPosition=ScientificInferior]
   Scientific Inferior: 12345
\end{Lexample}

The \pkg{realscripts} package
(which is also loaded by \pkg{xltxtra} for \XeTeX)
redefines the \cmd\textsubscript\ and
\cmd\textsuperscript\ commands to use the above font features automatically,
including for use in footnote labels.
If this is the only feature of \pkg{xltxtra} you wish to use, consider
loading \pkg{realscripts} on its own instead.



\subsection{CJK features}

This section summarises the features which are largely intending for Chinese, Korean,
and Japanese typesetting.


\subsubsection{Annotation --- \texttt{nalt} }

Some fonts are equipped with an extensive range of
numbers and numerals in different forms. These are accessed with the
\feat{Annotation} feature (OpenType feature |nalt|), selected numerically as shown in
\exref{ot-annot}. Note that the indexing starts from zero.

\begin{Xexample}{ot-annot}{Annotation forms for OpenType fonts.}
  \fontspec{Hiragino Maru Gothic Pro}
   1 2 3 4 5 6 7 8 9
  \def\x#1{\\{\addfontfeature{Annotation=#1}
            1 2 3 4 5 6 7 8 9 }}
  \x0\x1\x2\x3\x4\x5\x6\x7\x7\x8\x9
\end{Xexample}


\subsubsection{Character width}\label{sec:CharacterWidth}

Many Asian fonts are equipped with variously spaced characters for
shoe-horning into their generally monospaced text.
These are
accessed through the \feat{CharacterWidth} feature.

\begin{features}{CharacterWidth}
\otf*{Proportional}{pwid}
\otf*{Full}        {fwid}
\otf*{Half}        {hwid}
\otf*{Third}       {twid}
\otf*{Quarter}     {qwid}
\otf*{AlternateProportional}{palt}
\otf*{AlternateHalf}{halt}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

Japanese alphabetic glyphs (in Hiragana or Katakana) may be typeset
proportionally, to better fit horizontal measures, or monospaced, to
fit into the rigid grid imposed by ideographic typesetting. In this
latter case, there are also half-width forms for squeezing more kana
glyphs (which are less complex than the kanji they are amongst) into
a given block of space. The same features are given to roman letters
in Japanese fonts, for typesetting foreign words in the same style
as the surrounding text.

\begin{Xexample}[firstline=2]{charwdprop}{Proportional or fixed width forms.}
  \def\texta{ようこそ}\def\textb{ワカヨタレソ}
  \def\test{\makebox[2cm][l]{\texta}%
            \makebox[2.5cm][l]{\textb}%
            \makebox[2.5cm][l]{abcdef}}
  \fontspec{Hiragino Mincho Pro}
  {\addfontfeature{CharacterWidth=Proportional}\test}\\
  {\addfontfeature{CharacterWidth=Full}\test}\\
  {\addfontfeature{CharacterWidth=Half}\test}
\end{Xexample}

The same situation occurs with numbers, which are provided in
increasingly illegible compressed forms seen in \exref{charwd}.

\begin{Xexample}[firstline=2]{charwd}{Numbers can be compressed significantly.}
  \centering
  \fontspec[Renderer=AAT]{Hiragino Mincho Pro}
  {\addfontfeature{CharacterWidth=Full}
   ---12321---}\\
  {\addfontfeature{CharacterWidth=Half}
   ---1234554321---}\\
  {\addfontfeature{CharacterWidth=Third}
   ---123456787654321---}\\
  {\addfontfeature{CharacterWidth=Quarter}
   ---12345678900987654321---}
\end{Xexample}


\subsubsection{CJK shape}

\begin{features}{CJKShape}
\otf{Traditional}{trad}
\otf{Simplified} {smpl}
\otf{JIS1978}    {jp78}
\otf{JIS1983}    {jp83}
\otf{JIS1990}    {jp90}
\otf{Expert}     {expt}
\otf{NLC}        {nlck}
\end{features}

There have been many standards for how CJK ideographic
glyphs are `supposed' to look. Some fonts will contain many alternate
glyphs available in order to be able to display these gylphs
correctly in whichever form is appropriate. Both \AAT\ and OpenType
fonts support the following \feat{CJKShape} options:
\opt{Traditional}, \opt{Simplified}, \opt{JIS1978}, \opt{JIS1983},
\opt{JIS1990}, and \opt{Expert}. OpenType also supports the \opt{NLC} option.

\begin{Xexample}[firstline=2]{ot-cjk-shape}{Different standards for CJK ideograph presentation.}
  \LARGE\def\text{ 唖噛躯 妍并訝}
  \fontspec{Hiragino Mincho Pro}
  {\addfontfeature{CJKShape=Traditional}
  \text }                          \\
  {\addfontfeature{CJKShape=NLC}
  \text }                          \\
  {\addfontfeature{CJKShape=Expert}
  \text }
\end{Xexample}


\subsubsection{Vertical typesetting}

\begin{features}{Vertical}
\otf*{RotatedGlyphs}         {vrt2}
\otf*{AlternatesForRotation} {vrtr}
\otf*{Alternates}            {vert}
\otf*{KanaAlternates}        {vkna}
\otf*{Kerning}               {vkrn}
\otf*{AlternateMetrics}      {valt}
\otf*{HalfMetrics}           {vhal}
\otf*{ProportionalMetrics}   {vpal}
\cmidrule{2-4}
\otf{ResetAll}{}
\end{features}

OpenType provides a plethora of features for accommodating the varieties of possibilities
needed for vertical typesetting (CJK and others).
No capabilities for achieving such vertical typesetting are provided by \pkg{fontspec},
however; please get in touch if there are improvements that could be made.


\end{document}

% /©
% ------------------------------------------------
% The FONTSPEC package  <wspr.io/fontspec>
% ------------------------------------------------
% Copyright  2004-2020  Will Robertson, LPPL "maintainer"
% Copyright  2009-2015  Khaled Hosny
% Copyright  2013       Philipp Gesang
% Copyright  2013-2016  Joseph Wright
% ------------------------------------------------
% This package is free software and may be redistributed and/or modified under
% the conditions of the LaTeX Project Public License, version 1.3c or higher
% (your choice): <http://www.latex-project.org/lppl/>.
% ------------------------------------------------
% ©/