diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty | 2051 |
1 files changed, 1132 insertions, 919 deletions
diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty b/Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty index a7ef1c9a9ec..4a82ad05de5 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty @@ -14,7 +14,7 @@ %% %% \ProvidesPackage{fontspec-luatex} - [2012/05/06 v2.2b Advanced font selection for XeLaTeX/LuaLaTeX] + [2013/02/25 v2.3 Font selection for XeLaTeX and LuaLaTeX] \ExplSyntaxOn @@ -26,49 +26,58 @@ \tl_set_eq:NN \UTFencname \g_fontspec_encoding_tl % for xunicode \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl -\tl_put_right:Nn \document { +\tl_put_right:Nn \document + { \tl_set_eq:NN \cyrillicencoding \g_fontspec_encoding_tl \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl -} + } \cs_set_eq:NN \fontspec_tmp: \XeTeXpicfile \cs_set:Npn \XeTeXpicfile {} \RequirePackage{xunicode} \cs_set_eq:NN \XeTeXpicfile \fontspec_tmp: -\DeclareDocumentCommand \fontspec { O{} m } { +\DeclareDocumentCommand \fontspec { O{} m } + { \fontencoding {\g_fontspec_encoding_tl} \fontspec_set_family:Nnn \f@family {#1}{#2} \selectfont \ignorespaces -} -\DeclareDocumentCommand \setmainfont { O{} m } { + } +\DeclareDocumentCommand \setmainfont { O{} m } + { \fontspec_set_family:Nnn \rmdefault {#1}{#2} \normalfont -} -\DeclareDocumentCommand \setsansfont { O{} m } { + } +\DeclareDocumentCommand \setsansfont { O{} m } + { \fontspec_set_family:Nnn \sfdefault {#1}{#2} \normalfont -} -\DeclareDocumentCommand \setmonofont { O{} m } { + } +\DeclareDocumentCommand \setmonofont { O{} m } + { \fontspec_set_family:Nnn \ttdefault {#1}{#2} \normalfont -} + } \cs_set_eq:NN \setromanfont \setmainfont \tl_new:N \g_fontspec_mathrm_tl \tl_new:N \g_fontspec_bfmathrm_tl \tl_new:N \g_fontspec_mathsf_tl \tl_new:N \g_fontspec_mathtt_tl -\DeclareDocumentCommand \setmathrm { O{} m } { +\DeclareDocumentCommand \setmathrm { O{} m } + { \fontspec_set_family:Nnn \g_fontspec_mathrm_tl {#1}{#2} -} -\DeclareDocumentCommand \setboldmathrm { O{} m } { + } +\DeclareDocumentCommand \setboldmathrm { O{} m } + { \fontspec_set_family:Nnn \g_fontspec_bfmathrm_tl {#1}{#2} -} -\DeclareDocumentCommand \setmathsf { O{} m } { + } +\DeclareDocumentCommand \setmathsf { O{} m } + { \fontspec_set_family:Nnn \g_fontspec_mathsf_tl {#1}{#2} -} -\DeclareDocumentCommand \setmathtt { O{} m } { + } +\DeclareDocumentCommand \setmathtt { O{} m } + { \fontspec_set_family:Nnn \g_fontspec_mathtt_tl {#1}{#2} -} + } \@onlypreamble\setmathrm \@onlypreamble\setboldmathrm \@onlypreamble\setmathsf @@ -76,318 +85,379 @@ \tl_set:Nn \g_fontspec_mathrm_tl {\rmdefault} \tl_set:Nn \g_fontspec_mathsf_tl {\sfdefault} \tl_set:Nn \g_fontspec_mathtt_tl {\ttdefault} -\DeclareDocumentCommand \newfontfamily { m O{} m } { +\DeclareDocumentCommand \newfontfamily { m O{} m } + { \fontspec_select:nn{#2}{#3} - \use:x { - \exp_not:N \DeclareRobustCommand \exp_not:N #1 { + \use:x + { + \exp_not:N \DeclareRobustCommand \exp_not:N #1 + { \exp_not:N \fontencoding {\g_fontspec_encoding_tl} \exp_not:N \fontfamily {\l_fontspec_family_tl} \exp_not:N \selectfont - } - } -} -\DeclareDocumentCommand \newfontface { m O{} m } { + } + } + } +\DeclareDocumentCommand \newfontface { m O{} m } + { \newfontfamily #1 [ BoldFont={},ItalicFont={},SmallCapsFont={},#2 ] {#3} -} + } \tl_new:N \g_fontspec_default_fontopts_tl -\DeclareDocumentCommand \defaultfontfeatures {m} { +\prop_new:N \g__fontspec_fontopts_prop +\DeclareDocumentCommand \defaultfontfeatures { o m } + { + \IfNoValueTF {#1} + { \__fontspec_set_default_features:n {#2} } + { \__fontspec_set_font_default_features:nn {#1} {#2} } + } +\cs_new:Nn \__fontspec_set_default_features:n + { \tl_set:Nn \g_fontspec_default_fontopts_tl {#1,} -} -\DeclareDocumentCommand \addfontfeatures {m} { + } +\cs_new:Nn \__fontspec_set_font_default_features:nn + { + \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {#1} + \tl_if_empty:nTF {#2} + { \prop_gremove:NV \g__fontspec_fontopts_prop \l__fontspec_tmp_tl } + { \prop_gput:NVn \g__fontspec_fontopts_prop \l__fontspec_tmp_tl {#2} } + } +\cs_new:Nn \__fontspec_sanitise_fontname:Nn + { + \use:x { \tl_to_lowercase:n { \tl_set:Nx \exp_not:N #1 {#2} } } + \tl_remove_all:Nn #1 {~} + \clist_map_inline:Nn \l_fontspec_extensions_clist + { \tl_remove_once:Nn #1 {##1} } + } +\DeclareDocumentCommand \addfontfeatures {m} + { \ifcsname zf@family@fontdef\f@family\endcsname \group_begin: \tl_clear:N \g_fontspec_default_fontopts_tl - \use:x { + \use:x + { \exp_not:N\fontspec_select:nn {\csname zf@family@options\f@family\endcsname,#1} {\csname zf@family@fontname\f@family\endcsname} - } + } \group_end: \fontfamily\l_fontspec_family_tl\selectfont \else \fontspec_warning:n {addfontfeatures-ignored} \fi \ignorespaces -} + } \cs_set_eq:NN \addfontfeature \addfontfeatures \DeclareDocumentCommand \newfontfeature {mm} - { - \keys_define:nn { fontspec } - { - #1 .code:n = { - \fontspec_update_fontid:n {+zf-#1} - \fontspec_update_featstr:n {#2} - } - } - } -\DeclareDocumentCommand \newAATfeature {mmmm} { + { + \keys_define:nn { fontspec } + { + #1 .code:n = + { + \fontspec_update_fontid:n {+zf-#1} + \fontspec_update_featstr:n {#2} + } + } + } +\DeclareDocumentCommand \newAATfeature {mmmm} + { \keys_if_exist:nnF { fontspec } {#1} { \fontspec_define_font_feature:n {#1} } \keys_if_choice_exist:nnnT {fontspec} {#1} {#2} { \fontspec_warning:nxx {feature-option-overwrite}{#1}{#2} } \fontspec_define_feature_option:nnnnn{#1}{#2}{#3}{#4}{} -} -\DeclareDocumentCommand \newICUfeature {mmm} { + } +\DeclareDocumentCommand \newICUfeature {mmm} + { \keys_if_exist:nnF { fontspec / options } {#1} { \fontspec_define_font_feature:n{#1} } \keys_if_choice_exist:nnnT {fontspec} {#1} {#2} { \fontspec_warning:nxx {feature-option-overwrite}{#1}{#2} } \fontspec_define_feature_option:nnnnn{#1}{#2}{}{}{#3} -} + } \cs_set_eq:NN \newopentypefeature \newICUfeature \DeclareDocumentCommand \aliasfontfeature {mm} - { - \keys_if_exist:nnTF {fontspec} {#1} - { - \keys_define:nn {fontspec} - { #2 .code:n = { \keys_set:nn {fontspec} { #1 = {##1} } } } - } - { - \keys_if_exist:nnTF {fontspec-preparse} {#1} + { + \keys_if_exist:nnTF {fontspec} {#1} + { + \keys_define:nn {fontspec} + { #2 .code:n = { \keys_set:nn {fontspec} { #1 = {##1} } } } + } + { + \keys_if_exist:nnTF {fontspec-preparse} {#1} { - \keys_define:nn {fontspec-preparse} - { #2 .code:n = { \keys_set:nn {fontspec-preparse} { #1 = {##1} } } } + \keys_define:nn {fontspec-preparse} + { #2 .code:n = { \keys_set:nn {fontspec-preparse} { #1 = {##1} } } } } { - \keys_if_exist:nnTF {fontspec-preparse-external} {#1} - { - \keys_define:nn {fontspec-preparse-external} + \keys_if_exist:nnTF {fontspec-preparse-external} {#1} + { + \keys_define:nn {fontspec-preparse-external} { - #2 .code:n = - { \keys_set:nn {fontspec-preparse-external} { #1 = {##1} } } + #2 .code:n = + { \keys_set:nn {fontspec-preparse-external} { #1 = {##1} } } } + } + { + \fontspec_warning:nx {rename-feature-not-exist} {#1} + } } - { \fontspec_warning:nx {rename-feature-not-exist} {#1} } - } - } - } + } + } \DeclareDocumentCommand \aliasfontfeatureoption {mmm} - { - \cs_set_eq:cc { \c_keys_code_root_tl fontspec/#1/#3 } - { \c_keys_code_root_tl fontspec/#1/#2 } - } + { \keys_define:nn { fontspec / #1 } { #3 .meta:n = {#2} } } \DeclareDocumentCommand \newfontscript {mm} -{ + { \fontspec_new_script:nn {#1} {#2} \fontspec_new_script:nn {#2} {#2} -} + } \keys_define:nn { fontspec } { Script .choice: } \cs_new:Nn \fontspec_new_script:nn -{ + { \keys_define:nn { fontspec } { Script / #1 .code:n = - \fontspec_check_script:nTF {#2} { + \fontspec_check_script:nTF {#2} + { \fontspec_update_fontid:n {+script=#1} \tl_set:Nn \l_fontspec_script_tl {#2} \int_set:Nn \l_fontspec_script_int {\l_fontspec_strnum_int} - }{ - \fontspec_check_script:nTF {latn} { + } + { + \fontspec_check_script:nTF {latn} + { \fontspec_warning:nx {script-not-exist-latn} {#1} \keys_set:nn {fontspec} {Script=Latin} - }{ + } + { \fontspec_warning:nx {script-not-exist} {#1} - } - } - } -} + } + } + } + } \DeclareDocumentCommand \newfontlanguage {mm} -{ + { \fontspec_new_lang:nn {#1} {#2} \fontspec_new_lang:nn {#2} {#2} -} + } \keys_define:nn { fontspec } { Language .choice: } \cs_new:Nn \fontspec_new_lang:nn -{ + { \keys_define:nn { fontspec } { Language / #1 .code:n = - \fontspec_check_lang:nTF {#2} { + \fontspec_check_lang:nTF {#2} + { \fontspec_update_fontid:n {+lang=#1} \tl_set:Nn \l_fontspec_lang_tl {#2} \int_set:Nn \l_fontspec_language_int {\l_fontspec_strnum_int} - }{ + } + { \fontspec_warning:nx {language-not-exist} {#1} \keys_set:nn { fontspec } { Language = Default } - } + } } -} + } \DeclareDocumentCommand \DeclareFontsExtensions {m} -{ + { \tl_set:Nn \l_fontspec_extensions_clist { #1 } \tl_remove_all:Nn \l_fontspec_extensions_clist {~} -} + } \DeclareFontsExtensions{.otf,.ttf,.OTF,.TTF,.ttc,.TTC,.dfont} -\prg_new_conditional:Nnn \fontspec_if_fontspec_font: {TF,T,F} { - \cs_if_exist:cTF {g_fontspec_ \f@family _prop} { - \prg_return_true: - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_aat_feature:nn {TF,T,F} { - \fontspec_if_fontspec_font:TF { +\prg_new_conditional:Nnn \fontspec_if_fontspec_font: {TF,T,F} + { + \cs_if_exist:cTF {g_fontspec_ \f@family _prop} \prg_return_true: \prg_return_false: + } +\prg_new_conditional:Nnn \fontspec_if_aat_feature:nn {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\use:c{zf@family@fontdef\f@family}} {\f@size pt} - \bool_if:NTF \l_fontspec_atsui_bool { + \bool_if:NTF \l_fontspec_atsui_bool + { \fontspec_make_AAT_feature_string:nnTF {#1}{#2} \prg_return_true: \prg_return_false: - }{ + } + { \prg_return_false: - } - }{ + } + } + { \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_opentype: {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + } +\prg_new_conditional:Nnn \fontspec_if_opentype: {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: \bool_if:NTF \l_fontspec_icu_bool \prg_return_true: \prg_return_false: - }{ + } + { \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_feature:n {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + } +\prg_new_conditional:Nnn \fontspec_if_feature:n {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \int_set:Nv \l_fontspec_script_int {g_fontspec_script_num_(\f@family)_tl} \int_set:Nv \l_fontspec_language_int {g_fontspec_lang_num_(\f@family)_tl} \tl_set:Nv \l_fontspec_script_tl {g_fontspec_script_(\f@family)_tl} \tl_set:Nv \l_fontspec_lang_tl {g_fontspec_lang_(\f@family)_tl} \fontspec_check_ot_feat:nTF {#1} {\prg_return_true:} {\prg_return_false:} - }{ + } + { \prg_return_false: - } - }{ + } + } + { \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_feature:nnn {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + } +\prg_new_conditional:Nnn \fontspec_if_feature:nnn {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \fontspec_iv_str_to_num:Nn \l_fontspec_script_int {#1} \fontspec_iv_str_to_num:Nn \l_fontspec_language_int {#2} \fontspec_check_ot_feat:nTF {#3} \prg_return_true: \prg_return_false: - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_script:n {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\prg_new_conditional:Nnn \fontspec_if_script:n {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \fontspec_check_script:nTF {#1} \prg_return_true: \prg_return_false: - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_language:n {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\prg_new_conditional:Nnn \fontspec_if_language:n {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \tl_set:Nv \l_fontspec_script_tl {g_fontspec_script_(\f@family)_tl} \int_set:Nv \l_fontspec_script_int {g_fontspec_script_num_(\f@family)_tl} \fontspec_check_lang:nTF {#1} \prg_return_true: \prg_return_false: - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_language:nn {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\prg_new_conditional:Nnn \fontspec_if_language:nn {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \tl_set:Nn \l_fontspec_script_tl {#1} \fontspec_iv_str_to_num:Nn \l_fontspec_script_int {#1} \fontspec_check_lang:nTF {#2} \prg_return_true: \prg_return_false: - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_current_script:n {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\prg_new_conditional:Nnn \fontspec_if_current_script:n {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \str_if_eq:nvTF {#1} {g_fontspec_script_(\f@family)_tl} {\prg_return_true:} {\prg_return_false:} - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\prg_new_conditional:Nnn \fontspec_if_current_language:n {TF,T,F} { - \fontspec_if_fontspec_font:TF { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\prg_new_conditional:Nnn \fontspec_if_current_language:n {TF,T,F} + { + \fontspec_if_fontspec_font:TF + { \fontspec_font_set:Nnn \l_fontspec_font {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt} \fontspec_set_font_type: - \bool_if:NTF \l_fontspec_icu_bool { + \bool_if:NTF \l_fontspec_icu_bool + { \str_if_eq:nvTF {#1} {g_fontspec_lang_(\f@family)_tl} {\prg_return_true:} {\prg_return_false:} - }{ - \prg_return_false: - } - }{ - \prg_return_false: - } -} -\cs_new:Nn \fontspec_set_family:Nnn { + } + { \prg_return_false: } + } + { \prg_return_false: } + } +\cs_new:Nn \fontspec_set_family:Nnn + { \fontspec_select:nn {#2}{#3} \tl_set_eq:NN #1 \l_fontspec_family_tl -} + } \cs_new:Nn \fontspec_set_fontface:NNnn - { - \fontspec_select:nn {#3}{#4} - \tl_set_eq:NN #1 \l_fontspec_font - \tl_set_eq:NN #2 \l_fontspec_family_tl - } + { + \fontspec_select:nn {#3}{#4} + \tl_set_eq:NN #1 \l_fontspec_font + \tl_set_eq:NN #2 \l_fontspec_family_tl + } \cs_set:Nn \fontspec_fontwrap:n { "#1" } -\cs_if_free:NT \font_set_eq:NN { +\cs_if_free:NT \font_set_eq:NN + { \cs_set_eq:NN \font_set_eq:NN \tex_let:D - \cs_set:Npn \font_set:Nnn #1#2#3 { + \cs_set:Npn \font_set:Nnn #1#2#3 + { \font #1 = #2 ~at~ #3\scan_stop: - } - \cs_set:Npn \font_gset:Nnn #1#2#3 { + } + \cs_set:Npn \font_gset:Nnn #1#2#3 + { \global \font #1 = #2 ~at~ #3 \scan_stop: - } + } \cs_set:Npn \font_suppress_not_found_error: {\luatexsuppressfontnotfounderror=1} - \prg_set_conditional:Nnn \font_if_null:N {p,TF,T,F} { + \prg_set_conditional:Nnn \font_if_null:N {p,TF,T,F} + { \ifx #1 \nullfont \prg_return_true: \else \prg_return_false: \fi - } -} -\cs_new:Nn \fontspec_font_set:Nnn { + } + } +\cs_new:Nn \fontspec_font_set:Nnn + { \font_set:Nnn #1 {\fontspec_fontwrap:n {#2}} {#3} -} -\cs_new:Nn \fontspec_font_gset:Nnn { + } +\cs_new:Nn \fontspec_font_gset:Nnn + { \font_gset:Nnn #1 {\fontspec_fontwrap:n {#2}} {#3} -} -\prg_new_conditional:Nnn \font_glyph_if_exist:Nn {p,TF,T,F} { + } +\prg_new_conditional:Nnn \font_glyph_if_exist:Nn {p,TF,T,F} + { \etex_iffontchar:D #1 #2 \scan_stop: \prg_return_true: \else: \prg_return_false: \fi: -} -\cs_set:Nn \fontspec_select:nn { + } +\cs_set:Nn \fontspec_select:nn + { \group_begin: \font_suppress_not_found_error: \fontspec_init: @@ -395,7 +465,8 @@ \tl_remove_all:Nn \l_fontspec_fontname_tl {~} \tl_set_eq:NN \l_fontspec_fontid_tl \l_fontspec_fontname_tl \tl_set_eq:NN \l_fontspec_fontname_up_tl \l_fontspec_fontname_tl - \exp_args:NnV \fontspec_preparse_features:nn {#1} \l_fontspec_fontname_tl + \__fontspec_load_external_fontoptions:N \l_fontspec_fontname_tl + \fontspec_preparse_features:nN {#1} \l_fontspec_fontname_tl \fontspec_font_set:Nnn \l_fontspec_font {\fontspec_fullname:n {\l_fontspec_fontname_up_tl}} {\f@size pt} \font_if_null:NT \l_fontspec_font { \fontspec_error:nx {font-not-found} {\l_fontspec_fontname_up_tl} } \fontspec_set_font_type: @@ -404,7 +475,8 @@ \fontspec_set_scriptlang: \fontspec_get_features:n {} \bool_set_false:N \l_fontspec_firsttime_bool - \fontspec_save_family:nT {#2} { + \fontspec_save_family:nT {#2} + { \fontspec_save_fontinfo:nn {#1} {#2} \DeclareFontFamily{\g_fontspec_encoding_tl}{\l_fontspec_family_tl}{} \fontspec_set_upright: @@ -413,19 +485,39 @@ \fontspec_set_slanted: \fontspec_set_bold_italic: \fontspec_set_bold_slanted: - } + } \fontspec_info:nxx {defining-font} {#1} {#2} \group_end: -} -\cs_new:Nn \fontspec_preparse_features:nn { - \fontspec_if_detect_external:nT {#2} + } +\cs_new:Nn \__fontspec_load_external_fontoptions:N + { + \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {#1} + \prop_if_in:NVF \g__fontspec_fontopts_prop {\l__fontspec_tmp_tl} + { + \exp_args:No \file_if_exist:nT {\l__fontspec_tmp_tl.fontspec} + { \file_input:n {\l__fontspec_tmp_tl.fontspec} } + } + } +\cs_new:Nn \fontspec_preparse_features:nN + { + \exp_args:NV \fontspec_if_detect_external:nT #2 { \keys_set:nn {fontspec-preparse-external} {ExternalLocation} } + + \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {\l_fontspec_fontname_tl} + \prop_get:NVN \g__fontspec_fontopts_prop \l__fontspec_tmp_tl \l__fontspec_fontopts_clist \keys_set_known:nxN {fontspec-preparse-external} - {\g_fontspec_default_fontopts_tl #1} \l_fontspec_keys_leftover_clist + { + \g_fontspec_default_fontopts_tl + \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,} + #1 + } + \l_fontspec_keys_leftover_clist \tl_set_eq:NN \l_fontspec_fontname_tl \l_fontspec_fontname_up_tl + \keys_set_known:nxN {fontspec-renderer} {\l_fontspec_keys_leftover_clist} + \l_fontspec_keys_leftover_clist \keys_set_known:nxN {fontspec-preparse} {\l_fontspec_keys_leftover_clist} \l_fontspec_fontfeat_clist -} + } \prg_new_conditional:Nnn \fontspec_if_detect_external:n {T} { \clist_map_inline:Nn \l_fontspec_extensions_clist @@ -436,207 +528,260 @@ } \bool_if:NTF \l_tmpa_bool \prg_return_true: \prg_return_false: } -\cs_set:Nn \fontspec_fullname:n { +\cs_set:Nn \fontspec_fullname:n + { \fontspec_namewrap:n { #1 \l_fontspec_extension_tl } \l_fontspec_renderer_tl \l_fontspec_optical_size_tl -} + } %% Now we have a unique (in fact, too unique!) string that contains -\prg_new_conditional:Nnn \fontspec_save_family:n {T} { +\prg_new_conditional:Nnn \fontspec_save_family:n {T} + { \cs_if_exist:cF {g_fontspec_UID_\l_fontspec_fontid_tl} - { - \cs_if_exist:cTF {g_fontspec_family_#1_int} { - \int_gincr:c {g_fontspec_family_#1_int} - }{ - \int_new:c {g_fontspec_family_#1_int} - } + { + \cs_if_exist:cTF {g_fontspec_family_#1_int} + { \int_gincr:c {g_fontspec_family_#1_int} } + { \int_new:c {g_fontspec_family_#1_int} } \tl_set:Nx \l_fontspec_tmp_tl {#1} \tl_remove_all:Nn \l_fontspec_tmp_tl {~} \tl_gset:cx {g_fontspec_UID_\l_fontspec_fontid_tl} - { - \l_fontspec_tmp_tl ( \int_use:c {g_fontspec_family_#1_int} ) - } - } + { + \l_fontspec_tmp_tl ( \int_use:c {g_fontspec_family_#1_int} ) + } + } \tl_gset:Nv \l_fontspec_family_tl {g_fontspec_UID_\l_fontspec_fontid_tl} \cs_if_exist:cTF {g_fontspec_ \l_fontspec_family_tl _prop} \prg_return_false: \prg_return_true: -} -\cs_new:Nn \fontspec_set_scriptlang: { - \bool_if:NT \l_fontspec_firsttime_bool { - \tl_if_empty:NTF \l_fontspec_script_name_tl { + } +\cs_new:Nn \fontspec_set_scriptlang: + { + \bool_if:NT \l_fontspec_firsttime_bool + { + \tl_if_empty:NTF \l_fontspec_script_name_tl + { \fontspec_check_script:nTF {latn} - { + { \tl_set:Nn \l_fontspec_script_name_tl {Latin} - \tl_if_empty:NT \l_fontspec_lang_name_tl { + \tl_if_empty:NT \l_fontspec_lang_name_tl + { \tl_set:Nn \l_fontspec_lang_name_tl {Default} - } + } \keys_set:nx {fontspec} {Script=\l_fontspec_script_name_tl} \keys_set:nx {fontspec} {Language=\l_fontspec_lang_name_tl} - } - { + } + { \fontspec_info:n {no-scripts} - } - } - { - \tl_if_empty:NT \l_fontspec_lang_name_tl { + } + } + { + \tl_if_empty:NT \l_fontspec_lang_name_tl + { \tl_set:Nn \l_fontspec_lang_name_tl {Default} - } + } \keys_set:nx {fontspec} {Script=\l_fontspec_script_name_tl} \keys_set:nx {fontspec} {Language=\l_fontspec_lang_name_tl} - } - } -} + } + } + } \cs_generate_variant:Nn \prop_gput:Nnn {cnV} \cs_generate_variant:Nn \prop_gput:Nnn {cnx} -\cs_new:Nn \fontspec_save_fontinfo:nn { - +\cs_new:Nn \fontspec_save_fontinfo:nn + { \prop_new:c {g_fontspec_ \l_fontspec_family_tl _prop} \prop_gput:cnx {g_fontspec_ \l_fontspec_family_tl _prop} {fontname} {#2} \prop_gput:cnx {g_fontspec_ \l_fontspec_family_tl _prop} {options} {\g_fontspec_default_fontopts_tl #1} - \prop_gput:cnx {g_fontspec_ \l_fontspec_family_tl _prop} {fontdef} { - \fontspec_fullname:n {\l_fontspec_fontname_tl} : - \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist - } + \prop_gput:cnx {g_fontspec_ \l_fontspec_family_tl _prop} {fontdef} + { + \fontspec_fullname:n {\l_fontspec_fontname_tl} : + \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist + } \prop_gput:cnV {g_fontspec_ \l_fontspec_family_tl _prop} {script-num} \l_fontspec_script_int \prop_gput:cnV {g_fontspec_ \l_fontspec_family_tl _prop} {lang-num} \l_fontspec_language_int \prop_gput:cnV {g_fontspec_ \l_fontspec_family_tl _prop} {script-tag} \l_fontspec_script_tl \prop_gput:cnV {g_fontspec_ \l_fontspec_family_tl _prop} {lang-tag} \l_fontspec_lang_tl - \tl_gset:cx {zf@family@fontname\l_fontspec_family_tl} {#2} - \tl_gset:cx {zf@family@options\l_fontspec_family_tl} {\g_fontspec_default_fontopts_tl #1} - \tl_gset:cx {zf@family@fontdef\l_fontspec_family_tl} { - \fontspec_fullname:n {\l_fontspec_fontname_tl} : - \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist - } - \tl_gset:cV {g_fontspec_script_num_(\l_fontspec_family_tl)_tl} \l_fontspec_script_int - \tl_gset:cV {g_fontspec_lang_num_(\l_fontspec_family_tl)_tl} \l_fontspec_language_int - \tl_gset_eq:cN {g_fontspec_script_(\l_fontspec_family_tl)_tl} \l_fontspec_script_tl - \tl_gset_eq:cN {g_fontspec_lang_(\l_fontspec_family_tl)_tl} \l_fontspec_lang_tl -} -\cs_new:Nn \fontspec_set_upright: { + \tl_gset:cx {zf@family@fontname\l_fontspec_family_tl} {#2} + \tl_gset:cx {zf@family@options\l_fontspec_family_tl} {\g_fontspec_default_fontopts_tl #1} + \tl_gset:cx {zf@family@fontdef\l_fontspec_family_tl} + { + \fontspec_fullname:n {\l_fontspec_fontname_tl} : + \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist + } + \tl_gset:cV {g_fontspec_script_num_(\l_fontspec_family_tl)_tl} \l_fontspec_script_int + \tl_gset:cV {g_fontspec_lang_num_(\l_fontspec_family_tl)_tl} \l_fontspec_language_int + \tl_gset_eq:cN {g_fontspec_script_(\l_fontspec_family_tl)_tl} \l_fontspec_script_tl + \tl_gset_eq:cN {g_fontspec_lang_(\l_fontspec_family_tl)_tl} \l_fontspec_lang_tl + } +\cs_new:Nn \fontspec_set_upright: + { \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_tl \mddefault \updefault \l_fontspec_fontfeat_up_clist -} -\cs_new:Nn \fontspec_set_bold: { - \bool_if:NF \l_fontspec_nobf_bool { - \tl_if_empty:NTF \l_fontspec_fontname_bf_tl { + } +\cs_new:Nn \fontspec_set_bold: + { + \bool_if:NF \l_fontspec_nobf_bool + { + \tl_if_empty:NTF \l_fontspec_fontname_bf_tl + { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/B} \bfdefault \updefault \l_fontspec_fontfeat_bf_clist - }{ + } + { \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bf_tl \bfdefault \updefault \l_fontspec_fontfeat_bf_clist - } - } -} -\cs_new:Nn \fontspec_set_italic: { - \bool_if:NF \l_fontspec_noit_bool { + } + } + } +\cs_new:Nn \fontspec_set_italic: + { + \bool_if:NF \l_fontspec_noit_bool + { \tl_if_empty:NTF \l_fontspec_fontname_it_tl - { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/I} } - { \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_it_tl } - \mddefault \itdefault \l_fontspec_fontfeat_it_clist - } -} + { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/I} } + { \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_it_tl } + \mddefault \itdefault \l_fontspec_fontfeat_it_clist + } + } \cs_new:Nn \fontspec_set_slanted: - { - \tl_if_empty:NF \l_fontspec_fontname_sl_tl - { - \fontspec_make_font_shapes:nnnn - \l_fontspec_fontname_sl_tl \mddefault \sldefault - \l_fontspec_fontfeat_sl_clist - } - } -\cs_new:Nn \fontspec_set_bold_italic: { - \bool_if:nF {\l_fontspec_noit_bool || \l_fontspec_nobf_bool} { + { + \tl_if_empty:NF \l_fontspec_fontname_sl_tl + { + \fontspec_make_font_shapes:nnnn + \l_fontspec_fontname_sl_tl \mddefault \sldefault + \l_fontspec_fontfeat_sl_clist + } + } +\cs_new:Nn \fontspec_set_bold_italic: + { + \bool_if:nF {\l_fontspec_noit_bool || \l_fontspec_nobf_bool} + { \tl_if_empty:NTF \l_fontspec_fontname_bfit_tl - { + { \tl_if_empty:NTF \l_fontspec_fontname_bf_tl - { + { \tl_if_empty:NTF \l_fontspec_fontname_it_tl - { + { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_tl {/BI} - } - { + } + { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_it_tl {/B} - } - } - { + } + } + { \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_bf_tl {/I} - } - } - { + } + } + { \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bfit_tl - } + } \bfdefault \itdefault \l_fontspec_fontfeat_bfit_clist - } -} + } + } \cs_new:Nn \fontspec_set_bold_slanted: - { - \tl_if_empty:NTF \l_fontspec_fontname_bfsl_tl - { - \tl_if_empty:NF \l_fontspec_fontname_sl_tl { - \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_sl_tl {/B} - \bfdefault \sldefault \l_fontspec_fontfeat_bfsl_clist - } - }{ - \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bfsl_tl - \bfdefault \sldefault \l_fontspec_fontfeat_bfsl_clist - } - } + { + \tl_if_empty:NTF \l_fontspec_fontname_bfsl_tl + { + \tl_if_empty:NF \l_fontspec_fontname_sl_tl + { + \fontspec_make_auto_font_shapes:nnnnn \l_fontspec_fontname_sl_tl {/B} + \bfdefault \sldefault \l_fontspec_fontfeat_bfsl_clist + } + } + { + \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bfsl_tl + \bfdefault \sldefault \l_fontspec_fontfeat_bfsl_clist + } + } \cs_new:Nn \fontspec_set_font_type: - { - \bool_set_true:N \l_fontspec_icu_bool - } + { + \bool_set_true:N \l_fontspec_icu_bool + } \cs_new:Nn \fontspec_make_auto_font_shapes:nnnnn - { - \bool_if:NF \l_fontspec_external_bool - { - \fontspec_font_set:Nnn \l_tmpa_font - { \fontspec_fullname:n {#1} } {\f@size pt} - \fontspec_font_set:Nnn \l_tmpb_font - { \fontspec_fullname:n {#1#2} } {\f@size pt} - \str_if_eq:xxTF { \fontname \l_tmpa_font } { \fontname \l_tmpb_font } - { \fontspec_info:nx {no-font-shape} {#1#2} } - { \fontspec_make_font_shapes:nnnn {#1#2}{#3}{#4}{#5} } - } - } + { + \bool_if:NF \l_fontspec_external_bool + { + \fontspec_font_set:Nnn \l_tmpa_font + { \fontspec_fullname:n {#1} } {\f@size pt} + \fontspec_font_set:Nnn \l_tmpb_font + { \fontspec_fullname:n {#1#2} } {\f@size pt} + \str_if_eq_x:nnTF { \fontname \l_tmpa_font } { \fontname \l_tmpb_font } + { \fontspec_info:nx {no-font-shape} {#1#2} } + { \fontspec_make_font_shapes:nnnn {#1#2}{#3}{#4}{#5} } + } + } \cs_new:Nn \fontspec_make_font_shapes:nnnn { \group_begin: - \tl_set:Nx \l_fontspec_fontname_tl {#1} - \fontspec_font_set:Nnn \l_fontspec_font {\fontspec_fullname:n {#1}} {\f@size pt} - \font_if_null:NT \l_fontspec_font { \fontspec_error:nx {font-not-found} {#1} } - \fontspec_declare_shape:nnn {#2}{#3}{#4} - \tl_if_empty:NTF \l_fontspec_fontname_sc_tl { - \bool_if:NF \l_fontspec_nosc_bool { - \fontspec_make_smallcaps:T { + + \__fontspec_load_fontname:n {#1} + \fontspec_declare_shape:nnn {#2}{#3} + { \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,} #4 } + + \tl_if_empty:NTF \l_fontspec_fontname_sc_tl + { + \bool_if:NF \l_fontspec_nosc_bool + { + \fontspec_make_smallcaps:T + { \fontspec_declare_shape:nnn {#2} { \tl_if_eq:NNTF #3 \itdefault \sidefault \scdefault } - { #4 , Letters=SmallCaps, \l_fontspec_fontfeat_sc_clist } - } - } - }{ - \fontspec_font_set:Nnn \l_fontspec_font {\fontspec_fullname:n {\l_fontspec_fontname_sc_tl}} {\f@size pt} - \tl_set:Nx \l_fontspec_fontname_tl {\l_fontspec_fontname_sc_tl} + { + \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,} + #4 , Letters=SmallCaps , \l_fontspec_fontfeat_sc_clist + } + } + } + } + { + \__fontspec_load_fontname:n {\l_fontspec_fontname_sc_tl} \fontspec_declare_shape:nnn {#2} - { \tl_if_eq:NNTF #3 \itdefault \sidefault \scdefault } - { #4 , \l_fontspec_fontfeat_sc_clist } - } + { \tl_if_eq:NNTF #3 \itdefault \sidefault \scdefault } + { + \quark_if_no_value:NF \l__fontspec_fontopts_clist {\l__fontspec_fontopts_clist,} + #4 , \l_fontspec_fontfeat_sc_clist + } + } \group_end: -} -\cs_new:Nn \fontspec_declare_shape:nnn { + } +\cs_new:Nn \__fontspec_load_fontname:n + { + \tl_set:Nx \l_fontspec_fontname_tl {#1} + \__fontspec_load_external_fontoptions:N \l_fontspec_fontname_tl + \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {\l_fontspec_fontname_tl} + \prop_get:NVN \g__fontspec_fontopts_prop \l__fontspec_tmp_tl \l__fontspec_fontopts_clist + \fontspec_font_set:Nnn \l_fontspec_font {\fontspec_fullname:n {\l_fontspec_fontname_tl}} {\f@size pt} + \font_if_null:NT \l_fontspec_font { \fontspec_error:nx {font-not-found} {#1} } + } +\cs_new:Nn \fontspec_declare_shape:nnn + { \clist_if_empty:NTF \l_fontspec_sizefeat_clist - { - \fontspec_get_features:n {#3} - \tl_set:Nx \l_fontspec_nfss_tl { + { \__fontspec_declare_shape_nosizing:n {#3} } + { \__fontspec_declare_shape_withsizing:n {#3} } + \use:x + { + \exp_not:N \DeclareFontShape {\g_fontspec_encoding_tl} {\l_fontspec_family_tl} + {#1} {#2} {\l_fontspec_nfss_tl}{\l_fontspec_postadjust_tl} + } + \__fontspec_declare_shape_slanted:nn {#1} {#2} + \__fontspec_declare_shape_loginfo:nnn {#1} {#2} {#3} + } +\cs_new:Nn \__fontspec_declare_shape_nosizing:n + { + \fontspec_get_features:n {#1} + \tl_set:Nx \l_fontspec_nfss_tl + { <-> \l_fontspec_scale_tl - \fontspec_fontwrap:n { + \fontspec_fontwrap:n + { \fontspec_fullname:n {\l_fontspec_fontname_tl} : \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist - } - } - } - { + } + } + } +\cs_new:Nn \__fontspec_declare_shape_withsizing:n + { \tl_clear:N \l_fontspec_nfss_tl - \clist_map_inline:Nn \l_fontspec_sizefeat_clist { + \clist_map_inline:Nn \l_fontspec_sizefeat_clist + { \tl_clear:N \l_fontspec_size_tl \tl_set_eq:NN \l_fontspec_sizedfont_tl \l_fontspec_fontname_tl @@ -645,35 +790,41 @@ \l_fontspec_keys_leftover_clist \tl_if_empty:NT \l_fontspec_size_tl { \fontspec_error:n {no-size-info} } - \fontspec_get_features:n{ #3 , \l_fontspec_keys_leftover_clist } + \fontspec_get_features:n { #1 , \l_fontspec_keys_leftover_clist } - \tl_put_right:Nx \l_fontspec_nfss_tl { + \tl_put_right:Nx \l_fontspec_nfss_tl + { <\l_fontspec_size_tl> \l_fontspec_scale_tl - \fontspec_fontwrap:n { + \fontspec_fontwrap:n + { \fontspec_fullname:n { \l_fontspec_sizedfont_tl } : \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist - } - } - - } - } - \use:x{ - \exp_not:N\DeclareFontShape{\g_fontspec_encoding_tl}{\l_fontspec_family_tl}{#1}{#2} - {\l_fontspec_nfss_tl}{\l_fontspec_postadjust_tl} - } - \bool_if:nT { - \str_if_eq_p:xx {#2} {\itdefault} && - !(\str_if_eq_p:xx {\itdefault} {\sldefault}) - } - { - \use:x { + } + } + } + } +\cs_new:Nn \__fontspec_declare_shape_slanted:nn + { + \bool_if:nT + { + \str_if_eq_x_p:nn {#2} {\itdefault} && + !(\str_if_eq_x_p:nn {\itdefault} {\sldefault}) + } + { + \use:x + { \exp_not:N \DeclareFontShape {\g_fontspec_encoding_tl}{\l_fontspec_family_tl}{#1}{\sldefault} {<->ssub*\l_fontspec_family_tl/#1/\itdefault}{\l_fontspec_postadjust_tl} - } - } + } + } + } +\cs_new:Nn \__fontspec_declare_shape_loginfo:nnn + { \tl_gput_right:Nx \l_fontspec_defined_shapes_tl - { \exp_not:n { \\ \\ } - *~ '\exp_not:N \prg_case_str:nnn {#1/#2} { + { + \exp_not:n { \\ \\ } + *~ '\exp_not:N \str_case:nnn {#1/#2} + { {\mddefault/\updefault} {normal} {\mddefault/\scdefault} {small~ caps} {\bfdefault/\updefault} {bold} @@ -682,41 +833,48 @@ {\mddefault/\sidefault} {italic~ small~ caps} {\bfdefault/\itdefault} {bold~ italic} {\bfdefault/\sidefault} {bold~ italic~ small~ caps} - } {#2/#3}'~ - with~ NFSS~ spec.: \exp_not:N \\ - \l_fontspec_nfss_tl - \tl_if_empty:NF \l_fontspec_postadjust_tl { - \exp_not:N \\ and~ font~ adjustment~ code: \exp_not:N \\ \l_fontspec_postadjust_tl - } - } -} + } {#2/#3}'~ + with~ NFSS~ spec.: \exp_not:N \\ + \l_fontspec_nfss_tl + \tl_if_empty:NF \l_fontspec_postadjust_tl + { + \exp_not:N \\ and~ font~ adjustment~ code: \exp_not:N \\ \l_fontspec_postadjust_tl + } + } + } \tl_set:Nn \l_fontspec_pre_feat_sclist - { - mode = \l_fontspec_mode_tl ; - \tl_if_empty:NF \l_fontspec_script_tl - { - script = \l_fontspec_script_tl ; - language = \l_fontspec_lang_tl ; - } - } -\cs_new:Nn \fontspec_update_fontid:n { - \bool_if:NT \l_fontspec_firsttime_bool { + { + mode = \l_fontspec_mode_tl ; + \tl_if_empty:NF \l_fontspec_script_tl + { + script = \l_fontspec_script_tl ; + language = \l_fontspec_lang_tl ; + } + } +\cs_new:Nn \fontspec_update_fontid:n + { + \bool_if:NT \l_fontspec_firsttime_bool + { \tl_gput_right:Nx \l_fontspec_fontid_tl {#1} - } -} -\cs_set:Npn \fontspec_get_features:n #1 { + } + } +\cs_set:Nn \fontspec_get_features:n + { \sclist_clear:N \l_fontspec_rawfeatures_sclist \tl_clear:N \l_fontspec_scale_tl \tl_set_eq:NN \l_fontspec_opacity_tl \g_fontspec_opacity_tl \tl_set_eq:NN \l_fontspec_hexcol_tl \g_fontspec_hexcol_tl \tl_clear:N \l_fontspec_postadjust_tl - \keys_set:nx {fontspec} {\l_fontspec_fontfeat_clist, #1} - \str_if_eq:xxF { \l_fontspec_hexcol_tl \l_fontspec_opacity_tl } - { \g_fontspec_hexcol_tl \g_fontspec_opacity_tl } + + \keys_set_known:nxN {fontspec-renderer} {\l_fontspec_fontfeat_clist,#1} + \l_fontspec_keys_leftover_clist + \keys_set:nx {fontspec} {\l_fontspec_keys_leftover_clist} + \str_if_eq_x:nnF { \l_fontspec_hexcol_tl \l_fontspec_opacity_tl } + { \g_fontspec_hexcol_tl \g_fontspec_opacity_tl } { \fontspec_update_featstr:n{color=\l_fontspec_hexcol_tl\l_fontspec_opacity_tl} - } -} + } + } \tl_clear:N \l_fontspec_fontname_bf_tl \tl_clear:N \l_fontspec_fontname_it_tl \tl_clear:N \l_fontspec_fake_slant_tl @@ -741,7 +899,8 @@ \tl_new:N \g_fontspec_opacity_tl \tl_set:Nn \g_fontspec_hexcol_tl {000000} \tl_set:Nn \g_fontspec_opacity_tl {FF~} -\cs_set:Npn \fontspec_init: { +\cs_set:Npn \fontspec_init: + { \bool_set_false:N \l_fontspec_icu_bool \bool_set_true:N \l_fontspec_firsttime_bool \cs_set:Npn \fontspec_namewrap:n ##1 @@ -754,328 +913,345 @@ \luatexposthyphenchar = 0 % fixme \luatexpreexhyphenchar = 0 % fixme \luatexpostexhyphenchar= 0 % fixme -} -\cs_set:Nn \fontspec_make_ot_smallcaps:T { + } +\cs_set:Nn \fontspec_make_ot_smallcaps:T + { \fontspec_check_ot_feat:nT {+smcp} { #1 } -} + } \cs_set_eq:NN \fontspec_make_smallcaps:T \fontspec_make_ot_smallcaps:T \cs_set_eq:NN \sclist_clear:N \tl_clear:N -\cs_new:Nn \sclist_gput_right:Nn { - \tl_gput_right:Nn #1 {#2;} -} +\cs_new:Nn \sclist_gput_right:Nn + { \tl_gput_right:Nn #1 {#2;} } \cs_generate_variant:Nn \sclist_gput_right:Nn {Nx} -\cs_new:Nn \fontspec_update_featstr:n { - \bool_if:NF \l_fontspec_firsttime_bool { +\cs_new:Nn \fontspec_update_featstr:n + { + \bool_if:NF \l_fontspec_firsttime_bool + { \sclist_gput_right:Nx \l_fontspec_rawfeatures_sclist {#1} - } -} + } + } \cs_new:Nn \fontspec_make_feature:nnn - { - \fontspec_make_ICU_feature:n {#3} - } + { \fontspec_make_ICU_feature:n {#3} } \cs_generate_variant:Nn \fontspec_make_feature:nnn {nnx} -\cs_new:Nn \fontspec_make_AAT_feature:nn { +\cs_new:Nn \fontspec_make_AAT_feature:nn + { \tl_if_empty:nTF {#1} - { \fontspec_warning:n {aat-feature-not-exist} } - { - \fontspec_make_AAT_feature_string:nnTF {#1}{#2} - { - \fontspec_update_fontid:n {+#1,#2} - \fontspec_update_featstr:n {\l_fontspec_feature_string_tl} - } - { \fontspec_warning:nx {aat-feature-not-exist-in-font} {#1,#2} } - } -} -\cs_new:Nn \fontspec_make_ICU_feature:n { + { \fontspec_warning:n {aat-feature-not-exist} } + { + \fontspec_make_AAT_feature_string:nnTF {#1}{#2} + { + \fontspec_update_fontid:n {+#1,#2} + \fontspec_update_featstr:n {\l_fontspec_feature_string_tl} + } + { \fontspec_warning:nx {aat-feature-not-exist-in-font} {#1,#2} } + } + } +\cs_new:Nn \fontspec_make_ICU_feature:n + { \tl_if_empty:nTF {#1} - { \fontspec_warning:n {icu-feature-not-exist} } - { - \fontspec_check_ot_feat:nTF {#1} - { - \fontspec_update_fontid:n {#1} - \fontspec_update_featstr:n{#1} - } - { \fontspec_warning:nx {icu-feature-not-exist-in-font} {#1} } - } -} + { \fontspec_warning:n {icu-feature-not-exist} } + { + \fontspec_check_ot_feat:nTF {#1} + { + \fontspec_update_fontid:n {#1} + \fontspec_update_featstr:n{#1} + } + { \fontspec_warning:nx {icu-feature-not-exist-in-font} {#1} } + } + } \cs_new_protected:Nn \fontspec_make_numbered_feature:nn - { - \fontspec_check_ot_feat:nTF {#1} - { - \fontspec_update_fontid:n {#1=#2} + { + \fontspec_check_ot_feat:nTF {#1} + { + \fontspec_update_fontid:n {#1=#2} \fontspec_update_featstr:n { #1 = \int_eval:n {#2+1} } - } - { \fontspec_warning:nx {icu-feature-not-exist-in-font} {#1} } - } + } + { \fontspec_warning:nx {icu-feature-not-exist-in-font} {#1} } + } \cs_generate_variant:Nn \fontspec_make_numbered_feature:nn {xn} -\cs_new:Nn \fontspec_define_font_feature:n { +\cs_new:Nn \fontspec_define_font_feature:n + { \keys_define:nn {fontspec} { #1 .multichoice: } -} -\cs_new:Nn \fontspec_define_feature_option:nnnnn { - \keys_define:nn {fontspec} { + } +\cs_new:Nn \fontspec_define_feature_option:nnnnn + { + \keys_define:nn {fontspec} + { #1/#2 .code:n = { \fontspec_make_feature:nnn{#3}{#4}{#5} } - } -} + } + } \cs_new:Nn \fontspec_define_numbered_feat:nnnn - { - \keys_define:nn {fontspec} - { - #1/#2 .code:n = - { \fontspec_make_numbered_feature:nn {#3}{#4} } - } - } -\prg_new_conditional:Nnn \fontspec_make_AAT_feature_string:nn {TF,T,F} { + { + \keys_define:nn {fontspec} + { + #1/#2 .code:n = + { \fontspec_make_numbered_feature:nn {#3}{#4} } + } + } +\prg_new_conditional:Nnn \fontspec_make_AAT_feature_string:nn {TF,T,F} + { \tl_set:Nx \l_tmpa_tl { \XeTeXfeaturename \l_fontspec_font #1 } \tl_if_empty:NTF \l_tmpa_tl - { \prg_return_false: } - { + { \prg_return_false: } + { \int_compare:nTF { \XeTeXisexclusivefeature\l_fontspec_font #1 > 0 } - { + { \tl_set:Nx \l_tmpb_tl {\XeTeXselectorname\l_fontspec_font #1\space #2} - }{ + } + { \int_if_even:nTF {#2} - { + { \tl_set:Nx \l_tmpb_tl {\XeTeXselectorname\l_fontspec_font #1\space #2} - }{ - \tl_set:Nx \l_tmpb_tl { + } + { + \tl_set:Nx \l_tmpb_tl + { \XeTeXselectorname\l_fontspec_font #1\space \numexpr#2-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: } - { + { \prg_return_false: } + { \tl_set:Nx \l_fontspec_feature_string_tl { \l_tmpa_tl = \l_tmpb_tl } \prg_return_true: - } - } -} -\cs_set:Npn \fontspec_iv_str_to_num:Nn #1#2 { + } + } + } +\cs_set:Nn \fontspec_iv_str_to_num:Nn + { \fontspec_iv_str_to_num:w #1 \q_nil #2 \c_empty_tl \c_empty_tl \q_nil -} -\cs_set:Npn \fontspec_iv_str_to_num:w #1 \q_nil #2#3#4#5#6 \q_nil { - \int_set:Nn #1 { + } +\cs_set:Npn \fontspec_iv_str_to_num:w #1 \q_nil #2#3#4#5#6 \q_nil + { + \int_set:Nn #1 + { `#2 * "1000000 + `#3 * "10000 + \ifx \c_empty_tl #4 32 \else `#4 \fi * "100 + \ifx \c_empty_tl #5 32 \else `#5 \fi - } -} + } + } \cs_generate_variant:Nn \fontspec_iv_str_to_num:Nn {No} -\cs_set:Npn \fontspec_v_str_to_num:Nn #1#2 { +\cs_set:Nn \fontspec_v_str_to_num:Nn + { \bool_if:nTF - { - \tl_if_head_eq_charcode_p:nN {#2} {+} || - \tl_if_head_eq_charcode_p:nN {#2} {-} - } - { \fontspec_iv_str_to_num:No #1 { \use_none:n #2 } } - { \fontspec_iv_str_to_num:Nn #1 {#2} } -} + { + \tl_if_head_eq_charcode_p:nN {#2} {+} || + \tl_if_head_eq_charcode_p:nN {#2} {-} + } + { \fontspec_iv_str_to_num:No #1 { \use_none:n #2 } } + { \fontspec_iv_str_to_num:Nn #1 {#2} } + } \prg_new_conditional:Nnn \fontspec_check_script:n {TF} - { - \directlua{fontspec.check_ot_script("l_fontspec_font", "#1")} - \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: - } + { + \directlua{fontspec.check_ot_script("l_fontspec_font", "#1")} + \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: + } \prg_new_conditional:Nnn \fontspec_check_lang:n {TF} - { - \directlua{ - fontspec.check_ot_lang( "l_fontspec_font", "#1", "\l_fontspec_script_tl" ) - } - \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: - } + { + \directlua + { + fontspec.check_ot_lang( "l_fontspec_font", "#1", "\l_fontspec_script_tl" ) + } + \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: + } \prg_new_conditional:Nnn \fontspec_check_ot_feat:n {TF,T} - { - \directlua{ - fontspec.check_ot_feat( - "l_fontspec_font", "#1", - "\l_fontspec_lang_tl", "\l_fontspec_script_tl" - ) - } - \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: - } + { + \directlua + { + fontspec.check_ot_feat( + "l_fontspec_font", "#1", + "\l_fontspec_lang_tl", "\l_fontspec_script_tl" + ) + } + \if@tempswa \prg_return_true: \else: \prg_return_false: \fi: + } +\cs_new:Nn \__fontspec_keys_define_code:nnn + { + \keys_define:nn {#1} { #2 .code:n = {#3} } + } \bool_new:N \l_fontspec_external_bool -\keys_define:nn {fontspec-preparse-external} { - ExternalLocation .code:n = { +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {ExternalLocation} + { \bool_set_true:N \l_fontspec_nobf_bool \bool_set_true:N \l_fontspec_noit_bool \bool_set_true:N \l_fontspec_external_bool \cs_gset:Npn \fontspec_namewrap:n ##1 - { file: #1 ##1 } - } -} + { file: #1 ##1 } + } \aliasfontfeature{ExternalLocation}{Path} -\keys_define:nn {fontspec-preparse-external} { - Extension .code:n = { +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {Extension} + { \tl_set:Nn \l_fontspec_extension_tl {#1} - \bool_if:NF \l_fontspec_external_bool { + \bool_if:NF \l_fontspec_external_bool + { \keys_set:nn {fontspec-preparse-external} {ExternalLocation} - } -} -} + } + } \tl_clear:N \l_fontspec_extension_tl -\keys_define:nn {fontspec-preparse} { - Renderer .choice_code:n = { +\keys_define:nn {fontspec-renderer} + { + Renderer .choice_code:n = + { \fontspec_update_fontid:n {+rend:\l_keys_choice_tl} - \int_compare:nTF {\l_keys_choice_int < 3} { + \int_compare:nTF {\l_keys_choice_int <= 3} { \fontspec_warning:nx {only-xetex-feature} {Renderer=AAT/ICU/Graphite} - }{ + } + { \tl_set:Nv \l_fontspec_mode_tl { g_fontspec_mode_tag_ \l_keys_choice_tl } - } - } + } + } , Renderer .generate_choices:n = {AAT,ICU,Graphite,Full,Basic} -} + } \tl_set:cn {g_fontspec_renderer_tag_AAT} {/AAT} \tl_set:cn {g_fontspec_renderer_tag_ICU} {/ICU} \tl_set:cn {g_fontspec_renderer_tag_Graphite} {/GR} \tl_set:cn {g_fontspec_mode_tag_Full} {node} \tl_set:cn {g_fontspec_mode_tag_Basic} {base} -\keys_define:nn {fontspec-preparse} { Script .code:n = { +\__fontspec_keys_define_code:nnn {fontspec-preparse} {Script} + { \tl_set:Nn \l_fontspec_script_name_tl {#1} \fontspec_update_fontid:n {+script:#1} - } -} -\keys_define:nn {fontspec-preparse} { Language .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {Language} + { \tl_set:Nn \l_fontspec_lang_name_tl {#1} \fontspec_update_fontid:n {+language:#1} - } -} -\keys_define:nn {fontspec-preparse-external} { UprightFont .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {UprightFont} + { \fontspec_complete_fontname:Nn \l_fontspec_fontname_up_tl {#1} \fontspec_update_fontid:n {up:#1} - } -} -\keys_define:nn {fontspec-preparse-external} { BoldFont .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {BoldFont} + { \tl_if_empty:nTF {#1} - { + { \bool_set_true:N \l_fontspec_nobf_bool \fontspec_update_fontid:n {nobf} - } - { + } + { \bool_set_false:N \l_fontspec_nobf_bool \fontspec_complete_fontname:Nn \l_fontspec_fontname_bf_tl {#1} \fontspec_update_fontid:n {bf:#1} - } - } -} -\keys_define:nn {fontspec-preparse-external} { ItalicFont .code:n = { + } + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {ItalicFont} + { \tl_if_empty:nTF {#1} - { + { \bool_set_true:N \l_fontspec_noit_bool \fontspec_update_fontid:n {noit} - }{ + } + { \bool_set_false:N \l_fontspec_noit_bool \fontspec_complete_fontname:Nn \l_fontspec_fontname_it_tl {#1} \fontspec_update_fontid:n {it:#1} - } - } -} -\keys_define:nn {fontspec-preparse-external} { BoldItalicFont .code:n = { + } + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {BoldItalicFont} + { \fontspec_complete_fontname:Nn \l_fontspec_fontname_bfit_tl {#1} \fontspec_update_fontid:n {bfit:#1} - } -} -\keys_define:nn {fontspec-preparse-external} - { - SlantedFont .code:n = - { - \fontspec_complete_fontname:Nn \l_fontspec_fontname_sl_tl {#1} - \fontspec_update_fontid:n {sl:#1} - } - } -\keys_define:nn {fontspec-preparse-external} { BoldSlantedFont .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {SlantedFont} + { + \fontspec_complete_fontname:Nn \l_fontspec_fontname_sl_tl {#1} + \fontspec_update_fontid:n {sl:#1} + } +\__fontspec_keys_define_code:nnn {fontspec-preparse-external} {BoldSlantedFont} + { \fontspec_complete_fontname:Nn \l_fontspec_fontname_bfsl_tl {#1} \fontspec_update_fontid:n {bfsl:#1} - } -} -\keys_define:nn {fontspec} { SmallCapsFont .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec} {SmallCapsFont} + { \tl_if_empty:nTF {#1} - { + { \bool_set_true:N \l_fontspec_nosc_bool \fontspec_update_fontid:n {nosc} - }{ + } + { \bool_set_true:N \l_fontspec_nosc_bool \fontspec_complete_fontname:Nn \l_fontspec_fontname_sc_tl {#1} \fontspec_update_fontid:n {sc:#1} - } - } -} -\cs_set:Npn \fontspec_complete_fontname:Nn #1#2 { + } + } +\cs_set:Nn \fontspec_complete_fontname:Nn + { \tl_set:Nn #1 {#2} \tl_replace_all:Nnx #1 {*} {\l_fontspec_fontname_tl} \tl_remove_all:Nn #1 {~} -} + } \cs_generate_variant:Nn \tl_replace_all:Nnn {Nnx} -\keys_define:nn {fontspec-preparse} { UprightFeatures .code:n = { +\__fontspec_keys_define_code:nnn {fontspec-preparse} {UprightFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_up_clist { , #1} \fontspec_update_fontid:n {rmfeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { BoldFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {BoldFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_bf_clist {, #1} \fontspec_update_fontid:n {bffeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { ItalicFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {ItalicFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_it_clist {, #1} \fontspec_update_fontid:n {itfeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { BoldItalicFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {BoldItalicFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_bfit_clist {, #1} \fontspec_update_fontid:n {bfitfeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { SlantedFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {SlantedFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_sl_clist {, #1} \fontspec_update_fontid:n {slfeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { BoldSlantedFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {BoldSlantedFeatures} + { \tl_set:Nn \l_fontspec_fontfeat_bfsl_clist {, #1} \fontspec_update_fontid:n {bfslfeat:#1} - } -} -\keys_define:nn {fontspec} { SmallCapsFeatures .code:n = { - \bool_if:NF \l_fontspec_firsttime_bool { + } +\__fontspec_keys_define_code:nnn {fontspec} {SmallCapsFeatures} + { + \bool_if:NF \l_fontspec_firsttime_bool + { \tl_set:Nn \l_fontspec_fontfeat_sc_clist {, #1} - } + } \fontspec_update_fontid:n {scfeat:#1} - } -} -\keys_define:nn {fontspec-preparse} { SizeFeatures .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec-preparse} {SizeFeatures} + { \tl_set:Nn \l_fontspec_sizefeat_clist {#1} \fontspec_update_fontid:n {sizefeat:#1} - } -} -\keys_define:nn {fontspec-sizing} - { - Size .code:n = - { - \tl_set:Nn \l_fontspec_size_tl {#1} - } - } -\keys_define:nn {fontspec-sizing} - { - Font .code:n = - { - \fontspec_complete_fontname:Nn \l_fontspec_sizedfont_tl {#1} - } - } -\keys_define:nn {fontspec} { Scale .code:n = { - \prg_case_str:nnn {#1} - { + } +\__fontspec_keys_define_code:nnn {fontspec-sizing} {Size} + { + \tl_set:Nn \l_fontspec_size_tl {#1} + } +\__fontspec_keys_define_code:nnn {fontspec-sizing} {Font} + { + \fontspec_complete_fontname:Nn \l_fontspec_sizedfont_tl {#1} + } +\__fontspec_keys_define_code:nnn {fontspec} {Scale} + { + \str_case:nnn {#1} + { {MatchLowercase} { \fontspec_calc_scale:n {5} } {MatchUppercase} { \fontspec_calc_scale:n {8} } - } - { \tl_set:Nx \l_fontspec_scale_tl {#1} } + } + { \tl_set:Nx \l_fontspec_scale_tl {#1} } \fontspec_update_fontid:n {+scale:\l_fontspec_scale_tl} \tl_set:Nx \l_fontspec_scale_tl { s*[\l_fontspec_scale_tl] } - } -} -\cs_new:Nn \fontspec_calc_scale:n { + } +\cs_new:Nn \fontspec_calc_scale:n + { \group_begin: \rmfamily \fontspec_set_font_dimen:NnN \l_fontspec_tmpa_dim {#1} \font @@ -1086,223 +1262,234 @@ \tl_gset:Nx \l_fontspec_scale_tl { \fp_use:N \l_fontspec_tmpa_fp } \fontspec_info:n {set-scale} \group_end: -} + } \cs_new:Nn \fontspec_set_font_dimen:NnN -{ + { \dim_set:Nn #1 { \fontdimen #2 #3 } - \dim_compare:nNnT #1 = {0pt} { - \settoheight #1 { + \dim_compare:nNnT #1 = {0pt} + { + \settoheight #1 + { \str_if_eq:nnTF {#3} {\font} \rmfamily #3 - \prg_case_int:nnn #2 { - {5} {x} % x-height - {8} {X} % cap-height - } {?} % "else" clause; never reached. - } - } -} -\keys_define:nn {fontspec} { WordSpace .code:n = { + \int_case:nnn #2 + { + {5} {x} % x-height + {8} {X} % cap-height + } {?} % "else" clause; never reached. + } + } + } +\__fontspec_keys_define_code:nnn {fontspec} {WordSpace} + { \fontspec_update_fontid:n {+wordspace:#1} - \bool_if:NF \l_fontspec_firsttime_bool { - \_fontspec_parse_wordspace:w #1,,,\q_stop - } - } -} -\cs_set:Npn \_fontspec_parse_wordspace:w #1,#2,#3,#4 \q_stop { + \bool_if:NF \l_fontspec_firsttime_bool + { \_fontspec_parse_wordspace:w #1,,,\q_stop } + } +\cs_set:Npn \_fontspec_parse_wordspace:w #1,#2,#3,#4 \q_stop + { \tl_if_empty:nTF {#4} - { - \tl_put_right:Nn \l_fontspec_postadjust_tl { + { + \tl_put_right:Nn \l_fontspec_postadjust_tl + { \fontdimen 2 \font = #1 \fontdimen 2 \font \fontdimen 3 \font = #1 \fontdimen 3 \font \fontdimen 4 \font = #1 \fontdimen 4 \font - } - }{ - \tl_put_right:Nn \l_fontspec_postadjust_tl { + } + } + { + \tl_put_right:Nn \l_fontspec_postadjust_tl + { \fontdimen 2 \font = #1 \fontdimen 2 \font \fontdimen 3 \font = #2 \fontdimen 3 \font \fontdimen 4 \font = #3 \fontdimen 4 \font - } - } -} -\keys_define:nn {fontspec} - { - PunctuationSpace .code:n = - { - \fontspec_update_fontid:n {+punctspace:#1} - \tl_put_right:Nx \l_fontspec_postadjust_tl - { \fontdimen 7 \font = #1 \fontdimen 7 \font } - } - } -\keys_define:nn {fontspec} { FontAdjustment .code:n = { + } + } + } +\__fontspec_keys_define_code:nnn {fontspec} {PunctuationSpace} + { + \fontspec_update_fontid:n {+punctspace:#1} + \tl_put_right:Nx \l_fontspec_postadjust_tl + { \fontdimen 7 \font = #1 \fontdimen 7 \font } + } +\__fontspec_keys_define_code:nnn {fontspec} {FontAdjustment} + { \fontspec_update_fontid:n {+fontadjust:\detokenize{#1}} \tl_put_right:Nx \l_fontspec_postadjust_tl {#1} - } -} -\keys_define:nn {fontspec} { LetterSpace .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec} {LetterSpace} + { \fontspec_update_fontid:n {+tracking:#1} \fontspec_update_featstr:n{letterspace=#1} - } -} -\keys_define:nn {fontspec} { HyphenChar .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec} {HyphenChar} + { \fontspec_update_fontid:n {+hyphenchar:#1} \str_if_eq:nnTF {#1} {None} - { + { \tl_put_right:Nn \l_fontspec_postadjust_tl { \hyphenchar \font = \c_minus_one } - } - { + } + { \tl_if_single:nTF {#1} - { \tl_set:Nn \l_fontspec_hyphenchar_tl {`#1} } - { \tl_set:Nn \l_fontspec_hyphenchar_tl { #1} } + { \tl_set:Nn \l_fontspec_hyphenchar_tl {`#1} } + { \tl_set:Nn \l_fontspec_hyphenchar_tl { #1} } \font_glyph_if_exist:NnTF \l_fontspec_font {\l_fontspec_hyphenchar_tl} - { + { \tl_put_right:Nn \l_fontspec_postadjust_tl { \hyphenchar \font = \c_zero \luatexprehyphenchar = \l_fontspec_hyphenchar_tl \scan_stop: } - } - { \fontspec_error:nx {no-glyph}{#1} } - } - } -} -\keys_define:nn {fontspec} { Color .code:n = { + } + { \fontspec_error:nx {no-glyph}{#1} } + } + } +\__fontspec_keys_define_code:nnn {fontspec} {Color} + { \fontspec_update_fontid:n {+col:#1} \cs_if_exist:cTF { \token_to_str:N \color@ #1 } - { + { \convertcolorspec{named}{#1}{HTML}\l_fontspec_hexcol_tl - } - { + } + { \int_compare:nTF { \tl_length:n {#1} == 6 } - { \tl_set:Nn \l_fontspec_hexcol_tl {#1} } - { + { \tl_set:Nn \l_fontspec_hexcol_tl {#1} } + { \int_compare:nTF { \tl_length:n {#1} == 8 } - { \fontspec_parse_colour:viii #1 } - { - \bool_if:NF \l_fontspec_firsttime_bool { - \fontspec_warning:nx {bad-colour} {#1} - } - } - } - } - } -} -\cs_set:Npn \fontspec_parse_colour:viii #1#2#3#4#5#6#7#8 { + { \fontspec_parse_colour:viii #1 } + { + \bool_if:NF \l_fontspec_firsttime_bool + { \fontspec_warning:nx {bad-colour} {#1} } + } + } + } + } +\cs_set:Npn \fontspec_parse_colour:viii #1#2#3#4#5#6#7#8 + { \tl_set:Nn \l_fontspec_hexcol_tl {#1#2#3#4#5#6} \tl_if_eq:NNF \l_fontspec_opacity_tl \g_fontspec_opacity_tl { - \bool_if:NF \l_fontspec_firsttime_bool { - \fontspec_warning:nx {opa-twice-col} {#7#8} - } + \bool_if:NF \l_fontspec_firsttime_bool + { \fontspec_warning:nx {opa-twice-col} {#7#8} } } \tl_set:Nn \l_fontspec_opacity_tl {#7#8} -} + } \aliasfontfeature{Color}{Colour} \int_new:N \l_fontspec_tmp_int -\keys_define:nn {fontspec} { Opacity .code:n = { +\__fontspec_keys_define_code:nnn {fontspec} {Opacity} + { \fontspec_update_fontid:n {+opac:#1} \int_set:Nn \l_fontspec_tmp_int {255} \_int_mult_truncate:Nn \l_fontspec_tmp_int { #1 } \tl_if_eq:NNF \l_fontspec_opacity_tl \g_fontspec_opacity_tl { - \bool_if:NF \l_fontspec_firsttime_bool { - \fontspec_warning:nx {opa-twice} {#1} - } + \bool_if:NF \l_fontspec_firsttime_bool + { \fontspec_warning:nx {opa-twice} {#1} } } \tl_set:Nx \l_fontspec_opacity_tl { \int_compare:nT { \l_fontspec_tmp_int <= "F } {0} % zero pad \int_to_hexadecimal:n { \l_fontspec_tmp_int } } - } -} -\keys_define:nn {fontspec} -{ - Mapping .code:n = { - \str_if_eq:nnTF {#1} {tex-text} { + } +\__fontspec_keys_define_code:nnn {fontspec} {Mapping} + { + \str_if_eq:nnTF {#1} {tex-text} + { \fontspec_warning:n {no-mapping-ligtex} \msg_redirect_name:nnn {fontspec} {no-mapping-ligtex} {none} \keys_set:nn {fontspec} { Ligatures=TeX } - }{ - \fontspec_warning:n {no-mapping} - } - } -} -\keys_define:nn {fontspec} { FeatureFile .code:n = { + } + { \fontspec_warning:n {no-mapping} } + } +\__fontspec_keys_define_code:nnn {fontspec} {FeatureFile} + { \fontspec_update_fontid:n {+fea:#1} \fontspec_update_featstr:n{featurefile=#1} - } -} -\keys_define:nn {fontspec} { Weight .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec} {Weight} + { \fontspec_update_fontid:n {+weight:#1} \fontspec_update_featstr:n{weight=#1} - } -} -\keys_define:nn {fontspec} { Width .code:n = { + } +\__fontspec_keys_define_code:nnn {fontspec} {Width} + { \fontspec_update_fontid:n {+width:#1} \fontspec_update_featstr:n{width=#1} - } -} -\keys_define:nn {fontspec} { OpticalSize .code:n = - { - \tl_set:Nn \l_fontspec_optical_size_tl {/ S = #1} - \fontspec_update_fontid:n {+size:#1} - } -} -\keys_define:nn {fontspec} { FakeSlant .code:n = { - \fontspec_update_fontid:n {+slant:#1} - \fontspec_update_featstr:n{slant=#1} - }, + } +\__fontspec_keys_define_code:nnn {fontspec} {OpticalSize} + { + \tl_set:Nn \l_fontspec_optical_size_tl {/ S = #1} + \fontspec_update_fontid:n {+size:#1} + } +\keys_define:nn {fontspec} + { + FakeSlant .code:n = + { + \fontspec_update_fontid:n {+slant:#1} + \fontspec_update_featstr:n{slant=#1} + }, FakeSlant .default:n = {0.2} } -\keys_define:nn {fontspec} { FakeStretch .code:n = { - \fontspec_update_fontid:n {+extend:#1} - \fontspec_update_featstr:n{extend=#1} - }, +\keys_define:nn {fontspec} + { + FakeStretch .code:n = + { + \fontspec_update_fontid:n {+extend:#1} + \fontspec_update_featstr:n{extend=#1} + }, FakeStretch .default:n = {1.2} } \keys_define:nn {fontspec} - { - FakeBold .code:n = { \fontspec_warning:n {fakebold-only-xetex} } - } -\keys_define:nn {fontspec} { AutoFakeSlant .code:n = { - \bool_if:NT \l_fontspec_firsttime_bool { - - \tl_set:Nn \l_fontspec_fake_slant_tl {#1} - \clist_put_right:Nn \l_fontspec_fontfeat_it_clist {FakeSlant=#1} - \tl_set_eq:NN \l_fontspec_fontname_it_tl \l_fontspec_fontname_tl - \bool_set_false:N \l_fontspec_noit_bool + { + FakeBold .code:n = { \fontspec_warning:n {fakebold-only-xetex} } + } +\keys_define:nn {fontspec} + { + AutoFakeSlant .code:n = + { + \bool_if:NT \l_fontspec_firsttime_bool + { + \tl_set:Nn \l_fontspec_fake_slant_tl {#1} + \clist_put_right:Nn \l_fontspec_fontfeat_it_clist {FakeSlant=#1} + \tl_set_eq:NN \l_fontspec_fontname_it_tl \l_fontspec_fontname_tl + \bool_set_false:N \l_fontspec_noit_bool - \fontspec_update_fontid:n {fakeit:#1} + \fontspec_update_fontid:n {fakeit:#1} - \tl_if_empty:NF \l_fontspec_fake_embolden_tl - { - \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist - {FakeBold=\l_fontspec_fake_embolden_tl} - \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist {FakeSlant=#1} - \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl - } - } - }, + \tl_if_empty:NF \l_fontspec_fake_embolden_tl + { + \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist + {FakeBold=\l_fontspec_fake_embolden_tl} + \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist {FakeSlant=#1} + \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl + } + } + }, AutoFakeSlant .default:n = {0.2} } -\keys_define:nn {fontspec} { AutoFakeBold .code:n = { - \bool_if:NT \l_fontspec_firsttime_bool { - - \tl_set:Nn \l_fontspec_fake_embolden_tl {#1} - \clist_put_right:Nn \l_fontspec_fontfeat_bf_clist {FakeBold=#1} - \tl_set_eq:NN \l_fontspec_fontname_bf_tl \l_fontspec_fontname_tl - \bool_set_false:N \l_fontspec_nobf_bool +\keys_define:nn {fontspec} + { + AutoFakeBold .code:n = + { + \bool_if:NT \l_fontspec_firsttime_bool + { + \tl_set:Nn \l_fontspec_fake_embolden_tl {#1} + \clist_put_right:Nn \l_fontspec_fontfeat_bf_clist {FakeBold=#1} + \tl_set_eq:NN \l_fontspec_fontname_bf_tl \l_fontspec_fontname_tl + \bool_set_false:N \l_fontspec_nobf_bool - \fontspec_update_fontid:n {fakebf:#1} + \fontspec_update_fontid:n {fakebf:#1} - \tl_if_empty:NF \l_fontspec_fake_slant_tl { - \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist - {FakeSlant=\l_fontspec_fake_slant_tl} - \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist {FakeBold=#1} - \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl - } - } - }, + \tl_if_empty:NF \l_fontspec_fake_slant_tl + { + \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist + {FakeSlant=\l_fontspec_fake_slant_tl} + \clist_put_right:Nx \l_fontspec_fontfeat_bfit_clist {FakeBold=#1} + \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl + } + } + }, AutoFakeBold .default:n = {1.5} } \fontspec_define_font_feature:n{Ligatures} @@ -1331,12 +1518,13 @@ \fontspec_define_feature_option:nnnnn{Ligatures}{Icelandic} {1}{32}{} \fontspec_define_feature_option:nnnnn{Ligatures}{NoIcelandic} {1}{33}{} \keys_define:nn {fontspec} -{ - Ligatures / TeX .code:n = { + { + Ligatures / TeX .code:n = + { \fontspec_update_fontid:n {+tlig+trep} \fontspec_update_featstr:n{+tlig;+trep} - } -} + } + } \fontspec_define_font_feature:n{Letters} \fontspec_define_feature_option:nnnnn{Letters}{Normal} {3}{0}{} \fontspec_define_feature_option:nnnnn{Letters}{Uppercase} {3}{1}{+case} @@ -1357,9 +1545,10 @@ \fontspec_define_feature_option:nnnnn{Numbers}{Lining} {21}{1}{+lnum} \fontspec_define_feature_option:nnnnn{Numbers}{SlashedZero} {14}{5}{+zero} \fontspec_define_feature_option:nnnnn{Numbers}{NoSlashedZero}{14}{4}{-zero} -\luatex_if_engine:T { +\luatex_if_engine:T + { \fontspec_define_feature_option:nnnnn{Numbers}{Arabic}{}{}{+anum} -} + } \fontspec_define_font_feature:n {Contextuals} \fontspec_define_feature_option:nnnnn{Contextuals}{Swash} {} {} {+cswh} \fontspec_define_feature_option:nnnnn{Contextuals}{NoSwash} {} {} {-cswh} @@ -1406,59 +1595,61 @@ \fontspec_define_feature_option:nnnnn{Fractions}{Alternate}{} {} {+afrc} \fontspec_define_font_feature:n { Alternate } \keys_define:nn {fontspec} - { - Alternate .default:n = {0} , - Alternate / unknown .code:n = - { - \clist_map_inline:nn {#1} - { \fontspec_make_feature:nnx {17}{##1} { \fontspec_salt:n {##1} } } - } - } + { + Alternate .default:n = {0} , + Alternate / unknown .code:n = + { + \clist_map_inline:nn {#1} + { \fontspec_make_feature:nnx {17}{##1} { \fontspec_salt:n {##1} } } + } + } \cs_set:Nn \fontspec_salt:n { +salt = \int_eval:n {#1+1} } -\fontspec_define_font_feature:n { Variant } +\fontspec_define_font_feature:n {Variant} \keys_define:nn {fontspec} - { - Variant .default:n = {0} , - Variant / unknown .code:n = - { - \clist_map_inline:nn {#1} - { \fontspec_make_feature:nnx {18}{##1} { +ss \two@digits {##1} } } - } - } + { + Variant .default:n = {0} , + Variant / unknown .code:n = + { + \clist_map_inline:nn {#1} + { \fontspec_make_feature:nnx {18}{##1} { +ss \two@digits {##1} } } + } + } \aliasfontfeature{Variant}{StylisticSet} \fontspec_define_font_feature:n { CharacterVariant } \use:x - { - \cs_new:Npn \exp_not:N \fontspec_parse_cv:w - ##1 \c_colon_str ##2 \c_colon_str ##3 \exp_not:N \q_nil - { - \fontspec_make_numbered_feature:xn - { +cv \exp_not:N \two@digits {##1} } {##2} - } - \keys_define:nn {fontspec} - { - CharacterVariant / unknown .code:n = - { - \clist_map_inline:nn {##1} - { - \exp_not:N \fontspec_parse_cv:w - ####1 \c_colon_str 0 \c_colon_str \exp_not:N \q_nil - } - } - } - } + { + \cs_new:Npn \exp_not:N \fontspec_parse_cv:w + ##1 \c_colon_str ##2 \c_colon_str ##3 \exp_not:N \q_nil + { + \fontspec_make_numbered_feature:xn + { +cv \exp_not:N \two@digits {##1} } {##2} + } + \keys_define:nn {fontspec} + { + CharacterVariant / unknown .code:n = + { + \clist_map_inline:nn {##1} + { + \exp_not:N \fontspec_parse_cv:w + ####1 \c_colon_str 0 \c_colon_str \exp_not:N \q_nil + } + } + } + } \keys_define:nn {fontspec} - { - ScriptStyle .code:n = { - \fontspec_update_fontid:n {+ssty=1} - \fontspec_update_featstr:n{+sstyle} - }, - ScriptScriptStyle .code:n = { - \fontspec_update_fontid:n {+ssty=2} - \fontspec_update_featstr:n{+ssstyle} - } - } + { + ScriptStyle .code:n = + { + \fontspec_update_fontid:n {+ssty=1} + \fontspec_update_featstr:n{+sstyle} + }, + ScriptScriptStyle .code:n = + { + \fontspec_update_fontid:n {+ssty=2} + \fontspec_update_featstr:n{+ssstyle} + } + } \fontspec_define_font_feature:n{Style} \fontspec_define_feature_option:nnnnn{Style}{Alternate} {} {} {+salt} \fontspec_define_feature_option:nnnnn{Style}{Italic} {32}{2}{+ital} @@ -1504,29 +1695,31 @@ \fontspec_define_feature_option:nnnnn{Annotation}{DoubleCircle}{24}{11}{} \fontspec_define_font_feature:n { Annotation } \keys_define:nn {fontspec} - { - Annotation .default:n = {0} , - Annotation / unknown .code:n = - { - \fontspec_make_feature:nnx {}{} - { +nalt= \int_eval:n {#1+1} } - } - } + { + Annotation .default:n = {0} , + Annotation / unknown .code:n = + { + \fontspec_make_feature:nnx {}{} + { +nalt= \int_eval:n {#1+1} } + } + } \keys_define:nn {fontspec} - { - Vertical .choice: , - Vertical / RotatedGlyphs .code:n = - { - \bool_if:NTF \l_fontspec_icu_bool { - \fontspec_make_feature:nnn{}{}{+vrt2} - \fontspec_update_fontid:n {+vert} - \fontspec_update_featstr:n{vertical} - }{ - \fontspec_update_fontid:n {+vert} - \fontspec_update_featstr:n{vertical} - } - } - } + { + Vertical .choice: , + Vertical / RotatedGlyphs .code:n = + { + \bool_if:NTF \l_fontspec_icu_bool + { + \fontspec_make_feature:nnn{}{}{+vrt2} + \fontspec_update_fontid:n {+vert} + \fontspec_update_featstr:n{vertical} + } + { + \fontspec_update_fontid:n {+vert} + \fontspec_update_featstr:n{vertical} + } + } + } \newfontscript{Arabic}{arab} \newfontscript{Armenian}{armn} \newfontscript{Balinese}{bali} \newfontscript{Bengali}{beng} \newfontscript{Bopomofo}{bopo} \newfontscript{Braille}{brai} @@ -1765,86 +1958,93 @@ \newfontlanguage{Chinese~Traditional}{ZHT}\newfontlanguage{Zande}{ZND} \newfontlanguage{Zulu}{ZUL} \keys_define:nn {fontspec} - { - Language / Turkish .code:n = - { - \fontspec_check_lang:nTF {TRK} { - \int_set:Nn \l_fontspec_language_int {\l_fontspec_strnum_int} - \fontspec_update_fontid:n {+lang=Turkish} - \tl_set:Nn \l_fontspec_lang_tl {TRK} - }{ - \fontspec_check_lang:nTF {TUR} { - \int_set:Nn \l_fontspec_language_int {\l_fontspec_strnum_int} - \fontspec_update_fontid:n {+lang=Turkish} - \tl_set:Nn \l_fontspec_lang_tl {TUR} - }{ - \fontspec_warning:nx {language-not-exist} {Turkish} - \keys_set:nn {fontspec} {Language=Default} - } - } - } - } -\keys_define:nn {fontspec} - { - Language / Default .code:n = - { - \fontspec_update_fontid:n {+lang=dflt} - \tl_set:Nn \l_fontspec_lang_tl {DFLT} - \int_zero:N \l_fontspec_language_int - } - } -\keys_define:nn {fontspec} - { - RawFeature .code:n = - { - \fontspec_update_fontid:n {+Raw:#1} - \fontspec_update_featstr:n{#1} - } - } + { + Language / Turkish .code:n = + { + \fontspec_check_lang:nTF {TRK} + { + \int_set:Nn \l_fontspec_language_int {\l_fontspec_strnum_int} + \fontspec_update_fontid:n {+lang=Turkish} + \tl_set:Nn \l_fontspec_lang_tl {TRK} + } + { + \fontspec_check_lang:nTF {TUR} + { + \int_set:Nn \l_fontspec_language_int {\l_fontspec_strnum_int} + \fontspec_update_fontid:n {+lang=Turkish} + \tl_set:Nn \l_fontspec_lang_tl {TUR} + } + { + \fontspec_warning:nx {language-not-exist} {Turkish} + \keys_set:nn {fontspec} {Language=Default} + } + } + } + } +\__fontspec_keys_define_code:nnn {fontspec}{ Language / Default } + { + \fontspec_update_fontid:n {+lang=dflt} + \tl_set:Nn \l_fontspec_lang_tl {DFLT} + \int_zero:N \l_fontspec_language_int + } +\__fontspec_keys_define_code:nnn {fontspec} {RawFeature} + { + \fontspec_update_fontid:n {+Raw:#1} + \fontspec_update_featstr:n{#1} + } \providecommand*{\sidefault}{si} -\DeclareRobustCommand{\sishape}{ +\DeclareRobustCommand{\sishape} + { \not@math@alphabet\sishape\relax \fontshape\sidefault\selectfont -} + } \DeclareTextFontCommand{\textsi}{\sishape} -\cs_new:Nn \fontspec_blend_shape:nnn { +\cs_new:Nn \fontspec_blend_shape:nnn + { \bool_if:nTF - { - \str_if_eq_p:xx {\f@shape} {#2} && + { + \str_if_eq_x_p:nn {\f@shape} {#2} && \cs_if_exist_p:c {\f@encoding/\f@family/\f@series/#3} - } - { \fontshape{#3}\selectfont } - { \fontshape{#1}\selectfont } -} -\DeclareRobustCommand \itshape { + } + { \fontshape{#3}\selectfont } + { \fontshape{#1}\selectfont } + } +\DeclareRobustCommand \itshape + { \not@math@alphabet\itshape\mathit \fontspec_blend_shape:nnn\itdefault\scdefault\sidefault -} -\DeclareRobustCommand \slshape { + } +\DeclareRobustCommand \slshape + { \not@math@alphabet\slshape\relax \fontspec_blend_shape:nnn\sldefault\scdefault\sidefault -} -\DeclareRobustCommand \scshape { + } +\DeclareRobustCommand \scshape + { \not@math@alphabet\scshape\relax \fontspec_blend_shape:nnn\scdefault\itdefault\sidefault -} -\DeclareRobustCommand \upshape { + } +\DeclareRobustCommand \upshape + { \not@math@alphabet\upshape\relax \fontspec_blend_shape:nnn\updefault\sidefault\scdefault -} -\@ifpackageloaded{euler}{ + } +\@ifpackageloaded{euler} + { \bool_set_true:N \g_fontspec_package_euler_loaded_bool -}{ + } + { \bool_set_false:N \g_fontspec_package_euler_loaded_bool -} -\cs_set:Nn \fontspec_setup_maths: { - \@ifpackageloaded{euler}{ - \bool_if:NTF \g_fontspec_package_euler_loaded_bool { - \bool_set_true:N \g_fontspec_math_euler_bool - }{ - \fontspec_error:n {euler-too-late} - } - }{} + } +\cs_set:Nn \fontspec_setup_maths: + { + \@ifpackageloaded{euler} + { + \bool_if:NTF \g_fontspec_package_euler_loaded_bool + { \bool_set_true:N \g_fontspec_math_euler_bool } + { \fontspec_error:n {euler-too-late} } + } + {} \@ifpackageloaded{lucbmath}{\bool_set_true:N \g_fontspec_math_lucida_bool}{} \@ifpackageloaded{lucidabr}{\bool_set_true:N \g_fontspec_math_lucida_bool}{} \@ifpackageloaded{lucimatx}{\bool_set_true:N \g_fontspec_math_lucida_bool}{} @@ -1866,12 +2066,14 @@ \DeclareMathSymbol{\colon}{\mathpunct}{legacymaths}{58} \fi \group_end: - \bool_if:NF \g_fontspec_math_euler_bool { + \bool_if:NF \g_fontspec_math_euler_bool + { \DeclareMathSymbol{!}{\mathclose}{legacymaths}{33} \DeclareMathSymbol{:}{\mathrel} {legacymaths}{58} \DeclareMathSymbol{;}{\mathpunct}{legacymaths}{59} \DeclareMathSymbol{?}{\mathclose}{legacymaths}{63} - \bool_if:NF \g_fontspec_math_lucida_bool { + \bool_if:NF \g_fontspec_math_lucida_bool + { \DeclareMathSymbol{0}{\mathalpha}{legacymaths}{`0} \DeclareMathSymbol{1}{\mathalpha}{legacymaths}{`1} \DeclareMathSymbol{2}{\mathalpha}{legacymaths}{`2} @@ -1911,20 +2113,25 @@ \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g_fontspec_mathsf_tl\mddefault\updefault \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g_fontspec_mathtt_tl\mddefault\updefault \SetSymbolFont{operators}{bold}\g_fontspec_encoding_tl\g_fontspec_mathrm_tl\bfdefault\updefault - \tl_if_empty:NTF \g_fontspec_bfmathrm_tl { + \tl_if_empty:NTF \g_fontspec_bfmathrm_tl + { \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g_fontspec_mathrm_tl\bfdefault\updefault \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g_fontspec_mathrm_tl\bfdefault\itdefault - }{ + } + { \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g_fontspec_bfmathrm_tl\mddefault\updefault \SetMathAlphabet\mathbf{bold}\g_fontspec_encoding_tl\g_fontspec_bfmathrm_tl\bfdefault\updefault \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g_fontspec_bfmathrm_tl\mddefault\itdefault - } + } \SetMathAlphabet\mathsf{bold}\g_fontspec_encoding_tl\g_fontspec_mathsf_tl\bfdefault\updefault \SetMathAlphabet\mathtt{bold}\g_fontspec_encoding_tl\g_fontspec_mathtt_tl\bfdefault\updefault -} -\cs_new:Nn \fontspec_maybe_setup_maths: { - \@ifpackageloaded{anttor}{ - \ifx\define@antt@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi}{} + } +\cs_new:Nn \fontspec_maybe_setup_maths: + { + \@ifpackageloaded{anttor} + { + \ifx\define@antt@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi + }{} \@ifpackageloaded{arev}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{eulervm}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{mathdesign}{\bool_set_false:N \g_fontspec_math_bool}{} @@ -1933,12 +2140,16 @@ \@ifpackageloaded{mathesf}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{gfsartemisia}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{gfsneohellenic}{\bool_set_false:N \g_fontspec_math_bool}{} - \@ifpackageloaded{iwona}{ - \ifx\define@iwona@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi}{} + \@ifpackageloaded{iwona} + { + \ifx\define@iwona@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi + }{} \@ifpackageloaded{kpfonts}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{kmath}{\bool_set_false:N \g_fontspec_math_bool}{} - \@ifpackageloaded{kurier}{ - \ifx\define@kurier@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi}{} + \@ifpackageloaded{kurier} + { + \ifx\define@kurier@mathversions a\bool_set_false:N \g_fontspec_math_bool\fi + }{} \@ifpackageloaded{fouriernc}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{fourier}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{lmodern}{\bool_set_false:N \g_fontspec_math_bool}{} @@ -1947,24 +2158,26 @@ \@ifpackageloaded{MinionPro}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{unicode-math}{\bool_set_false:N \g_fontspec_math_bool}{} \@ifpackageloaded{breqn}{\bool_set_false:N \g_fontspec_math_bool}{} - \bool_if:NT \g_fontspec_math_bool { + \bool_if:NT \g_fontspec_math_bool + { \fontspec_info:n {setup-math} \fontspec_setup_maths: - } -} + } + } \AtBeginDocument{\fontspec_maybe_setup_maths:} -\bool_if:NT \g_fontspec_cfg_bool { +\bool_if:NT \g_fontspec_cfg_bool + { \InputIfFileExists{fontspec.cfg} {} {\typeout{No~ fontspec.cfg~ file~ found;~ no~ configuration~ loaded.}} -} + } \tl_set:Nn \zf@enc { \g_fontspec_encoding_tl } \cs_set:Npn \zf@fontspec #1 #2 - { - \fontspec_select:nn {#1} {#2} - \tl_set:Nn \zf@family { \l_fontspec_family_tl } - \tl_set:Nn \zf@basefont { \l_fontspec_font } - } + { + \fontspec_select:nn {#1} {#2} + \tl_set:Nn \zf@family { \l_fontspec_family_tl } + \tl_set:Nn \zf@basefont { \l_fontspec_font } + } \ExplSyntaxOff %% %% Copyright 2004--2012 Will Robertson <wspr81@gmail.com> |