-
Notifications
You must be signed in to change notification settings - Fork 34
/
fontspec-code-graphite.dtx
129 lines (121 loc) · 3.93 KB
/
fontspec-code-graphite.dtx
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
%%^^A%% fontspec-code-graphite.dtx -- part of FONTSPEC <latex3.github.io/fontspec>
% \section{Graphite/AAT code}
%
% \iffalse
% \begin{macrocode}
%<*fontspec&XE>
% \end{macrocode}
% \fi
%
% \begin{macro}{\@@_define_aat_feature_group:n}
% \begin{macrocode}
\cs_new:Nn \@@_define_aat_feature_group:n
{
\keys_define:nn {fontspec-aat} { #1 .multichoice: }
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_define_aat_feature:nnnn}
% \begin{macrocode}
\cs_new:Nn \@@_define_aat_feature:nnnn
{
\keys_define:nn {fontspec-aat}
{
#1/#2 .code:n = { \@@_make_AAT_feature:nn {#3}{#4} }
}
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\@@_make_AAT_feature:nn}
% \begin{macrocode}
\cs_new:Nn \@@_make_AAT_feature:nn
{
\tl_if_empty:nTF {#1}
{ \@@_warning:n {aat-feature-not-exist} }
{
\exp_args:No \@@_make_AAT_feature_string:NnnTF \l_@@_fontface_cs_tl {#1} {#2}
{
\@@_update_featstr:n {\l_fontspec_feature_string_tl}
}
{
\@@_warning:nx {aat-feature-not-exist-in-font} {#1,#2}
}
}
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_make_AAT_feature_string:NnnTF}
% This macro takes the numerical codes for a font feature and
% creates a specified macro containing the string required in the
% font definition to turn that feature on or off. Used primarily in
% [...], but also used to check if small caps
% exists in the requested font (see page~\pageref{mac:makesmallcaps}).
%
% For exclusive selectors, it's easy; just grab the string:
% For \emph{non}-exclusive selectors, it's a little more complex.
% If the selector is even, it corresponds to switching the feature on.
% If the selector is \emph{odd}, it corresponds to switching the feature off.
% But \XeTeX\ doesn't return a selector string for this number, since the
% feature is defined for the `switching on' value. So we need to check the
% selector of the previous number, and then prefix the feature string with |!|
% to denote the switch.
%
% Finally, save out the complete feature string in \cmd\l_fontspec_feature_string_tl.
% \begin{macrocode}
\prg_new_conditional:Nnn \@@_make_AAT_feature_string:Nnn {TF,T,F}
{
\tl_set:Nx \l_@@_tmpa_tl { \XeTeXfeaturename #1 #2 }
\tl_if_empty:NTF \l_@@_tmpa_tl
{ \prg_return_false: }
{
\int_compare:nTF { \XeTeXisexclusivefeature #1 #2 > 0 }
{
\tl_set:Nx \l_@@_tmpb_tl {\XeTeXselectorname #1 #2\space #3}
}
{
\int_if_even:nTF {#3}
{
\tl_set:Nx \l_@@_tmpb_tl {\XeTeXselectorname #1 #2\space #3}
}
{
\tl_set:Nx \l_@@_tmpb_tl
{
\XeTeXselectorname #1 #2\space \numexpr#3-1\relax
}
\tl_if_empty:NF \l_@@_tmpb_tl { \tl_put_left:Nn \l_@@_tmpb_tl {!} }
}
}
\tl_if_empty:NTF \l_@@_tmpb_tl
{ \prg_return_false: }
{
\tl_set:Nx \l_fontspec_feature_string_tl { \l_@@_tmpa_tl = \l_@@_tmpb_tl }
\prg_return_true:
}
}
}
% \end{macrocode}
% \end{macro}
%
% \iffalse
% \begin{macrocode}
%</fontspec&XE>
% \end{macrocode}
% \fi
\endinput
% /©
% ------------------------------------------------
% The FONTSPEC package <latex3.github.io/fontspec>
% ------------------------------------------------
% Copyright 2022-2024 The LaTeX project, LPPL "maintainer"
% Copyright 2004-2022 Will Robertson
% 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/>.
% ------------------------------------------------
% ©/