summaryrefslogtreecommitdiff
path: root/macros/unicodetex/latex/fontspec/fontspec-code-xfss.dtx
blob: 6fdb9f4ad56bd70e59c822a43359086249cddfb8 (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
%%^^A%%  fontspec-code-xfss.dtx -- part of FONTSPEC <latex3.github.io/fontspec>

% \section{Changes/additions to the NFSS}
%
% \begin{function}{\strong, \strongenv}
% \begin{syntax}
% "\strong" \marg{text}
% "\begin{strongenv}" \meta{text} "\end{strongenv}"
% \end{syntax}
% Typesets text in the `strong' font. NFSS series equivalent to \cs{emph}. Can be nested.
% \end{function}
%
% \begin{function}{\strongfontdeclare}
% \begin{syntax}
% "\strongfontdeclare" \marg{comma-separated font switch declarations}
% \end{syntax}
% Define the behaviour of nested \cs{strong} commands. 
% \end{function}
%
% \begin{function}{\strongreset}
% \begin{syntax}
% "\renewcommand \strongreset" \marg{font switch declarations}
% \end{syntax}
% Define the behaviour when a \cs{strong} command is nested deeper than the definitions provided by \cs{strongfontdeclare}.
% By default this is \meta{empty} --- i.e., bold on top of bold remains bold.
% In certain circumstances it may be appropriate to reset to a default state. 
% \end{function}
%
%
% \section{Implementation}
%
%    \begin{macrocode}
%<*fontspec>
%    \end{macrocode}
%
%
% \subsection{Italic small caps and so on} \label{sec:sishape}
%
%    \begin{macrocode}
\providecommand*\scitdefault{\scdefault\itdefault}
\providecommand*\scsldefault{\scdefault\sldefault}
\providecommand*\scswdefault{\scdefault\swdefault}
%    \end{macrocode}
% \LaTeX's `shape' font axis needs to be overloaded to support italic small caps and slanted small caps.
% These are the combinations to support:
%    \begin{macrocode}
\cs_new:Nn \@@_shape_merge:nn { c_@@_shape_#1_#2_tl }
\cs_new:Nn \@@_merge_default_shapes:
  {
    \tl_const:cn { \@@_shape_merge:nn \shapedefault\scdefault    } {\scdefault}
    \tl_const:cn { \@@_shape_merge:nn \itdefault   \scdefault    } {\scitdefault}
    \tl_const:cn { \@@_shape_merge:nn \sldefault   \scdefault    } {\scsldefault}
    \tl_const:cn { \@@_shape_merge:nn \swdefault   \scdefault    } {\scswdefault}
    \tl_const:cn { \@@_shape_merge:nn \scdefault   \itdefault    } {\scitdefault}
    \tl_const:cn { \@@_shape_merge:nn \scdefault   \sldefault    } {\scsldefault}
    \tl_const:cn { \@@_shape_merge:nn \scdefault   \swdefault    } {\scswdefault}
    \tl_const:cn { \@@_shape_merge:nn \scsldefault \itdefault    } {\scitdefault}
    \tl_const:cn { \@@_shape_merge:nn \scitdefault \sldefault    } {\scsldefault}
    \tl_const:cn { \@@_shape_merge:nn \scitdefault \shapedefault } {\scdefault}
    \tl_const:cn { \@@_shape_merge:nn \scsldefault \shapedefault } {\scdefault}
  }
\@@_merge_default_shapes:
%    \end{macrocode}
%
% The following is rather specific; it only returns true if the merged shape exists,
% but more importantly also if the merged shape is defined for the current font.
%    \begin{macrocode}
\prg_new_conditional:Nnn \@@_if_merge_shape:n {TF}
  {
    \bool_lazy_and:nnTF
      { \tl_if_exist_p:c { \@@_shape_merge:nn {\f@shape} {#1} } }
      {
        \cs_if_exist_p:c
          {
            \f@encoding/\f@family/\f@series/
            \tl_use:c { \@@_shape_merge:nn {\f@shape} {#1} }
          }
      }
    \prg_return_true: \prg_return_false:
  }
%    \end{macrocode}
%
%
%    \begin{macrocode}
\cs_set_eq:NN \emfontdeclare \DeclareEmphSequence
%    \end{macrocode}
%
%
%
%
% \subsection{Strong emphasis}
%
% \begin{macro}{\strongfontdeclare}
%    \begin{macrocode}
\cs_set_protected:Npn \strongfontdeclare #1
  {
    \prop_gclear:N   \g_@@_strong_prop
    \int_zero:N      \l_@@_strongdef_int

    \group_begin:
      \normalfont
      \clist_map_inline:nn {\strongreset,#1}
        {
          ##1
          \prop_gput_if_not_in:NeV \g_@@_strong_prop { \f@series } { \l_@@_strongdef_int }
          \prop_gput:Nen \g_@@_strong_prop { switch-\int_use:N \l_@@_strongdef_int } { ##1 }
          \int_incr:N \l_@@_strongdef_int
        }
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\strongenv}
%    \begin{macrocode}
\DeclareRobustCommand \strongenv
  {
    \@nomath\strongenv

%<debug> \typeout{Strong~ level:~\int_use:N \l_@@_strong_int}
    \prop_get:NeNT \g_@@_strong_prop { \f@series } \l_@@_strong_tmp_tl
      {
        \int_set:Nn \l_@@_strong_int { \l_@@_strong_tmp_tl }
%<debug> \typeout{Series~ (\f@series)~ detected;~ new~ level:~\int_use:N \l_@@_strong_int}
      }

    \int_incr:N \l_@@_strong_int

    \prop_get:NeNTF \g_@@_strong_prop { switch-\int_use:N \l_@@_strong_int } \l_@@_strong_switch_tl
      { \l_@@_strong_switch_tl }
      {
        \int_zero:N \l_@@_strong_int
        \strongreset
      }

  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\strong}
%    \begin{macrocode}
\DeclareTextFontCommand{\strong}{\strongenv}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\strongreset}
%    \begin{macrocode}
\cs_set:Npn \strongreset {}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\reset@font}
% Ensure nesting resets when necessary:
%    \begin{macrocode}
\cs_set_protected:Npn \reset@font
  {
    \normalfont
    \int_zero:N \l_@@_strong_int
  }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Defaults}
%
%    \begin{macrocode}
\strongfontdeclare{\bfseries}
%    \end{macrocode}
%
%    \begin{macrocode}
%</fontspec>
%    \end{macrocode}


\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/>.
% ------------------------------------------------
% ©/