diff options
Diffstat (limited to 'macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx')
-rw-r--r-- | macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx | 130 |
1 files changed, 117 insertions, 13 deletions
diff --git a/macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx b/macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx index bb18912f8a..57ff738183 100644 --- a/macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx +++ b/macros/unicodetex/latex/fontspec/fontspec-code-keyval.dtx @@ -63,7 +63,13 @@ \bool_set_true:N \l_@@_noit_bool \bool_set_true:N \l_@@_external_bool \tl_set:Nn \l_@@_font_path_tl {#1} - \@@_font_is_file: + \bool_lazy_and:nnTF { \l_@@_external_kpse_bool } { \tl_if_empty_p:N \l_@@_font_path_tl } + { + \@@_font_is_kpse: + } + { + \@@_font_is_file: + } %<*XE> \keys_set:nn {fontspec-renderer} {Renderer=OpenType} %</XE> @@ -89,6 +95,22 @@ \@@_keys_define_code:nnn {fontspec} {Extension} {} % \end{macrocode} % +% \paragraph{\feat{KpseOnly}} +% If the font is specified by filename, only search for it through kpse. +% \XeTeX\ does not support finding system fonts by filename so this is always implicitly set +% there. +% \begin{macrocode} +\@@_keys_define_code:nnn {fontspec-preparse-external} {KpseOnly} + { + \bool_set_true:N \l_@@_external_kpse_bool + \bool_if:NT \l_@@_external_bool + { + \@@_font_is_kpse: + } + } +\@@_keys_define_code:nnn {fontspec} {KpseOnly} {} +% \end{macrocode} +% % % \paragraph{\feat{Renderer}} % This feature must be processed before all others (the other font shape and features @@ -463,8 +485,8 @@ % % \paragraph{Scale} % If the input isn't one of the pre-defined string options, then -% it's gotta be numerical. \cs{fontspec_calc_scale:n} does all the work in -% the auto-scaling cases. +% it's gotta be numerical. \cs{fontspec_calc_scale:n} and \cs{fontspec_calc_scale:nn} +% do all the work in the auto-scaling cases. % \begin{macrocode} \@@_keys_define_code:nnn {fontspec} {Scale} { @@ -472,8 +494,10 @@ { {MatchLowercase} { \@@_calc_scale:n {5} } {MatchUppercase} { \@@_calc_scale:n {8} } + {MatchAveragecase} { \@@_calc_scale:nn {5} {8} } } { \tl_set:Nx \l_@@_scale_tl {#1} } + \@@_info:n {set-scale} } % \end{macrocode} % @@ -520,7 +544,6 @@ \dim_to_fp:n {\l_@@_tmpb_dim} } } - \@@_info:n {set-scale} \exp_args:NNNx \group_end: \tl_set:Nx \l_@@_scale_tl { \l_@@_scale_tl } @@ -529,6 +552,26 @@ % \end{macro} % % +% \begin{macro}{\@@_calc_scale:nn} +% This macro calls \cs{fontspec_calc_scale:n} twice +% and then sets the scale to the average of the two results. +% \begin{macrocode} +\cs_new:Nn \@@_calc_scale:nn +{ + \group_begin: + \__fontspec_calc_scale:n {#1} + \tl_set_eq:NN \l_@@_tmp_tl \l_@@_scale_tl + \__fontspec_calc_scale:n {#2} + \tl_set:Nx \l_@@_scale_tl + { + \fp_eval:n { (\l_@@_tmp_tl + \l_@@_scale_tl)/2 } + } + \exp_args:NNNx + \group_end: + \tl_set:Nx \l_@@_scale_tl { \l_@@_scale_tl } + } +% \end{macrocode} +% \end{macro} % \begin{macro}{\@@_set_font_dimen:NnN} % This function sets the dimension |#1| (for font |#3|) to `fontdimen' |#2| % for either font dimension 5 (x-height) or 8 (cap-height). If, for some @@ -675,26 +718,61 @@ % \end{macrocode} % % \paragraph{Color} -% Hooks into pkg{xcolor}, which names its colours \texttt{\char`\\color@<name>}. +% Test first if the color is a named l3color, then if it is a color from +% \pkg{xcolor}, which names its colours \texttt{\char`\\color@<name>}. +% If this fails the argument is assumed to be a hex color. +% % \begin{macrocode} \@@_keys_define_code:nnn {fontspec} {Color} { - \cs_if_exist:cTF { \token_to_str:N \color@ #1 } +%<*XE> + \color_if_exist:nTF {#1} { - \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl + \color_export:nnN {#1} {HTML}\l_@@_hexcol_tl } { - \int_compare:nTF { \tl_count:n {#1} == 6 } - { \tl_set:Nn \l_@@_hexcol_tl {#1} } + \cs_if_exist:cTF { \token_to_str:N \color@ #1 } + { + \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl + } { - \int_compare:nTF { \tl_count:n {#1} == 8 } - { \fontspec_parse_colour:viii #1 } + \int_compare:nTF { \tl_count:n {#1} == 6 } + { \tl_set:Nn \l_@@_hexcol_tl {#1} } { - \bool_if:NF \l_@@_firsttime_bool - { \@@_warning:nx {bad-colour} {#1} } + \int_compare:nTF { \tl_count:n {#1} == 8 } + { \fontspec_parse_colour:viii #1 } + { + \bool_if:NF \l_@@_firsttime_bool + { \@@_warning:nx {bad-colour} {#1} } + } } } } +%</XE> +%<*LU> + \color_if_exist:nTF {#1} + { + \tl_set:Nn \l_@@_hexcol_tl {#1} + } + { + \cs_if_exist:cTF { \token_to_str:N \color@ #1 } + { + \convertcolorspec{named}{#1}{HTML}\l_@@_hexcol_tl + } + { + \int_compare:nTF { \tl_count:n {#1} == 6 } + { \tl_set:Nn \l_@@_hexcol_tl {#1} } + { + \int_compare:nTF { \tl_count:n {#1} == 8 } + { \fontspec_parse_colour:viii #1 } + { + \bool_if:NF \l_@@_firsttime_bool + { \@@_warning:nx {bad-colour} {#1} } + } + } + } + } +%</LU> } % \end{macrocode} % @@ -723,6 +801,7 @@ } \tl_set:Nx \l_@@_opacity_tl { +%<LU> , \int_compare:nT { \l_@@_tmp_int <= "F } {0} % zero pad \int_to_hex:n { \l_@@_tmp_int } } @@ -760,14 +839,21 @@ % \subsubsection{Continuous font axes} % % \begin{macrocode} +%<*XE> \@@_keys_define_code:nnn {fontspec} {Weight} { \@@_update_featstr:n{weight=#1} } +%</XE> +%<LU>\@@_define_opentype_variation_axis:nn {Weight} {wght} +%<*XE> \@@_keys_define_code:nnn {fontspec} {Width} { \@@_update_featstr:n{width=#1} } +%</XE> +%<LU>\@@_define_opentype_variation_axis:nn {Width} {wdth} +\@@_define_opentype_variation_axis:nn {Slant} {slnt} \@@_keys_define_code:nnn {fontspec} {OpticalSize} %<*XE> { @@ -795,6 +881,23 @@ %</LU> % \end{macrocode} % +% For other potentially font specific variation axes, there is a raw setter available: +% \begin{macrocode} +\@@_keys_define_code:nnn {fontspec-opentype} {RawAxis} + { + \prop_gput_from_keyval:Nn \g_@@_rawvariations_prop {#1} + } +% \end{macrocode} +% +% \subsubsection{Variation instances} +% +% \begin{macrocode} +\@@_keys_define_code:nnn {fontspec-opentype} {Instance} + { + \tl_gset:Nn \g_@@_instance_tl {#1} + } +% \end{macrocode} +% % \subsubsection{Font transformations} % These are to be specified to apply directly to a font shape: % \begin{macrocode} @@ -914,6 +1017,7 @@ % ------------------------------------------------ % The FONTSPEC package <wspr.io/fontspec> % ------------------------------------------------ +% Copyright 2022-2023 The LaTeX project % Copyright 2004-2022 Will Robertson, LPPL "maintainer" % Copyright 2009-2015 Khaled Hosny % Copyright 2013 Philipp Gesang |