| 1 |
%%^^A%% fontspec-code-internal.dtx -- part of FONTSPEC <latex3.github.io/fontspec> |
| 2 |
|
| 3 |
% \section{Internals} |
| 4 |
% |
| 5 |
% \iffalse |
| 6 |
% \begin{macrocode} |
| 7 |
%<*fontspec> |
| 8 |
% \end{macrocode} |
| 9 |
% \fi |
| 10 |
% |
| 11 |
% \subsection{The main function for setting fonts} |
| 12 |
% |
| 13 |
% \begin{macro}{\@@_select_font_family:nn} |
| 14 |
% This is the command that defines font families for use, the underlying |
| 15 |
% procedure of all \cmd\fontspec-like commands. Given a |
| 16 |
% list of font features (|#1|) for a requested font (|#2|), |
| 17 |
% it will define an NFSS |
| 18 |
% family for that font and put the family name (globally) into \cs{l_fontspec_family_tl}. |
| 19 |
% The \TeX\ `\cs{font}' command is (globally) stored in \cs{l_fontspec_font}. |
| 20 |
% |
| 21 |
% This macro does its processing inside a group to attempt to restrict the scope of its internal processing. |
| 22 |
% This works to some degree to insulate the internal commands from having to be manually cleared. |
| 23 |
% |
| 24 |
% Some often-used variables to know about: |
| 25 |
% \begin{itemize} |
| 26 |
% \item \cmd{\l_fontspec_fontname_tl} is used as the generic name of the font being defined. |
| 27 |
% \item \cmd{\l_@@_fontid_tl} is the unique identifier of the font with all its features. |
| 28 |
% \item \cmd{\l_@@_fontname_up_tl} is the font specifically to be used as the upright font. |
| 29 |
% \item \cmd{\l_@@_basename_tl} is the (immutable) original argument used for |*|-replacing. |
| 30 |
% \item \cmd{\l_fontspec_font} is the plain \TeX{} font of the upright font requested. |
| 31 |
% \end{itemize} |
| 32 |
% \begin{macrocode} |
| 33 |
\cs_new_protected:Nn \@@_select_font_family:nn |
| 34 |
{ |
| 35 |
%<debug>\typeout{^^J^^J::::::::::::::::::::::::::::::^^J:: fontspec_select:nn~ {#1}~ {#2} } |
| 36 |
\group_begin: |
| 37 |
\@@_font_suppress_not_found_error: |
| 38 |
\@@_init: |
| 39 |
|
| 40 |
\@@_sanitise_fontname:Nn \l_fontspec_fontname_tl {#2} |
| 41 |
\tl_set_eq:NN \l_@@_fontname_up_tl \l_fontspec_fontname_tl |
| 42 |
\tl_set_eq:NN \l_@@_basename_tl \l_fontspec_fontname_tl |
| 43 |
|
| 44 |
%<debug>\typeout{^^J::::::::::::::: l_fontspec_fontname_tl~ =~ \l_fontspec_fontname_tl } |
| 45 |
|
| 46 |
\@@_if_detect_external:nT {#2} |
| 47 |
{ \keys_set:nn {fontspec-preparse-external} {Path} } |
| 48 |
|
| 49 |
\keys_set_known:nn {fontspec-preparse-cfg} {#1} |
| 50 |
|
| 51 |
\@@_init_ttc:n {#2} |
| 52 |
\@@_load_external_fontoptions:N \l_fontspec_fontname_tl |
| 53 |
|
| 54 |
\@@_extract_all_features:n {#1} |
| 55 |
\tl_set:Nx \l_@@_fontid_tl { \tl_to_str:N \l_fontspec_fontname_tl-:-\tl_to_str:N \l_@@_all_features_clist } |
| 56 |
|
| 57 |
%<debug>\typeout{fontid: \l_@@_fontid_tl} |
| 58 |
|
| 59 |
\@@_preparse_features: |
| 60 |
|
| 61 |
%<debug>\typeout{^^J::::::::::::::: l_fontspec_fontname_tl~ =~ \l_fontspec_fontname_tl } |
| 62 |
%<debug>\typeout{::::::::::::::: _fontname_up_tl~ =~ \l_@@_fontname_up_tl } |
| 63 |
%<debug>\typeout{::::::::::::::: l_@@_extension_tl~ =~ \l_@@_extension_tl } |
| 64 |
|
| 65 |
\@@_load_font: |
| 66 |
\@@_set_scriptlang: |
| 67 |
\@@_get_features:n {} |
| 68 |
\bool_set_false:N \l_@@_firsttime_bool |
| 69 |
|
| 70 |
\@@_save_family_needed:nTF {#2} |
| 71 |
{ |
| 72 |
\@@_save_family:nn {#1} {#2} |
| 73 |
%<debug>\@@_warning:nxx {defining-font} {#1} {#2} |
| 74 |
} |
| 75 |
{ |
| 76 |
%<debug>\typeout{Font~ family~ already~ defined.} |
| 77 |
} |
| 78 |
\group_end: |
| 79 |
|
| 80 |
\tl_set_eq:NN \l_fontspec_family_tl \g_@@_nfss_family_tl |
| 81 |
%<debug>\typeout{::::::::::::::::::::::::::::::} |
| 82 |
} |
| 83 |
% \end{macrocode} |
| 84 |
% \end{macro} |
| 85 |
% |
| 86 |
% \begin{macro}{\fontspec_select:nn} |
| 87 |
% This old name has been used by 3rd party packages so for compatibility: |
| 88 |
% \begin{macrocode} |
| 89 |
\cs_set_eq:NN \fontspec_select:nn \@@_select_font_family:nn %% deprecated, for compatibility only |
| 90 |
% \end{macrocode} |
| 91 |
% \end{macro} |
| 92 |
% |
| 93 |
% \begin{macro}{\@@_sanitise_fontname:Nn} |
| 94 |
% Assigns font name |#2| to token list variable |#1| and strips extension(s) from it in the case of an external font. |
| 95 |
% \begin{macrocode} |
| 96 |
\cs_new:Nn \@@_sanitise_fontname:Nn |
| 97 |
{ |
| 98 |
\tl_set:Nx #1 {#2} |
| 99 |
\tl_trim_spaces:N #1 |
| 100 |
\@@_process_ext:N #1 |
| 101 |
} |
| 102 |
|
| 103 |
\cs_new:Nn \@@_process_ext:N |
| 104 |
{ |
| 105 |
\clist_map_inline:Nn \l_@@_extensions_clist |
| 106 |
{ |
| 107 |
\tl_if_in:NnT #1 {##1} |
| 108 |
{ |
| 109 |
%<debug> \typeout{::@@_process_ext:N~ --~ Removing~ EXT:~ ##1} |
| 110 |
\tl_remove_once:Nn #1 {##1} |
| 111 |
\tl_set:Nn \l_@@_extension_tl {##1} |
| 112 |
\@@_font_is_file: |
| 113 |
\clist_map_break: |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
% \end{macrocode} |
| 118 |
% \end{macro} |
| 119 |
% |
| 120 |
% \begin{macro}{\@@_if_detect_external:nT} |
| 121 |
% Check if either the fontname ends with a known font extension. |
| 122 |
% \begin{macrocode} |
| 123 |
\prg_new_conditional:Nnn \@@_if_detect_external:n {T} |
| 124 |
{ |
| 125 |
%<debug> \typeout{:: @@_if_detect_external:n { \exp_not:n {#1} } } |
| 126 |
\clist_map_inline:Nn \l_@@_extensions_clist |
| 127 |
{ |
| 128 |
\bool_set_false:N \l_@@_tmpa_bool |
| 129 |
\exp_args:Nx % <- this should be handled earlier |
| 130 |
\tl_if_in:nnT {#1 <= end_of_string} {##1 <= end_of_string} |
| 131 |
{ \bool_set_true:N \l_@@_tmpa_bool \clist_map_break: } |
| 132 |
} |
| 133 |
\bool_if:NTF \l_@@_tmpa_bool \prg_return_true: \prg_return_false: |
| 134 |
} |
| 135 |
% \end{macrocode} |
| 136 |
% \end{macro} |
| 137 |
% |
| 138 |
% \begin{macro}{\@@_init_ttc:n} |
| 139 |
% For TTC fonts we assume they will be loading the italic/bold fonts from the same file, |
| 140 |
% so prepopulate the fontnames to avoid needing to do it manually. |
| 141 |
% \begin{macrocode} |
| 142 |
\cs_new:Nn \@@_init_ttc:n |
| 143 |
{ |
| 144 |
\str_if_eq:eeT { \str_lowercase:f {\l_@@_extension_tl} } {.ttc} |
| 145 |
{ |
| 146 |
\tl_set_eq:NN \l_@@_fontname_it_tl \l_fontspec_fontname_tl |
| 147 |
\tl_set_eq:NN \l_@@_fontname_bf_tl \l_fontspec_fontname_tl |
| 148 |
\tl_set_eq:NN \l_@@_fontname_bfit_tl \l_fontspec_fontname_tl |
| 149 |
} |
| 150 |
} |
| 151 |
% \end{macrocode} |
| 152 |
% \end{macro} |
| 153 |
% |
| 154 |
% \begin{macro}{\@@_load_external_fontoptions:N} |
| 155 |
% Load a possible \texttt{.fontspec} font configuration file. |
| 156 |
% This file could set font-specific options for the font about to be loaded. |
| 157 |
% The parameter should be a token list containing a sanitised fontname. |
| 158 |
% In the past this used a space-stripped version of the name, so we check for the file |
| 159 |
% both with and without spaces to load it. |
| 160 |
% \begin{macrocode} |
| 161 |
\cs_new:Nn \@@_load_external_fontoptions:N |
| 162 |
{ |
| 163 |
\bool_if:NT \l_@@_fontcfg_bool |
| 164 |
{ |
| 165 |
%<debug> \typeout{:: @@_load_external_fontoptions:N \exp_not:N #1 } |
| 166 |
\tl_set:Nx \l_@@_ext_filename_tl {#1.fontspec} |
| 167 |
\tl_remove_all:Nn \l_@@_ext_filename_tl {~} |
| 168 |
\prop_if_in:NVF \g_@@_fontopts_prop #1 |
| 169 |
{ |
| 170 |
\exp_args:No \file_if_exist:nTF { \l_@@_ext_filename_tl } |
| 171 |
{ |
| 172 |
\file_input:n { \l_@@_ext_filename_tl } |
| 173 |
} |
| 174 |
{ |
| 175 |
\tl_remove_all:Nn \l_@@_ext_filename_tl {~} |
| 176 |
\exp_args:No \file_if_exist:nT { \l_@@_ext_filename_tl } |
| 177 |
{ \file_input:n { \l_@@_ext_filename_tl } } |
| 178 |
} |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
% \end{macrocode} |
| 183 |
% \end{macro} |
| 184 |
% |
| 185 |
% \begin{macro}{\@@_extract_all_features:} |
| 186 |
% \begin{macrocode} |
| 187 |
\cs_new:Nn \@@_extract_all_features:n |
| 188 |
{ |
| 189 |
%<debug> \typeout{:: @@_extract_all_features:n { \unexpanded {#1} } } |
| 190 |
\bool_if:NTF \l_@@_disable_defaults_bool |
| 191 |
{ |
| 192 |
\clist_set:Nx \l_@@_all_features_clist {#1} |
| 193 |
} |
| 194 |
{ |
| 195 |
\prop_get:NVNF \g_@@_fontopts_prop \l_fontspec_fontname_tl \l_@@_fontopts_clist |
| 196 |
{ \clist_clear:N \l_@@_fontopts_clist } |
| 197 |
|
| 198 |
\prop_get:NVNF \g_@@_fontopts_prop \l_@@_family_label_tl \l_@@_family_fontopts_clist |
| 199 |
{ \clist_clear:N \l_@@_family_fontopts_clist } |
| 200 |
\tl_clear:N \l_@@_family_label_tl |
| 201 |
|
| 202 |
\clist_set:Nx \l_@@_all_features_clist |
| 203 |
{ |
| 204 |
\g_@@_default_fontopts_clist, |
| 205 |
\l_@@_family_fontopts_clist, |
| 206 |
\l_@@_fontopts_clist, |
| 207 |
#1 |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
% \end{macrocode} |
| 212 |
% \end{macro} |
| 213 |
% |
| 214 |
% \begin{macro}{\@@_preparse_features:} |
| 215 |
% \darg{feature options} |
| 216 |
% \darg{font name} |
| 217 |
% Perform the (multi-step) feature parsing process. |
| 218 |
% |
| 219 |
% Convert the requested features to font definition |
| 220 |
% strings. First the features are parsed for information about font |
| 221 |
% loading (whether it's a named font or external font, etc.), and then |
| 222 |
% information is extracted for the names of the other shape fonts. |
| 223 |
% \begin{macrocode} |
| 224 |
\cs_new:Nn \@@_preparse_features: |
| 225 |
{ |
| 226 |
%<debug> \typeout{:: @@_preparse_features:} |
| 227 |
% \end{macrocode} |
| 228 |
% Detect if external fonts are to be used, possibly automatically, and |
| 229 |
% parse fontspec features for bold/italic fonts and their features. |
| 230 |
% \begin{macrocode} |
| 231 |
|
| 232 |
\@@_keys_set_known:nxN {fontspec-preparse-external} |
| 233 |
{ \l_@@_all_features_clist } |
| 234 |
\l_@@_keys_leftover_clist |
| 235 |
|
| 236 |
% \end{macrocode} |
| 237 |
% When \cmd{\l_fontspec_fontname_tl} is augmented with a prefix or whatever to create |
| 238 |
% the name of the upright font (\cmd{\l_@@_fontname_up_tl}), this latter is the new `general |
| 239 |
% font name' to use. |
| 240 |
% \begin{macrocode} |
| 241 |
\tl_set_eq:NN \l_fontspec_fontname_tl \l_@@_fontname_up_tl |
| 242 |
\@@_keys_set_known:nxN {fontspec-renderer} {\l_@@_keys_leftover_clist} |
| 243 |
\l_@@_keys_leftover_clist |
| 244 |
\@@_keys_set_known:nxN {fontspec-preparse} {\l_@@_keys_leftover_clist} |
| 245 |
\l_@@_fontfeat_clist |
| 246 |
} |
| 247 |
% \end{macrocode} |
| 248 |
% \end{macro} |
| 249 |
% |
| 250 |
% \begin{macro}{\@@_load_font:} |
| 251 |
% \begin{macrocode} |
| 252 |
\cs_new:Nn \@@_load_font: |
| 253 |
{ |
| 254 |
%<debug>\typeout{:: @@_load_font} |
| 255 |
|
| 256 |
\@@_sanitise_fontname:Nn \l_@@_fontname_up_tl { \l_@@_fontname_up_tl } |
| 257 |
%<debug>\typeout{Set~ base~ font~ for~ preliminary~ analysis:~ "\l_@@_fontname_up_tl"~ with~ features~ "\l_@@_pre_feat_sclist" } |
| 258 |
\@@_primitive_font_set:NnnF \l_@@_test_font |
| 259 |
{ \@@_construct_font_call:nn { \l_@@_fontname_up_tl } { \l_@@_pre_feat_sclist } } |
| 260 |
{ \f@size pt - 2sp } |
| 261 |
{ \@@_error:nx {font-not-found} {\l_@@_fontname_up_tl} } |
| 262 |
|
| 263 |
%<debug>\typeout{Set~ base~ font~ properly: \@@_construct_font_call:nn { \l_@@_fontname_up_tl } {} } |
| 264 |
\@@_set_font_type:N \l_@@_test_font |
| 265 |
\@@_primitive_font_gset:Onn \l_@@_fontface_cs_tl |
| 266 |
{ \@@_construct_font_call:nn { \l_@@_fontname_up_tl } { \l_@@_pre_feat_sclist } } |
| 267 |
{ \f@size pt + 2sp } |
| 268 |
|
| 269 |
\l_@@_fontface_cs_tl % this is necessary for LuaLaTeX to check the scripts properly |
| 270 |
|
| 271 |
} |
| 272 |
% \end{macrocode} |
| 273 |
% \end{macro} |
| 274 |
% |
| 275 |
% \begin{macro}{\@@_construct_font_call:nn} |
| 276 |
% Constructs the complete font invocation. |
| 277 |
% \darg{Base name} |
| 278 |
% \darg{Extension} |
| 279 |
% \darg{TTC Index} |
| 280 |
% \darg{Renderer} |
| 281 |
% \darg{Optical size} |
| 282 |
% \darg{Font features} |
| 283 |
% We check if \meta{Font features} are empty and if so don't add in the separator colon. |
| 284 |
% \begin{macrocode} |
| 285 |
\cs_new:Nn \@@_construct_font_call:nnnnnn |
| 286 |
{ |
| 287 |
%<XE> " \@@_fontname_wrap:n { #1 #2 #3 } |
| 288 |
%<LU> " \@@_fontname_wrap:n { #1 #2 } #3 |
| 289 |
#4 #5 |
| 290 |
\str_if_eq:eeF {#6}{} {:#6} " |
| 291 |
} |
| 292 |
% \end{macrocode} |
| 293 |
% In practice, we don't use the six-argument version, since most arguments are constructed on-the-fly: |
| 294 |
% \begin{macrocode} |
| 295 |
\cs_new:Nn \@@_construct_font_call:nn |
| 296 |
{ |
| 297 |
\@@_construct_font_call:nnnnnn |
| 298 |
{#1} |
| 299 |
\l_@@_extension_tl |
| 300 |
\l_@@_ttc_index_tl |
| 301 |
\l_@@_renderer_tl |
| 302 |
\l_@@_optical_size_tl |
| 303 |
{#2} |
| 304 |
} |
| 305 |
% \end{macrocode} |
| 306 |
% \end{macro} |
| 307 |
% |
| 308 |
% \begin{macro}{\@@_font_is_file:,\@@_font_is_name:} |
| 309 |
% The \cs{@@_fontname_wrap:n} command takes the font name and either passes it through unchanged or wraps it in the syntax for loading a font `by filename'. |
| 310 |
% For Lua\TeX\ there are two kinds kinds of filename based loading supported: Regular filename lookups which include system fonts and lookups restricted to kpse. |
| 311 |
% \begin{macrocode} |
| 312 |
\cs_new:Nn \@@_font_is_name: |
| 313 |
{ |
| 314 |
%<XE> \cs_set_eq:NN \@@_fontname_wrap:n \use:n |
| 315 |
%<LU> \cs_set:Npn \@@_fontname_wrap:n ##1 { name: ##1 } |
| 316 |
} |
| 317 |
% \end{macrocode} |
| 318 |
% |
| 319 |
% \begin{macrocode} |
| 320 |
\cs_new:Nn \@@_font_is_file: |
| 321 |
{ |
| 322 |
%<debug> \typeout{:: _font_is_file:} |
| 323 |
\bool_set_true:N \l_@@_external_bool |
| 324 |
\bool_lazy_and:nnTF { \l_@@_external_kpse_bool } { \tl_if_empty_p:N \l_@@_font_path_tl } |
| 325 |
{ |
| 326 |
\cs_set:Npn \@@_fontname_wrap:n ##1 { kpse: ##1 } |
| 327 |
} |
| 328 |
{ |
| 329 |
\cs_set:Npn \@@_fontname_wrap:n ##1 { [ \l_@@_font_path_tl ##1 ] } |
| 330 |
} |
| 331 |
} |
| 332 |
% \end{macrocode} |
| 333 |
% \end{macro} |
| 334 |
% |
| 335 |
% \begin{macro}{\@@_set_scriptlang:} |
| 336 |
% Only necessary for OpenType fonts. |
| 337 |
% First check if the font supports scripts, then apply defaults if |
| 338 |
% none are explicitly requested. Similarly with the language settings. |
| 339 |
% \begin{macrocode} |
| 340 |
\cs_new:Nn \@@_set_scriptlang: |
| 341 |
{ |
| 342 |
%<debug> \typeout{:: _set_scriptlang:} |
| 343 |
\bool_if:NT \l_@@_firsttime_bool |
| 344 |
{ |
| 345 |
\tl_if_empty:NF \l_@@_script_name_tl |
| 346 |
{ |
| 347 |
%<debug> \typeout{:::: Script=\l_@@_script_name_tl, Language=\l_@@_lang_name_tl} |
| 348 |
\keys_set:ne {fontspec-opentype} {Script=\l_@@_script_name_tl} |
| 349 |
\keys_set:ne {fontspec-opentype} {Language=\l_@@_lang_name_tl} |
| 350 |
} |
| 351 |
} |
| 352 |
} |
| 353 |
% \end{macrocode} |
| 354 |
% \end{macro} |
| 355 |
% |
| 356 |
% \begin{macro}{\@@_get_features:Nn} |
| 357 |
% This macro is a wrapper for |\keys_set:nn| which expands and adds a |
| 358 |
% default specification to the original passed options. It begins by |
| 359 |
% initialising the commands used to hold font-feature specific |
| 360 |
% strings. |
| 361 |
% Its argument is any additional features to prepend to the default. |
| 362 |
% |
| 363 |
% Do not set the colour if not explicitly spec'd else \verb|\color| (using |
| 364 |
% specials) will not work. |
| 365 |
% \begin{macrocode} |
| 366 |
\cs_new:Nn \@@_get_features:n |
| 367 |
{ |
| 368 |
%<debug> \typeout{:: @@_get_features:Nn { \exp_not:n {#1} } } |
| 369 |
\@@_init_fontface: |
| 370 |
\@@_keys_set_known:nxN {fontspec-renderer} {\l_@@_fontfeat_clist,#1} |
| 371 |
\l_@@_keys_leftover_clist |
| 372 |
\@@_keys_set_known:nxN {fontspec} {\l_@@_keys_leftover_clist} \l_@@_keys_leftover_clist |
| 373 |
%<*XE> |
| 374 |
\bool_if:NTF \l_@@_ot_bool |
| 375 |
{ |
| 376 |
%<debug> \typeout{::: Setting~ keys~ for~ OpenType~ font~ features:~"\l_@@_keys_leftover_clist"} |
| 377 |
\keys_set_known:nV {fontspec-opentype} \l_@@_keys_leftover_clist |
| 378 |
} |
| 379 |
{ |
| 380 |
%<debug> \typeout{::: Setting~ keys~ for~ AAT/Graphite~ font~ features:~"\l_@@_keys_leftover_clist"} |
| 381 |
\bool_if:nT { \l_@@_atsui_bool || \l_@@_graphite_bool } |
| 382 |
{ \keys_set_known:nV {fontspec-aat} \l_@@_keys_leftover_clist } |
| 383 |
} |
| 384 |
%</XE> |
| 385 |
%<*LU> |
| 386 |
%<debug> \typeout{::: Setting~ keys~ for~ OpenType~ font~ features:~"\l_@@_keys_leftover_clist"} |
| 387 |
\keys_set_known:nV {fontspec-opentype} \l_@@_keys_leftover_clist |
| 388 |
%</LU> |
| 389 |
|
| 390 |
\tl_if_empty:NF \l_@@_mapping_tl |
| 391 |
{ \@@_update_featstr:n { mapping = \l_@@_mapping_tl } } |
| 392 |
|
| 393 |
\str_if_eq:eeF { \l_@@_hexcol_tl \l_@@_opacity_tl } |
| 394 |
{ \c_@@_hexcol_tl \c_@@_opacity_tl } |
| 395 |
%<XE> { \@@_update_featstr:n { color = \l_@@_hexcol_tl\l_@@_opacity_tl } } |
| 396 |
%<LU> { \@@_update_featstr:n { color = {\l_@@_hexcol_tl\l_@@_opacity_tl} } } |
| 397 |
} |
| 398 |
% \end{macrocode} |
| 399 |
% \end{macro} |
| 400 |
% |
| 401 |
% \begin{macro}{\@@_save_family_needed:nTF} |
| 402 |
% Check if the family is unique and, if so, save its information. |
| 403 |
% (\cs{addfontfeature} and other macros use this data.) |
| 404 |
% Then the font family and its shapes are defined in the NFSS. |
| 405 |
% |
| 406 |
% Now we have a unique (in fact, too unique!) string that contains |
| 407 |
% the family name and every option in abbreviated form. This is used |
| 408 |
% with a counter to create a simple NFSS family name for the font we're |
| 409 |
% selecting. |
| 410 |
% |
| 411 |
% \begin{macrocode} |
| 412 |
\prg_new_conditional:Nnn \@@_save_family_needed:n { TF } |
| 413 |
{ |
| 414 |
|
| 415 |
%<debug> \typeout{save~ family:~ #1} |
| 416 |
%<debug> \typeout{== fontid_tl: "\l_@@_fontid_tl".} |
| 417 |
|
| 418 |
\tl_if_empty:NTF \l_@@_nfss_fam_tl |
| 419 |
{ |
| 420 |
\prop_get:NVNTF \g_@@_fontid_family_prop \l_@@_fontid_tl \l_@@_tmp_tl |
| 421 |
{ |
| 422 |
\tl_gset_eq:NN \g_@@_nfss_family_tl \l_@@_tmp_tl |
| 423 |
\prg_return_false: |
| 424 |
} |
| 425 |
{ |
| 426 |
\tl_set:Nx \l_@@_tmp_tl {#1} |
| 427 |
\tl_remove_all:Nn \l_@@_tmp_tl { ~ } |
| 428 |
\@@_save_fontid_family:VV \l_@@_fontid_tl \l_@@_tmp_tl |
| 429 |
\prg_return_true: |
| 430 |
} |
| 431 |
} |
| 432 |
{ |
| 433 |
\tl_gset_eq:NN \g_@@_nfss_family_tl \l_@@_nfss_fam_tl |
| 434 |
\cs_undefine:c { g_@@_fontinfo_ \g_@@_nfss_family_tl _prop } |
| 435 |
\prg_return_true: |
| 436 |
} |
| 437 |
} |
| 438 |
% \end{macrocode} |
| 439 |
% \begin{macrocode} |
| 440 |
\cs_new:Nn \@@_save_fontid_family:nn |
| 441 |
{ |
| 442 |
\prop_get:NnNTF \g_@@_family_int_prop {#2} \l_@@_tmp_tl |
| 443 |
{ |
| 444 |
\tl_set:Nx \l_@@_tmp_tl |
| 445 |
{ \int_eval:n { \l_@@_tmp_tl + 1 } } |
| 446 |
} |
| 447 |
{ \tl_set:Nn \l_@@_tmp_tl { 0 } } |
| 448 |
\prop_gput:NnV \g_@@_family_int_prop {#2} \l_@@_tmp_tl |
| 449 |
\tl_gset:Nx \g_@@_nfss_family_tl { #2 ( \l_@@_tmp_tl ) } |
| 450 |
\prop_gput:NnV \g_@@_fontid_family_prop {#1} \g_@@_nfss_family_tl |
| 451 |
} |
| 452 |
\cs_generate_variant:Nn \@@_save_fontid_family:nn { VV } |
| 453 |
% \end{macrocode} |
| 454 |
% \end{macro} |
| 455 |
% |
| 456 |
% \begin{macro}{\@@_save_family:nn} |
| 457 |
% Saves the relevant font information for future processing. |
| 458 |
% \begin{macrocode} |
| 459 |
\cs_new:Nn \@@_save_family:nn |
| 460 |
{ |
| 461 |
\@@_save_fontinfo:n {#2} |
| 462 |
\@@_find_autofonts: |
| 463 |
\DeclareFontFamily{\g_@@_nfss_enc_tl}{\g_@@_nfss_family_tl}{} |
| 464 |
\@@_set_faces: |
| 465 |
\@@_info:nxx {defining-font} {#1} {#2} |
| 466 |
} |
| 467 |
% \end{macrocode} |
| 468 |
% \end{macro} |
| 469 |
% |
| 470 |
% \begin{macro}{\@@_save_fontinfo:n} |
| 471 |
% Saves the relevant font information for future processing. |
| 472 |
% \begin{macrocode} |
| 473 |
\cs_new:Nn \@@_save_fontinfo:n |
| 474 |
{ |
| 475 |
\prop_new:c {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} |
| 476 |
\prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {fontname} { #1 } |
| 477 |
\prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {options} { \l_@@_all_features_clist } |
| 478 |
\prop_gput:cnx {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {fontdef} |
| 479 |
{ |
| 480 |
\@@_construct_font_call:nn {\l_fontspec_fontname_tl} |
| 481 |
{ \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist \@@_get_variations: } |
| 482 |
} |
| 483 |
\prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {script-num} \l_@@_script_int |
| 484 |
\prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {lang-num} \l_@@_language_int |
| 485 |
\prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {script-tag} \l_@@_script_tl |
| 486 |
\prop_gput:cnV {g_@@_fontinfo_ \g_@@_nfss_family_tl _prop} {lang-tag} \l_@@_lang_tl |
| 487 |
} |
| 488 |
% \end{macrocode} |
| 489 |
% \end{macro} |
| 490 |
% |
| 491 |
% \subsection{Setting font shapes in a family} |
| 492 |
% |
| 493 |
% All NFSS specifications take their default values, so if any of them |
| 494 |
% are redefined, the shapes will be selected to fit in with the |
| 495 |
% current state. For example, if \cmd\bfdefault\ is redefined to |b|, all |
| 496 |
% bold shapes defined by this package will also be assigned to |b|. |
| 497 |
% |
| 498 |
% The combination shapes are searched first because they use information that may be redefined in the single cases. |
| 499 |
% E.g., if no bold font is specified then |set_autofont| will attempt to set it. |
| 500 |
% This has subtle/small ramifications on the logic of choosing the bold italic font. |
| 501 |
% |
| 502 |
% \begin{macro}{\@@_find_autofonts:} |
| 503 |
% \begin{macrocode} |
| 504 |
\cs_new:Nn \@@_find_autofonts: |
| 505 |
{ |
| 506 |
\bool_if:nF {\l_@@_noit_bool || \l_@@_nobf_bool} |
| 507 |
{ |
| 508 |
\@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_@@_fontname_it_tl} {/B} |
| 509 |
\@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_@@_fontname_bf_tl} {/I} |
| 510 |
\@@_set_autofont:Nnn \l_@@_fontname_bfit_tl {\l_fontspec_fontname_tl} {/BI} |
| 511 |
} |
| 512 |
|
| 513 |
\bool_if:NF \l_@@_nobf_bool |
| 514 |
{ |
| 515 |
\@@_set_autofont:Nnn \l_@@_fontname_bf_tl {\l_fontspec_fontname_tl} {/B} |
| 516 |
} |
| 517 |
|
| 518 |
\bool_if:NF \l_@@_noit_bool |
| 519 |
{ |
| 520 |
\@@_set_autofont:Nnn \l_@@_fontname_it_tl {\l_fontspec_fontname_tl} {/I} |
| 521 |
} |
| 522 |
|
| 523 |
\@@_set_autofont:Nnn \l_@@_fontname_bfsl_tl {\l_@@_fontname_sl_tl} {/B} |
| 524 |
} |
| 525 |
% \end{macrocode} |
| 526 |
% \end{macro} |
| 527 |
% |
| 528 |
% \begin{macro}{\@@_set_faces:} |
| 529 |
% \begin{macrocode} |
| 530 |
\cs_new:Nn \@@_set_faces: |
| 531 |
{ |
| 532 |
\@@_add_nfssfont:nnnn \mddefault \shapedefault \l_fontspec_fontname_tl \l_@@_fontfeat_up_clist |
| 533 |
\@@_add_nfssfont:nnnn \bfdefault \shapedefault \l_@@_fontname_bf_tl \l_@@_fontfeat_bf_clist |
| 534 |
\@@_add_nfssfont:nnnn \mddefault \itdefault \l_@@_fontname_it_tl \l_@@_fontfeat_it_clist |
| 535 |
\@@_add_nfssfont:nnnn \mddefault \sldefault \l_@@_fontname_sl_tl \l_@@_fontfeat_sl_clist |
| 536 |
\@@_add_nfssfont:nnnn \mddefault \swdefault \l_@@_fontname_sw_tl \l_@@_fontfeat_sw_clist |
| 537 |
\@@_add_nfssfont:nnnn \bfdefault \itdefault \l_@@_fontname_bfit_tl \l_@@_fontfeat_bfit_clist |
| 538 |
\@@_add_nfssfont:nnnn \bfdefault \sldefault \l_@@_fontname_bfsl_tl \l_@@_fontfeat_bfsl_clist |
| 539 |
\@@_add_nfssfont:nnnn \bfdefault \swdefault \l_@@_fontname_bfsw_tl \l_@@_fontfeat_bfsw_clist |
| 540 |
\prop_map_inline:Nn \l_@@_nfssfont_prop { \@@_set_faces_aux:nnnnn ##2 } |
| 541 |
} |
| 542 |
% \end{macrocode} |
| 543 |
% |
| 544 |
% \begin{macrocode} |
| 545 |
\cs_new:Nn \@@_set_faces_aux:nnnnn |
| 546 |
{ |
| 547 |
%<debug> \typeout{:: @@_set_faces_aux:nnnnn \exp_not:n { {#1} {#2} {#3} {#4} {#5} } } |
| 548 |
\fontspec_complete_fontname:Nn \l_@@_curr_fontname_tl {#3} |
| 549 |
\@@_make_font_shapes:Nnnnn \l_@@_curr_fontname_tl {#1} {#2} {#4} {#5} |
| 550 |
} |
| 551 |
% \end{macrocode} |
| 552 |
% \end{macro} |
| 553 |
% |
| 554 |
% \begin{macro}{\fontspec_complete_fontname:Nn} |
| 555 |
% This macro defines |#1| as the input with any |*| tokens of its input |
| 556 |
% replaced by the font name. This lets us define supplementary fonts in full |
| 557 |
% (``\texttt{Baskerville Semibold}'') or in abbreviation (``\texttt{* Semibold}''). |
| 558 |
% \begin{macrocode} |
| 559 |
\cs_new:Nn \fontspec_complete_fontname:Nn |
| 560 |
{ |
| 561 |
\tl_set:Nx #1 {#2} |
| 562 |
\tl_if_in:NnF \l_fontspec_fontname_tl {*} |
| 563 |
{ |
| 564 |
\tl_replace_all:Nne #1 {*} {\l_@@_basename_tl} |
| 565 |
} |
| 566 |
} |
| 567 |
% \end{macrocode} |
| 568 |
% \end{macro} |
| 569 |
% |
| 570 |
% \begin{macro}{\@@_add_nfssfont:nnnn} |
| 571 |
% \darg{series} |
| 572 |
% \darg{shape} |
| 573 |
% \darg{fontname} |
| 574 |
% \darg{fontspec features} |
| 575 |
% \begin{macrocode} |
| 576 |
\cs_new:Nn \@@_add_nfssfont:nnnn |
| 577 |
{ |
| 578 |
\tl_set:Nx \l_@@_this_font_tl {#3} |
| 579 |
|
| 580 |
\tl_if_empty:eTF {#4} |
| 581 |
{ \clist_set:Nn \l_@@_sizefeat_clist {Size={-}} } |
| 582 |
{ \@@_keys_set_known:nxN {fontspec-preparse-nested} {#4} \l_@@_tmp_tl } |
| 583 |
|
| 584 |
\tl_if_empty:NF \l_@@_this_font_tl |
| 585 |
{ |
| 586 |
\prop_put:Nee \l_@@_nfssfont_prop {#1/#2} |
| 587 |
{ {#1}{#2}{\l_@@_this_font_tl}{#4}{\l_@@_sizefeat_clist} } |
| 588 |
} |
| 589 |
} |
| 590 |
% \end{macrocode} |
| 591 |
% \end{macro} |
| 592 |
% |
| 593 |
% |
| 594 |
% \subsubsection{Fonts} |
| 595 |
% |
| 596 |
% \begin{macro}{\@@_set_font_type:N} |
| 597 |
% Now check if the font is to be rendered with \ATSUI\ or Harfbuzz. This will either |
| 598 |
% be automatic (based on the font type), or specified by the user via a font feature. |
| 599 |
% |
| 600 |
% This macro sets booleans |
| 601 |
% accordingly depending if the font in \cmd\l_fontspec_test_font\ is an \AAT\ |
| 602 |
% font or an OpenType font or a font with feature axes (either \AAT\ or |
| 603 |
% Multiple Master), respectively. |
| 604 |
% \begin{macrocode} |
| 605 |
\cs_new:Nn \@@_set_font_type:N |
| 606 |
{ |
| 607 |
%<debug> \typeout{:: @@_set_font_type:} |
| 608 |
%<*XE> |
| 609 |
\bool_set_false:N \l_@@_tfm_bool |
| 610 |
\bool_set_false:N \l_@@_atsui_bool |
| 611 |
\bool_set_false:N \l_@@_ot_bool |
| 612 |
\bool_set_false:N \l_@@_mm_bool |
| 613 |
\bool_set_false:N \l_@@_graphite_bool |
| 614 |
\ifcase\XeTeXfonttype #1 |
| 615 |
%<debug> \typeout{:::: TFM} |
| 616 |
\bool_set_true:N \l_@@_tfm_bool |
| 617 |
\or |
| 618 |
%<debug> \typeout{:::: AAT} |
| 619 |
\bool_set_true:N \l_@@_atsui_bool |
| 620 |
\tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/AAT} } |
| 621 |
\ifnum\XeTeXcountvariations #1 > 0\relax |
| 622 |
%<debug> \typeout{:::: MM} |
| 623 |
\bool_set_true:N \l_@@_mm_bool |
| 624 |
\fi |
| 625 |
\or |
| 626 |
%<debug> \typeout{:::: OpenType} |
| 627 |
\bool_set_true:N \l_@@_ot_bool |
| 628 |
\tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/OT} } |
| 629 |
\or |
| 630 |
%<debug> \typeout{:::: Graphite} |
| 631 |
\bool_set_true:N \l_@@_graphite_bool |
| 632 |
\tl_if_empty:NT \l_@@_renderer_tl { \tl_set:Nn \l_@@_renderer_tl {/GR} } |
| 633 |
\fi |
| 634 |
%</XE> |
| 635 |
% \end{macrocode} |
| 636 |
% If automatic, the \cmd{\l_@@_renderer_tl} token list will still be |
| 637 |
% empty (other suffices that could be added will be later in the feature |
| 638 |
% processing), and if it is indeed still empty, assign it a value so that the |
| 639 |
% other weights of the font are specifically loaded with the same renderer. |
| 640 |
% |
| 641 |
% LuaTeX only supports one: |
| 642 |
% \begin{macrocode} |
| 643 |
%<*LU> |
| 644 |
\bool_set_true:N \l_@@_ot_bool |
| 645 |
%</LU> |
| 646 |
} |
| 647 |
% \end{macrocode} |
| 648 |
% \end{macro} |
| 649 |
% |
| 650 |
% \begin{macro}{\@@_set_autofont:Nnn} |
| 651 |
% \darg{Font name tl} |
| 652 |
% \darg{Base font name} |
| 653 |
% \darg{Font name modifier} |
| 654 |
% |
| 655 |
% This function looks for font with \meta{name} and \meta{modifier} |#2#3|, and if found (i.e., different to font with name |#2|) stores it in tl |#1|. A modifier is something like |/B| to look for a bold font, for example. |
| 656 |
% |
| 657 |
% We can't match external fonts in this way (in \XeTeX\ anyway; todo: test with LuaTeX). |
| 658 |
% If \meta{font name tl} is not empty, then it's already been specified by the user so abort. |
| 659 |
% If \meta{Base font name} is not given, we also abort for obvious reasons. |
| 660 |
% |
| 661 |
% If \meta{font name tl} is empty, then proceed. |
| 662 |
% If not found, \meta{font name tl} remains empty. |
| 663 |
% Otherwise, we have a match. |
| 664 |
% \begin{macrocode} |
| 665 |
\cs_new:Nn \@@_set_autofont:Nnn |
| 666 |
{ |
| 667 |
\bool_if:NF \l_@@_external_bool |
| 668 |
{ |
| 669 |
\tl_if_empty:eF {#2} |
| 670 |
{ |
| 671 |
\tl_if_empty:NT #1 |
| 672 |
{ |
| 673 |
\@@_if_autofont:nnTF {#2} {#3} |
| 674 |
{ \tl_set:Nx #1 {#2#3} } |
| 675 |
{ \@@_info:nx {no-font-shape} {#2#3} } |
| 676 |
} |
| 677 |
} |
| 678 |
} |
| 679 |
} |
| 680 |
% \end{macrocode} |
| 681 |
% |
| 682 |
% \begin{macrocode} |
| 683 |
\prg_new_conditional:Nnn \@@_if_autofont:nn {T,TF} |
| 684 |
{ |
| 685 |
\group_begin: |
| 686 |
\@@_primitive_font_set:Nnn \l_@@_tmpa_font { \@@_construct_font_call:nn {#1} { \l_@@_pre_feat_sclist } } { \f@size pt + 1sp } |
| 687 |
\@@_primitive_font_set:Nnn \l_@@_tmpb_font { \@@_construct_font_call:nn {#1#2} { \l_@@_pre_feat_sclist } } { \f@size pt + 1sp } |
| 688 |
\cs_if_eq:NNTF \l_@@_tmpa_font \l_@@_tmpb_font |
| 689 |
{ \group_end: \prg_return_false: } |
| 690 |
{ \group_end: \prg_return_true: } |
| 691 |
} |
| 692 |
% \end{macrocode} |
| 693 |
% \end{macro} |
| 694 |
% |
| 695 |
% \begin{macro}{\@@_make_font_shapes:Nnnnn} |
| 696 |
% \darg{Font name} |
| 697 |
% \darg{Font series} |
| 698 |
% \darg{Font shape} |
| 699 |
% \darg{Font features} |
| 700 |
% \darg{Size features} |
| 701 |
% This macro eventually uses \cs{DeclareFontShape} to define the font shape in |
| 702 |
% question. |
| 703 |
% \begin{macrocode} |
| 704 |
\cs_new:Nn \@@_make_font_shapes:Nnnnn |
| 705 |
{ |
| 706 |
\group_begin: |
| 707 |
\@@_keys_set_known:nxN {fontspec-preparse-external} { #4 } \l_@@_leftover_clist |
| 708 |
\@@_load_fontname:Nn \l_fontspec_fontname_tl {#1} |
| 709 |
\@@_declare_shape:nnxx {#2} {#3} { \l_@@_fontopts_clist, \l_@@_leftover_clist } {#5} |
| 710 |
\group_end: |
| 711 |
} |
| 712 |
% \end{macrocode} |
| 713 |
% |
| 714 |
% \begin{macrocode} |
| 715 |
\cs_new:Nn \@@_load_fontname:Nn |
| 716 |
{ |
| 717 |
%<debug> \typeout{:: @@_load_fontname:Nn \exp_not:N #1 (#1) {#2} } |
| 718 |
\@@_sanitise_fontname:Nn #1 {#2} |
| 719 |
\@@_load_external_fontoptions:N #1 |
| 720 |
\prop_get:NVNF \g_@@_fontopts_prop #1 \l_@@_fontopts_clist |
| 721 |
{ \clist_clear:N \l_@@_fontopts_clist } |
| 722 |
\keys_set_groups:nnV {fontspec/fontname} {getfontname} \l_@@_fontopts_clist |
| 723 |
\@@_primitive_font_set:OnnF \l_@@_fontface_cs_tl |
| 724 |
{ \@@_construct_font_call:nn {#1} { \l_@@_pre_feat_sclist } } { \f@size pt + 2sp } |
| 725 |
{ \@@_error:nx {font-not-found} {#2} } |
| 726 |
} |
| 727 |
% \end{macrocode} |
| 728 |
% |
| 729 |
% \begin{macrocode} |
| 730 |
\keys_define:nn {fontspec/fontname} |
| 731 |
{ |
| 732 |
Font .tl_set:N = \l_fontspec_fontname_tl , |
| 733 |
Font .groups:n = {getfontname} , |
| 734 |
} |
| 735 |
% \end{macrocode} |
| 736 |
% \end{macro} |
| 737 |
% |
| 738 |
% \begin{macro}{\@@_declare_shape:nnnn} |
| 739 |
% \darg{Font series} |
| 740 |
% \darg{Font shape} |
| 741 |
% \darg{Font features} |
| 742 |
% \darg{Size features} |
| 743 |
% Wrapper for \cmd\DeclareFontShape. |
| 744 |
% And finally the actual font shape declaration using \cmd\l_@@_nfss_tl\ defined above. |
| 745 |
% \cmd\l_@@_postadjust_tl\ is defined in various places to deal with things like the hyphenation |
| 746 |
% character and interword spacing. |
| 747 |
% |
| 748 |
% The main part is to loop through \feat{SizeFeatures} arguments, which are of the form |
| 749 |
% {\par\centering |SizeFeatures={{<one>},{<two>},{<three>}}|.\par} |
| 750 |
% \begin{macrocode} |
| 751 |
\cs_new:Nn \@@_declare_shape:nnnn |
| 752 |
{ |
| 753 |
%<debug>\typeout{=~ declare_shape:~{\l_fontspec_fontname_tl}~{#1}~{#2}} |
| 754 |
\tl_build_begin:N \l_@@_nfss_tl |
| 755 |
\tl_build_begin:N \l_@@_nfss_sc_tl |
| 756 |
\tl_set_eq:NN \l_@@_saved_fontname_tl \l_fontspec_fontname_tl |
| 757 |
|
| 758 |
\exp_args:Nx \clist_map_inline:nn {#4} { \@@_setup_single_size:nn {#3} {##1} } |
| 759 |
|
| 760 |
\tl_build_end:N \l_@@_nfss_tl |
| 761 |
\tl_build_end:N \l_@@_nfss_sc_tl |
| 762 |
|
| 763 |
\@@_declare_shapes_normal:nn {#1} {#2} |
| 764 |
\@@_declare_shapes_smcaps:nn {#1} {#2} |
| 765 |
\@@_declare_shape_slanted:nn {#1} {#2} |
| 766 |
\@@_declare_shapes_bx:nn {#1} {#2} |
| 767 |
\@@_declare_shape_loginfo:nn {#1} {#2} |
| 768 |
} |
| 769 |
% \end{macrocode} |
| 770 |
% |
| 771 |
% \begin{macrocode} |
| 772 |
\cs_generate_variant:Nn \@@_declare_shape:nnnn {nnxx} |
| 773 |
% \end{macrocode} |
| 774 |
% \end{macro} |
| 775 |
% |
| 776 |
% \begin{macro}{\@@_setup_single_size:nn} |
| 777 |
% \begin{macrocode} |
| 778 |
\cs_new:Nn \@@_setup_single_size:nn |
| 779 |
{ |
| 780 |
\tl_clear:N \l_@@_size_tl |
| 781 |
\tl_set_eq:NN \l_@@_sizedfont_tl \l_@@_saved_fontname_tl % in case not spec'ed |
| 782 |
|
| 783 |
\keys_set_known:neN {fontspec-sizing} { \exp_after:wN \use:n #2 } |
| 784 |
\l_@@_sizing_leftover_clist |
| 785 |
\tl_if_empty:NT \l_@@_size_tl { \@@_error:n {no-size-info} } |
| 786 |
%<debug>\typeout{==~ size:~\l_@@_size_tl} |
| 787 |
|
| 788 |
% "normal" |
| 789 |
\@@_load_fontname:Nn \l_fontspec_fontname_tl {\l_@@_sizedfont_tl} |
| 790 |
\@@_setup_nfss:Nn \l_@@_nfss_tl { #1 , \l_@@_sizing_leftover_clist } |
| 791 |
%<debug> \typeout{===~ sized~ font:~ \l_@@_sizedfont_tl} |
| 792 |
|
| 793 |
% small caps |
| 794 |
\clist_set_eq:NN \l_@@_fontfeat_curr_clist \l_@@_fontfeat_sc_clist |
| 795 |
|
| 796 |
\bool_if:NF \l_@@_nosc_bool |
| 797 |
{ |
| 798 |
\tl_if_empty:NTF \l_@@_fontname_sc_tl |
| 799 |
{ |
| 800 |
\@@_make_smallcaps:TF |
| 801 |
{ |
| 802 |
%<debug>\typeout{====~Small~ caps~ found.} |
| 803 |
\clist_put_left:Nn \l_@@_fontfeat_curr_clist {Letters=SmallCaps} |
| 804 |
} |
| 805 |
{ |
| 806 |
%<debug>\typeout{====~Small~ caps~ not~ found.} |
| 807 |
\bool_set_true:N \l_@@_nosc_bool |
| 808 |
} |
| 809 |
} |
| 810 |
{ \@@_load_fontname:Nn \l_fontspec_fontname_tl {\l_@@_fontname_sc_tl} }% local for each size |
| 811 |
} |
| 812 |
|
| 813 |
\bool_if:NF \l_@@_nosc_bool |
| 814 |
{ |
| 815 |
\@@_setup_nfss:Nn \l_@@_nfss_sc_tl |
| 816 |
{#1 , \l_@@_sizing_leftover_clist , \l_@@_fontfeat_curr_clist} |
| 817 |
} |
| 818 |
} |
| 819 |
% \end{macrocode} |
| 820 |
% \end{macro} |
| 821 |
% |
| 822 |
% \begin{macro}{\@@_setup_nfss:Nn} |
| 823 |
% \begin{macrocode} |
| 824 |
\cs_new:Nn \@@_setup_nfss:Nn |
| 825 |
{ |
| 826 |
%<debug>\typeout{====~Setup~NFSS~shape:~<\l_@@_size_tl>~\l_fontspec_fontname_tl} |
| 827 |
%<debug>\typeout{====~Requested~features:~#2} |
| 828 |
|
| 829 |
\@@_get_features:n { #2 } |
| 830 |
|
| 831 |
%<debug>\typeout{====~Gathered~features:~\g_@@_rawfeatures_sclist \@@_get_variations:} |
| 832 |
|
| 833 |
\tl_if_empty:NF \l_@@_scale_tl |
| 834 |
{ |
| 835 |
\tl_set:Nx \l_@@_scale_tl { s*[\l_@@_scale_tl] } |
| 836 |
} |
| 837 |
|
| 838 |
\tl_build_put_right:Nx #1 |
| 839 |
{ |
| 840 |
<\l_@@_size_tl> \l_@@_scale_tl |
| 841 |
\@@_construct_font_call:nn { \l_fontspec_fontname_tl } |
| 842 |
{ \l_@@_pre_feat_sclist \g_@@_rawfeatures_sclist \@@_get_variations: } |
| 843 |
} |
| 844 |
} |
| 845 |
% \end{macrocode} |
| 846 |
% \end{macro} |
| 847 |
% |
| 848 |
% \begin{macro}{\@@_declare_shapes_normal:nn} |
| 849 |
% \begin{macrocode} |
| 850 |
\cs_new:Nn \@@_declare_shapes_normal:nn |
| 851 |
{ |
| 852 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} |
| 853 |
{#1} {#2} {\l_@@_nfss_tl}{\l_@@_postadjust_tl} |
| 854 |
} |
| 855 |
% \end{macrocode} |
| 856 |
% \end{macro} |
| 857 |
% |
| 858 |
% \begin{macro}{\@@_declare_shapes_smcaps:nn} |
| 859 |
% \begin{macrocode} |
| 860 |
\cs_new:Nn \@@_declare_shapes_smcaps:nn |
| 861 |
{ |
| 862 |
\tl_if_empty:NF \l_@@_nfss_sc_tl |
| 863 |
{ |
| 864 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} {#1} |
| 865 |
{ \@@_combo_sc_shape:n {#2} } {\l_@@_nfss_sc_tl} {\l_@@_postadjust_tl} |
| 866 |
} |
| 867 |
} |
| 868 |
% \end{macrocode} |
| 869 |
% |
| 870 |
% \begin{macrocode} |
| 871 |
\cs_new:Nn \@@_combo_sc_shape:n |
| 872 |
{ |
| 873 |
\tl_if_exist:cTF { \@@_shape_merge:nn {#1} {\scdefault} } |
| 874 |
{ \tl_use:c { \@@_shape_merge:nn {#1} {\scdefault} } } |
| 875 |
{ \scdefault#1 } |
| 876 |
} |
| 877 |
% \end{macrocode} |
| 878 |
% \end{macro} |
| 879 |
% |
| 880 |
% \begin{macro}{\@@_DeclareFontShape:nnnnnn} |
| 881 |
% \begin{macrocode} |
| 882 |
\cs_new:Nn \@@_DeclareFontShape:nnnnnn |
| 883 |
{ |
| 884 |
%<debug>\typeout{DeclareFontShape:~{#1}{#2}{#3}{#4}...} |
| 885 |
\group_begin: |
| 886 |
\normalsize |
| 887 |
\cs_undefine:c {#1/#2/#3/#4/\f@size} |
| 888 |
\group_end: |
| 889 |
\DeclareFontShape{#1}{#2}{#3}{#4}{#5}{#6} |
| 890 |
} |
| 891 |
\cs_generate_variant:Nn \@@_DeclareFontShape:nnnnnn {xxxxxx} |
| 892 |
% \end{macrocode} |
| 893 |
% |
| 894 |
% \begin{macro}{\@@_declare_shape_slanted:nn} |
| 895 |
% This extra stuff for the slanted shape substitution is a little bit awkward. |
| 896 |
% We define the slanted shape to be a synonym for it when (a)~we're defining an italic font, but also (b)~when the default slanted shape isn't `it'. |
| 897 |
% (Presumably this turned up once in a test and I realised it caused problems. I doubt this would happen much.) |
| 898 |
% |
| 899 |
% We should test when a slanted font has been specified and not run this code if so, but the \verb|\@@_set_slanted:| code will overwrite this anyway if necessary. |
| 900 |
% \begin{macrocode} |
| 901 |
\cs_new:Nn \@@_declare_shape_slanted:nn |
| 902 |
{ |
| 903 |
\bool_if:nT |
| 904 |
{ |
| 905 |
\str_if_eq_p:ee {#2} {\itdefault} && |
| 906 |
!(\str_if_eq_p:ee {\itdefault} {\sldefault}) |
| 907 |
} |
| 908 |
{ |
| 909 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl}{\g_@@_nfss_family_tl}{#1}{\sldefault} |
| 910 |
{<->ssub*\g_@@_nfss_family_tl/#1/\itdefault}{\l_@@_postadjust_tl} |
| 911 |
} |
| 912 |
} |
| 913 |
% \end{macrocode} |
| 914 |
% \end{macro} |
| 915 |
% |
| 916 |
% \begin{macro}{\@@_declare_shapes_bx:nn} |
| 917 |
% Similar processing for setting up b/bx substitutions. |
| 918 |
% \begin{macrocode} |
| 919 |
\cs_new:Nn \@@_declare_shapes_bx:nn |
| 920 |
{ |
| 921 |
\bool_if:nT |
| 922 |
{ |
| 923 |
\str_if_eq_p:ee {#1} {\bfdefault} && |
| 924 |
!(\str_if_eq_p:ee {\bfdefault} {bx}) |
| 925 |
} |
| 926 |
{ |
| 927 |
% bx/? |
| 928 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} |
| 929 |
{bx} {#2} |
| 930 |
{ <->ssub*\g_@@_nfss_family_tl/\bfdefault/#2 } |
| 931 |
{ \l_@@_postadjust_tl } |
| 932 |
|
| 933 |
% bx/sc -> b/sc |
| 934 |
\tl_if_empty:NF \l_@@_nfss_sc_tl |
| 935 |
{ |
| 936 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} |
| 937 |
{bx} { \@@_combo_sc_shape:n {#2} } |
| 938 |
{ <->ssub*\g_@@_nfss_family_tl/\bfdefault/#2 } |
| 939 |
{ \l_@@_postadjust_tl } |
| 940 |
} |
| 941 |
|
| 942 |
% bx/sl -> bx/it |
| 943 |
\bool_if:nT |
| 944 |
{ |
| 945 |
\str_if_eq_p:ee {#2} {\itdefault} && |
| 946 |
!(\str_if_eq_p:ee {\itdefault} {\sldefault}) |
| 947 |
} |
| 948 |
{ |
| 949 |
\@@_DeclareFontShape:xxxxxx {\g_@@_nfss_enc_tl} {\g_@@_nfss_family_tl} |
| 950 |
{bx} {\sldefault} |
| 951 |
{ <->ssub*\g_@@_nfss_family_tl/bx/\itdefault } |
| 952 |
{ \l_@@_postadjust_tl } |
| 953 |
} |
| 954 |
|
| 955 |
} |
| 956 |
} |
| 957 |
% \end{macrocode} |
| 958 |
% \end{macro} |
| 959 |
% |
| 960 |
% \begin{macro}{\@@_declare_shape_loginfo:nn} |
| 961 |
% Lastly some informative messaging. |
| 962 |
% \begin{macrocode} |
| 963 |
\cs_new:Nn \@@_declare_shape_loginfo:nn |
| 964 |
{ |
| 965 |
\tl_gput_right:Nx \g_@@_defined_shapes_tl |
| 966 |
{ |
| 967 |
\exp_not:n { \\ } |
| 968 |
-~ \exp_not:N \str_case:nn {#1/#2} |
| 969 |
{ |
| 970 |
{\mddefault/\shapedefault} {'normal'~} |
| 971 |
{\bfdefault/\shapedefault} {'bold'~} |
| 972 |
{\mddefault/\itdefault} {'italic'~} |
| 973 |
{\mddefault/\sldefault} {'slanted'~} |
| 974 |
{\mddefault/\swdefault} {'swash'~} |
| 975 |
{\bfdefault/\itdefault} {'bold~ italic'~} |
| 976 |
{\bfdefault/\sldefault} {'bold~ slanted'~} |
| 977 |
{\bfdefault/\swdefault} {'bold~ swash'~} |
| 978 |
} (#1/#2)~ |
| 979 |
with~ NFSS~ spec.:~ |
| 980 |
\l_@@_nfss_tl |
| 981 |
\tl_if_empty:NF \l_@@_nfss_sc_tl |
| 982 |
{ |
| 983 |
\exp_not:n { \\ } |
| 984 |
-~ \exp_not:N \str_case:nn { #1 / \@@_combo_sc_shape:n {#2} } |
| 985 |
{ |
| 986 |
{\mddefault/\scdefault} {'small~ caps'~} |
| 987 |
{\bfdefault/\scdefault} {'bold~ small~ caps'~} |
| 988 |
{\mddefault/\scitdefault} {'italic~ small~ caps'~} |
| 989 |
{\bfdefault/\scitdefault} {'bold~ italic~ small~ caps'~} |
| 990 |
{\mddefault/\scsldefault} {'slanted~ small~ caps'~} |
| 991 |
{\bfdefault/\scsldefault} {'bold~ slanted~ small~ caps'~} |
| 992 |
}~( #1 / \@@_combo_sc_shape:n {#2} )~ |
| 993 |
with~ NFSS~ spec.:~ |
| 994 |
\l_@@_nfss_sc_tl |
| 995 |
\tl_if_empty:fF {\l_@@_postadjust_tl} |
| 996 |
{ |
| 997 |
\exp_not:N \\ and~ font~ adjustment~ code: |
| 998 |
\exp_not:N \\ \l_@@_postadjust_tl |
| 999 |
} |
| 1000 |
} |
| 1001 |
} |
| 1002 |
} |
| 1003 |
% \end{macrocode} |
| 1004 |
% Maybe |\str_if_eq:eeF| would be better? |
| 1005 |
% \end{macro} |
| 1006 |
% |
| 1007 |
% |
| 1008 |
% \subsubsection{Features} |
| 1009 |
% |
| 1010 |
% \begin{macro}{\l_@@_pre_feat_sclist} |
| 1011 |
% These are the features always applied to a font selection before other |
| 1012 |
% features. |
| 1013 |
% \begin{macrocode} |
| 1014 |
\tl_set:Nn \l_@@_pre_feat_sclist |
| 1015 |
%<*XE> |
| 1016 |
{ |
| 1017 |
\bool_if:NT \l_@@_ot_bool |
| 1018 |
{ |
| 1019 |
\tl_if_empty:NF \l_@@_script_tl { script = \l_@@_script_tl ; } |
| 1020 |
\tl_if_empty:NF \l_@@_lang_tl { language = \l_@@_lang_tl ; } |
| 1021 |
} |
| 1022 |
} |
| 1023 |
%</XE> |
| 1024 |
%<*LU> |
| 1025 |
{ |
| 1026 |
mode = \l_@@_mode_tl ; |
| 1027 |
\tl_if_empty:NF \l_@@_shaper_tl { shaper = \l_@@_shaper_tl ; } |
| 1028 |
\tl_if_empty:NF \l_@@_script_tl { script = \l_@@_script_tl ; } |
| 1029 |
\tl_if_empty:NF \l_@@_lang_tl { language = \l_@@_lang_tl ; } |
| 1030 |
} |
| 1031 |
%</LU> |
| 1032 |
% \end{macrocode} |
| 1033 |
% \end{macro} |
| 1034 |
% |
| 1035 |
% |
| 1036 |
% \begin{macro}{\@@_make_smallcaps:TF} |
| 1037 |
% \begin{macro}{\@@_make_ot_smallcaps:TF} |
| 1038 |
% \label{mac:makesmallcaps} |
| 1039 |
% This macro checks if the font contains small caps. |
| 1040 |
% \begin{macrocode} |
| 1041 |
\cs_new:Nn \@@_make_ot_smallcaps:TF |
| 1042 |
{ |
| 1043 |
\bool_set_false:N \l_@@_tmpa_bool |
| 1044 |
\exp_args:Ne \clist_map_inline:nn { \l_@@_lang_tl , \g_@@_default_langs_clist } |
| 1045 |
{ |
| 1046 |
\exp_args:Ne \clist_map_inline:nn { \l_@@_script_tl , \g_@@_default_scripts_clist } |
| 1047 |
{ |
| 1048 |
\exp_args:No \@@_check_ot_feat:NnnnT \l_@@_fontface_cs_tl {smcp} {##1} {####1} |
| 1049 |
{ |
| 1050 |
%<debug>\typeout{SMCP~found~for~script/lang: ####1/##1~-~assuming~okay} |
| 1051 |
\bool_set_true:N \l_@@_tmpa_bool |
| 1052 |
\clist_map_break: |
| 1053 |
} |
| 1054 |
} |
| 1055 |
} |
| 1056 |
\bool_if:NTF \l_@@_tmpa_bool {#1} {#2} |
| 1057 |
} |
| 1058 |
% \end{macrocode} |
| 1059 |
% \begin{macrocode} |
| 1060 |
\cs_new:Nn \@@_make_smallcaps:TF |
| 1061 |
{ |
| 1062 |
\bool_if:NTF \l_@@_ot_bool |
| 1063 |
{ \@@_make_ot_smallcaps:TF {#1} {#2} } |
| 1064 |
{ |
| 1065 |
\bool_if:NT \l_@@_atsui_bool |
| 1066 |
{ |
| 1067 |
\exp_args:No \@@_make_AAT_feature_string:NnnTF |
| 1068 |
\l_@@_fontface_cs_tl {3} {3} {#1} {#2} |
| 1069 |
} |
| 1070 |
} |
| 1071 |
} |
| 1072 |
% \end{macrocode} |
| 1073 |
% \end{macro} |
| 1074 |
% \end{macro} |
| 1075 |
% |
| 1076 |
% \begin{macro}{\@@_update_featstr:n} |
| 1077 |
% \cmd{\g_@@_rawfeatures_sclist} is the string used to define the list of specific |
| 1078 |
% font features. Each time another font feature is requested, this |
| 1079 |
% macro is used to add that feature to the list. Font features are |
| 1080 |
% separated by semicolons. |
| 1081 |
% \begin{macrocode} |
| 1082 |
\cs_new:Nn \@@_update_featstr:n |
| 1083 |
{ |
| 1084 |
%<debug> \typeout{:::: @@_update_featstr:n {#1}} |
| 1085 |
\bool_if:NF \l_@@_firsttime_bool |
| 1086 |
{ |
| 1087 |
\tl_gset:Nx \g_@@_single_feat_tl { #1 } |
| 1088 |
%<debug> \typeout{::::~ Adding~ feature.} |
| 1089 |
\tl_gput_right:Nx \g_@@_rawfeatures_sclist {#1;} |
| 1090 |
} |
| 1091 |
} |
| 1092 |
% \end{macrocode} |
| 1093 |
% \end{macro} |
| 1094 |
% |
| 1095 |
% \begin{macro}{\@@_remove_clashing_featstr:n} |
| 1096 |
% \begin{macrocode} |
| 1097 |
\cs_new:Nn \@@_remove_clashing_featstr:n |
| 1098 |
{ |
| 1099 |
%<debug> \typeout{:::: @@_remove_clashing_featstr:n {#1}} |
| 1100 |
\clist_map_inline:nn {#1} |
| 1101 |
{ |
| 1102 |
%<debug> \typeout{::::~ Removing~ feature~ "##1;"} |
| 1103 |
\tl_gremove_all:Nn \g_@@_rawfeatures_sclist {##1;} |
| 1104 |
} |
| 1105 |
} |
| 1106 |
\cs_generate_variant:Nn \@@_remove_clashing_featstr:n {x} |
| 1107 |
% \end{macrocode} |
| 1108 |
% \end{macro} |
| 1109 |
% |
| 1110 |
% \begin{macro}{\@@_get_variations:} |
| 1111 |
% \cmd{\@@_get_variations:} builds the feature string representing the |
| 1112 |
% current variation instance and/or axis settings. |
| 1113 |
% \begin{macrocode} |
| 1114 |
\cs_generate_variant:Nn \tl_tail:n { e } |
| 1115 |
\cs_new:Nn \@@_format_axis:nn |
| 1116 |
{ |
| 1117 |
, #1 = #2 |
| 1118 |
} |
| 1119 |
\cs_new:Nn \@@_get_variations: |
| 1120 |
{ |
| 1121 |
\tl_if_empty:NF \g_@@_instance_tl |
| 1122 |
{ |
| 1123 |
instance = { \g_@@_instance_tl }; |
| 1124 |
} |
| 1125 |
\prop_if_empty:NF \g_@@_rawvariations_prop |
| 1126 |
{ |
| 1127 |
axis = { |
| 1128 |
\tl_tail:e { |
| 1129 |
\prop_map_function:NN \g_@@_rawvariations_prop \@@_format_axis:nn |
| 1130 |
} |
| 1131 |
}; |
| 1132 |
} |
| 1133 |
} |
| 1134 |
% \end{macrocode} |
| 1135 |
% \end{macro} |
| 1136 |
% |
| 1137 |
% \subsection{Initialisation} |
| 1138 |
% |
| 1139 |
% \begin{macro}{\@@_init:} |
| 1140 |
% Initialisations that need to occur once per fontspec font invocation. |
| 1141 |
% (Some of these may be redundant. |
| 1142 |
% Check whether they're assigned to globally or not.) |
| 1143 |
% \begin{macrocode} |
| 1144 |
\cs_set:Npn \@@_init: |
| 1145 |
{ |
| 1146 |
%<debug> \typeout{:: @@_init:} |
| 1147 |
\bool_set_false:N \l_@@_ot_bool |
| 1148 |
\bool_set_true:N \l_@@_firsttime_bool |
| 1149 |
\@@_font_is_name: |
| 1150 |
\tl_clear:N \l_@@_font_path_tl |
| 1151 |
\tl_clear:N \l_@@_optical_size_tl |
| 1152 |
\tl_clear:N \l_@@_ttc_index_tl |
| 1153 |
\tl_clear:N \l_@@_renderer_tl |
| 1154 |
\tl_gclear:N \g_@@_defined_shapes_tl |
| 1155 |
\tl_gclear:N \g_@@_curr_series_tl |
| 1156 |
\tl_gset_eq:NN \g_@@_nfss_enc_tl \g_fontspec_encoding_tl |
| 1157 |
%<*LU> |
| 1158 |
\tl_set:Nn \l_@@_mode_tl {node} |
| 1159 |
%</LU> |
| 1160 |
} |
| 1161 |
% \end{macrocode} |
| 1162 |
% \end{macro} |
| 1163 |
% |
| 1164 |
% \begin{macro}{\@@_init_fontface:} |
| 1165 |
% Executed in \cs{@@_get_features:Nn}. |
| 1166 |
% \begin{macrocode} |
| 1167 |
\cs_new:Nn \@@_init_fontface: |
| 1168 |
{ |
| 1169 |
\tl_gclear:N \g_@@_rawfeatures_sclist |
| 1170 |
\prop_gclear:N \g_@@_rawvariations_prop |
| 1171 |
\tl_gclear:N \g_@@_instance_tl |
| 1172 |
\tl_clear:N \l_@@_scale_tl |
| 1173 |
\tl_set_eq:NN \l_@@_opacity_tl \c_@@_opacity_tl |
| 1174 |
\tl_set_eq:NN \l_@@_hexcol_tl \c_@@_hexcol_tl |
| 1175 |
\tl_set_eq:NN \l_@@_postadjust_tl \c_@@_postadjust_tl |
| 1176 |
\tl_clear:N \l_@@_wordspace_adjust_tl |
| 1177 |
\tl_clear:N \l_@@_punctspace_adjust_tl |
| 1178 |
} |
| 1179 |
% \end{macrocode} |
| 1180 |
% \end{macro} |
| 1181 |
% |
| 1182 |
% |
| 1183 |
% \subsection{Miscellaneous} |
| 1184 |
% |
| 1185 |
% \begin{macro}{\@@_ot_validate_tag:n} |
| 1186 |
% This macro takes an OpenType tag and validates it. |
| 1187 |
% \begin{macrocode} |
| 1188 |
%<*LU> |
| 1189 |
% \end{macrocode} |
| 1190 |
% \begin{macrocode} |
| 1191 |
\cs_new_protected:Nn \@@_ot_validate_tag:n |
| 1192 |
{ |
| 1193 |
\@@_ot_validate_tag:w #1 \q_nil |
| 1194 |
} |
| 1195 |
\cs_generate_variant:Nn \@@_ot_validate_tag:n {x} |
| 1196 |
% \end{macrocode} |
| 1197 |
% |
| 1198 |
% \begin{macrocode} |
| 1199 |
\cs_set:Npn \@@_ot_validate_tag:w #1 #2 \q_nil |
| 1200 |
{ |
| 1201 |
\bool_if:nTF { \str_if_eq_p:nn {#1} {+} || \str_if_eq_p:nn {#1} {-} } |
| 1202 |
{ \@@_ot_validate_tag_aux:w #2 \c_empty_tl \c_empty_tl \q_nil } |
| 1203 |
{ \@@_ot_validate_tag_aux:w #1#2 \c_empty_tl \c_empty_tl \q_nil } |
| 1204 |
} |
| 1205 |
% \end{macrocode} |
| 1206 |
% |
| 1207 |
% \begin{macrocode} |
| 1208 |
\cs_set:Npn \@@_ot_validate_tag_aux:w #1#2#3#4#5 \q_nil |
| 1209 |
{ |
| 1210 |
\int_compare:nT { \tl_count:n {#5} > 2 } |
| 1211 |
{ \@@_error:nx {ot-tag-too-long} {#1#2#3#4#5} } |
| 1212 |
} |
| 1213 |
% \end{macrocode} |
| 1214 |
% \begin{macrocode} |
| 1215 |
%</LU> |
| 1216 |
% \end{macrocode} |
| 1217 |
% \end{macro} |
| 1218 |
% |
| 1219 |
% \begin{macro}{\@@_iv_str_to_num:Nn} |
| 1220 |
% This macro takes a four character string and converts it to the |
| 1221 |
% numerical representation required for \XeTeX\ OpenType script/language/feature |
| 1222 |
% purposes. The output is stored in |#1|. |
| 1223 |
% |
| 1224 |
% This code is not used in Lua\TeX, as the checking for that engine is done via Lua code |
| 1225 |
% provided by \pkg{luaotfload}. |
| 1226 |
% \begin{macrocode} |
| 1227 |
%<*XE> |
| 1228 |
% \end{macrocode} |
| 1229 |
% |
| 1230 |
% \begin{macrocode} |
| 1231 |
\cs_new:Nn \@@_iv_str_to_num:Nn |
| 1232 |
{ |
| 1233 |
%<debug>\typeout{_iv_str_to_num:~#1~/~#2} |
| 1234 |
\@@_strip_leading_sign:Nw #1#2 \q_nil |
| 1235 |
} |
| 1236 |
\cs_generate_variant:Nn \@@_iv_str_to_num:Nn {Nx} |
| 1237 |
% \end{macrocode} |
| 1238 |
% |
| 1239 |
% The input can be of the form of any of these: |
| 1240 |
% `|abcd|', `|abc|', `|abc |', `|ab|', `|ab |', \etc. |
| 1241 |
% (It is assumed the first two chars are \emph{always} not spaces.) So this macro |
| 1242 |
% reads in the string padded with \cmd\@empty s, |
| 1243 |
% and anything beyond four chars is snipped. The \cmd\@empty s then are used to reconstruct |
| 1244 |
% the spaces in the string to number calculation. |
| 1245 |
% |
| 1246 |
% For backwards compatibility this code also strips a leading |+| or |-|. |
| 1247 |
% |
| 1248 |
% \begin{macrocode} |
| 1249 |
\cs_set:Npn \@@_strip_leading_sign:Nw #1#2#3 \q_nil |
| 1250 |
{ |
| 1251 |
\bool_if:nTF { \str_if_eq_p:nn {#2} {+} || \str_if_eq_p:nn {#2} {-} } |
| 1252 |
{ \@@_iv_str_to_num:w #1 \q_nil #3 \c_empty_tl \c_empty_tl \q_nil } |
| 1253 |
{ \@@_iv_str_to_num:w #1 \q_nil #2#3 \c_empty_tl \c_empty_tl \q_nil } |
| 1254 |
} |
| 1255 |
% \end{macrocode} |
| 1256 |
% If input string (after sign is stripped) is more than 4 chars, \verb|#6| will contain |
| 1257 |
% `\meta{excess}\cs{c_empty_tl}\cs{c_empty_tl}'. Therefore use \verb|#6| to verify string length. |
| 1258 |
% \begin{macrocode} |
| 1259 |
\cs_set:Npn \@@_iv_str_to_num:w #1 \q_nil #2#3#4#5#6 \q_nil |
| 1260 |
{ |
| 1261 |
\int_compare:nT { \tl_count:n {#6} > 2 } |
| 1262 |
{ \@@_error:nx {ot-tag-too-long} {#2#3#4#5#6} } |
| 1263 |
|
| 1264 |
\int_set:Nn #1 |
| 1265 |
{ |
| 1266 |
`#2 * "1000000 |
| 1267 |
+ `#3 * "10000 |
| 1268 |
+ \ifx \c_empty_tl #4 32 \else `#4 \fi * "100 |
| 1269 |
+ \ifx \c_empty_tl #5 32 \else `#5 \fi |
| 1270 |
} |
| 1271 |
} |
| 1272 |
% \end{macrocode} |
| 1273 |
% |
| 1274 |
% \begin{macrocode} |
| 1275 |
%</XE> |
| 1276 |
% \end{macrocode} |
| 1277 |
% \end{macro} |
| 1278 |
% |
| 1279 |
% |
| 1280 |
% \iffalse |
| 1281 |
% \begin{macrocode} |
| 1282 |
%</fontspec> |
| 1283 |
% \end{macrocode} |
| 1284 |
% \fi |
| 1285 |
|
| 1286 |
|
| 1287 |
\endinput |
| 1288 |
|
| 1289 |
% /© |
| 1290 |
% ------------------------------------------------ |
| 1291 |
% The FONTSPEC package <latex3.github.io/fontspec> |
| 1292 |
% ------------------------------------------------ |
| 1293 |
% Copyright 2022-2025 The LaTeX project, LPPL "maintainer" |
| 1294 |
% Copyright 2004-2022 Will Robertson |
| 1295 |
% Copyright 2009-2015 Khaled Hosny |
| 1296 |
% Copyright 2013 Philipp Gesang |
| 1297 |
% Copyright 2013-2016 Joseph Wright |
| 1298 |
% ------------------------------------------------ |
| 1299 |
% This package is free software and may be redistributed and/or modified under |
| 1300 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 1301 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 1302 |
% ------------------------------------------------ |
| 1303 |
% ©/ |