diff options
author | Karl Berry <karl@freefriends.org> | 2015-03-14 22:59:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-03-14 22:59:51 +0000 |
commit | c493011f1ad4ff5cd2973ed6a6a3d4c9fec6470f (patch) | |
tree | 8031fe6db1684b5d12e9ae321631fda0a7b8534c /Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty | |
parent | 9c90dced35ede94c9693dfc8cdf67cbd4537caf1 (diff) |
fontspec (14mar15)
git-svn-id: svn://tug.org/texlive/trunk@36512 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty | 177 |
1 files changed, 108 insertions, 69 deletions
diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty b/Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty index 9598731ef62..74500f06cf3 100644 --- a/Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty +++ b/Master/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty @@ -14,7 +14,7 @@ %% %% \ProvidesPackage{fontspec-xetex} - [2014/06/21 v2.4a Font selection for XeLaTeX and LuaLaTeX] + [2015/03/14 v2.4c Font selection for XeLaTeX and LuaLaTeX] \ExplSyntaxOn @@ -32,28 +32,50 @@ \tl_set_eq:NN \latinencoding \g_fontspec_encoding_tl } \RequirePackage{xunicode} -\DeclareDocumentCommand \fontspec { O{} m O{} } +\cs_new:Nn \__fontspec_pass_args:nnn + { + \IfNoValueTF {#2} + { \__fontspec_post_arg:w {#1} {#3} } + { #1 {#2} {#3} } + } +\NewDocumentCommand \__fontspec_post_arg:w { m m O{} } + { #1 {#3} {#2} } +\NewDocumentCommand \fontspec { o m } + { \__fontspec_pass_args:nnn \__fontspec_fontspec:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_fontspec:nn { \fontencoding {\g_fontspec_encoding_tl} - \fontspec_set_family:Nnn \f@family {#1,#3}{#2} + \fontspec_set_family:Nnn \f@family {#1}{#2} \selectfont \ignorespaces } -\DeclareDocumentCommand \setmainfont { O{} m O{} } +\DeclareDocumentCommand \setmainfont { o m } + { \__fontspec_pass_args:nnn \__fontspec_setmainfont:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setmainfont:nn { - \fontspec_set_family:Nnn \rmdefault {#1,#3}{#2} + \fontspec_set_family:Nnn \rmdefault {#1}{#2} \normalfont \ignorespaces } -\DeclareDocumentCommand \setsansfont { O{} m O{} } + +\DeclareDocumentCommand \setsansfont { o m } + { \__fontspec_pass_args:nnn \__fontspec_setsansfont:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setsansfont:nn { - \fontspec_set_family:Nnn \sfdefault {#1,#3}{#2} + \fontspec_set_family:Nnn \sfdefault {#1}{#2} \normalfont \ignorespaces } -\DeclareDocumentCommand \setmonofont { O{} m O{} } + +\DeclareDocumentCommand \setmonofont { o m } + { \__fontspec_pass_args:nnn \__fontspec_setmonofont:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setmonofont:nn { - \fontspec_set_family:Nnn \ttdefault {#1,#3}{#2} + \fontspec_set_family:Nnn \ttdefault {#1}{#2} \normalfont \ignorespaces } @@ -62,21 +84,36 @@ \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 O{} } +\DeclareDocumentCommand \setmathrm { o m } + { \__fontspec_pass_args:nnn \__fontspec_setmathrm:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setmathrm:nn { - \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {#1,#3}{#2} + \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {#1} {#2} } -\DeclareDocumentCommand \setboldmathrm { O{} m O{} } + +\DeclareDocumentCommand \setboldmathrm { o m } + { \__fontspec_pass_args:nnn \__fontspec_setboldmathrm:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setboldmathrm:nn { - \fontspec_set_family:Nnn \g__fontspec_bfmathrm_tl {#1,#3}{#2} + \fontspec_set_family:Nnn \g__fontspec_bfmathrm_tl {#1} {#2} } -\DeclareDocumentCommand \setmathsf { O{} m O{} } + +\DeclareDocumentCommand \setmathsf { o m } + { \__fontspec_pass_args:nnn \__fontspec_setmathsf:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setmathsf:nn { - \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {#1,#3}{#2} + \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {#1} {#2} } -\DeclareDocumentCommand \setmathtt { O{} m O{} } + +\DeclareDocumentCommand \setmathtt { o m } + { \__fontspec_pass_args:nnn \__fontspec_setmathtt:nn {#1} {#2} } + +\cs_new:Nn \__fontspec_setmathtt:nn { - \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {#1,#3}{#2} + \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {#1} {#2} } \@onlypreamble\setmathrm \@onlypreamble\setboldmathrm @@ -85,9 +122,12 @@ \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 O{} } +\DeclareDocumentCommand \newfontfamily { m o m } + { \__fontspec_pass_args:nnn { \__fontspec_newfontfamily:Nnn #1 } {#2} {#3} } + +\cs_new:Nn \__fontspec_newfontfamily:Nnn { - \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N #1 _family } {#2,#4} {#3} + \fontspec_set_family:cnn { g__fontspec_ \cs_to_str:N #1 _family } {#2} {#3} \use:x { \exp_not:N \DeclareRobustCommand \exp_not:N #1 @@ -97,9 +137,12 @@ } } } -\DeclareDocumentCommand \newfontface { m O{} m O{} } +\DeclareDocumentCommand \newfontface { m o m } + { \__fontspec_pass_args:nnn { \__fontspec_newfontface:Nnn #1 } {#2} {#3} } + +\cs_new:Nn \__fontspec_newfontface:Nnn { - \newfontfamily #1 [ BoldFont={},ItalicFont={},SmallCapsFont={},#2,#4 ] {#3} + \newfontfamily #1 [ BoldFont={},ItalicFont={},SmallCapsFont={},#2 ] {#3} } \clist_new:N \g__fontspec_default_fontopts_clist \prop_new:N \g__fontspec_fontopts_prop @@ -137,15 +180,12 @@ } } } - \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 {~} + \tl_set:Nx #1 {#2} \clist_map_inline:Nn \l__fontspec_extensions_clist { \tl_remove_once:Nn #1 {##1} } } - \bool_new:N \l__fontspec_disable_defaults_bool \DeclareDocumentCommand \addfontfeatures {m} { @@ -198,32 +238,34 @@ \cs_set_eq:NN \newICUfeature \newopentypefeature % deprecated \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_define:nn {fontspec-preparse} - { #2 .code:n = { \keys_set:nn {fontspec-preparse} { #1 = {##1} } } } - } + \clist_map_inline:nn + { fontspec, fontspec-preparse, fontspec-preparse-external, + fontspec-preparse-nested, fontspec-renderer } + { + \keys_if_exist:nnT {##1} {#1} { - \keys_if_exist:nnTF {fontspec-preparse-external} {#1} - { - \keys_define:nn {fontspec-preparse-external} + \clist_map_break:n { - #2 .code:n = - { \keys_set:nn {fontspec-preparse-external} { #1 = {##1} } } + \__fontspec_alias_font_feature:nnn {##1} {#1} {#2} + \use_none_delimit_by_q_nil:w } - } - { - \__fontspec_warning:nx {rename-feature-not-exist} {#1} - } } - } + } + + % this executes if no match was found: + \__fontspec_warning:nx {rename-feature-not-exist} {#1} + + % jump to here if a match: + \use_none:n + \q_nil } + +\cs_set:Nn \__fontspec_alias_font_feature:nnn + { + \keys_define:nn {#1} + { #3 .code:n = { \keys_set:nn {#1} { #2 = {##1} } } } + } + \DeclareDocumentCommand \aliasfontfeatureoption {mmm} { \keys_define:nn { fontspec / #1 } { #3 .meta:n = {#2} } } \DeclareDocumentCommand \newfontscript {mm} @@ -503,11 +545,11 @@ \font_suppress_not_found_error: \__fontspec_init: - \tl_set:Nx \l_fontspec_fontname_tl {#2} - \tl_set_eq:NN \l_fontspec_fontname_up_tl \l_fontspec_fontname_tl - \tl_set_eq:NN \l__fontspec_basename_tl \l_fontspec_fontname_tl + \tl_set:Nx \l_fontspec_fontname_tl {#2} + \tl_set:Nx \l_fontspec_fontname_up_tl {#2} + \tl_set:Nx \l__fontspec_basename_tl {#2} - \__fontspec_load_external_fontoptions:N \l_fontspec_fontname_tl + \__fontspec_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#2} \__fontspec_extract_all_features:n {#1} \__fontspec_preparse_features: @@ -528,26 +570,25 @@ } \group_end: } -\cs_new:Nn \__fontspec_load_external_fontoptions:N +\cs_new:Nn \__fontspec_load_external_fontoptions:Nn { - \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {#1} - \prop_if_in:NVF \g__fontspec_fontopts_prop {\l__fontspec_tmp_tl} + \__fontspec_sanitise_fontname:Nn #1 {#2} + \tl_set:Nx \l__fontspec_ext_filename_tl {#1.fontspec} + \tl_remove_all:Nn \l__fontspec_ext_filename_tl {~} + \prop_if_in:NVF \g__fontspec_fontopts_prop #1 { - \exp_args:No \file_if_exist:nT {\l__fontspec_tmp_tl.fontspec} - { \file_input:n {\l__fontspec_tmp_tl.fontspec} } + \exp_args:No \file_if_exist:nT { \l__fontspec_ext_filename_tl } + { \file_input:n { \l__fontspec_ext_filename_tl } } } } \cs_new:Nn \__fontspec_extract_all_features:n { - \__fontspec_sanitise_fontname:Nn \l__fontspec_tmp_tl {\l_fontspec_fontname_tl} - \bool_if:NTF \l__fontspec_disable_defaults_bool { - \clist_set:Nx \l__fontspec_all_features_clist - {#1} + \clist_set:Nx \l__fontspec_all_features_clist {#1} } { - \prop_get:NVNF \g__fontspec_fontopts_prop \l__fontspec_tmp_tl \l__fontspec_fontopts_clist + \prop_get:NVNF \g__fontspec_fontopts_prop \l_fontspec_fontname_tl \l__fontspec_fontopts_clist { \clist_clear:N \l__fontspec_fontopts_clist } \prop_get:NVNF \g__fontspec_fontopts_prop \l__fontspec_family_label_tl \l__fontspec_family_fontopts_clist @@ -566,7 +607,7 @@ } \cs_new:Nn \__fontspec_preparse_features: { - \exp_args:NV \__fontspec_if_detect_external:nT \l_fontspec_fontname_tl + \__fontspec_if_detect_external:VT \l__fontspec_basename_tl { \keys_set:nn {fontspec-preparse-external} {ExternalLocation} } \keys_set_known:nxN {fontspec-preparse-external} @@ -598,6 +639,7 @@ } \bool_if:NTF \l__fontspec_tmpa_bool \prg_return_true: \prg_return_false: } +\cs_generate_variant:Nn \__fontspec_if_detect_external:nT {V} \cs_set:Nn \__fontspec_fullname:n { \__fontspec_namewrap:n { #1 \l__fontspec_extension_tl } @@ -776,10 +818,8 @@ \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:NVNF \g__fontspec_fontopts_prop \l__fontspec_tmp_tl \l__fontspec_fontopts_clist + \__fontspec_load_external_fontoptions:Nn \l_fontspec_fontname_tl {#1} + \prop_get:NVNF \g__fontspec_fontopts_prop \l_fontspec_fontname_tl \l__fontspec_fontopts_clist { \clist_clear:N \l__fontspec_fontopts_clist } \__fontspec_font_set:Nnn \l_fontspec_font {\__fontspec_fullname:n {\l_fontspec_fontname_tl}} {\f@size pt} \__fontspec_font_if_null:NT \l_fontspec_font { \__fontspec_error:nx {font-not-found} {#1} } @@ -1219,9 +1259,10 @@ \tl_clear:N \l__fontspec_extension_tl \keys_define:nn {fontspec-renderer} { - Renderer .choice_code:n = + Renderer .choices:nn = + {AAT,ICU,OpenType,Graphite,Full,Basic} { - \int_compare:nTF {\l_keys_choice_int <= 3} { + \int_compare:nTF {\l_keys_choice_int <= 4} { \tl_set:Nv \l_fontspec_renderer_tl { g_fontspec_renderer_tag_ \l_keys_choice_tl } } @@ -1229,8 +1270,6 @@ \__fontspec_warning:nx {only-luatex-feature} {Renderer=Full/Basic} } } - , - Renderer .generate_choices:n = {AAT,ICU,OpenType,Graphite,Full,Basic} } \tl_set:cn {g_fontspec_renderer_tag_AAT} {/AAT} \tl_set:cn {g_fontspec_renderer_tag_ICU} {/OT} |