From 9e8226cf8fa5064b6ad05024b81992bab84a2b20 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 7 Nov 2010 23:46:37 +0000
Subject: fontspec 2.1d (7nov10)

git-svn-id: svn://tug.org/texlive/trunk@20356 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/fontspec/fontspec.sty | 462 ++++++++++++----------
 1 file changed, 260 insertions(+), 202 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/fontspec/fontspec.sty')

diff --git a/Master/texmf-dist/tex/latex/fontspec/fontspec.sty b/Master/texmf-dist/tex/latex/fontspec/fontspec.sty
index 776a3d449da..a1407c8e32e 100644
--- a/Master/texmf-dist/tex/latex/fontspec/fontspec.sty
+++ b/Master/texmf-dist/tex/latex/fontspec/fontspec.sty
@@ -14,7 +14,7 @@
 %% 
 %% 
 \ProvidesPackage{fontspec}
-  [2010/09/29 v2.1b Advanced font selection for XeLaTeX/LuaLaTeX]
+  [2010/11/07 v2.1d Advanced font selection for XeLaTeX/LuaLaTeX]
 
 
 \RequirePackage{expl3,xparse}
@@ -29,7 +29,7 @@
     \RequirePackage{luatextra}[2010/05/10]
     \luatexRequireModule{fontspec}
   }{
-    \msg_error:nn {fontspec} {not-pdftex}
+    \msg_fatal:nn {fontspec} {not-pdftex}
   }
 }
 \xetex_if_engine:TF
@@ -43,20 +43,20 @@
     \luatex_if_engine:T
      { \cs_new:Npn \xetex_or_luatex:nnn #1#2#3 {#1{#3}} }
   }
-\newif\ifzf@firsttime
-\newif\ifzf@nobf
-\newif\ifzf@noit
-\newif\ifzf@nosc
-\newif\ifzf@tfm
-\newif\ifzf@atsui
-\newif\ifzf@icu
-\newif\ifzf@mm
-\newif\ifzf@graphite
-\newif\ifzf@math@euler
-\newif\ifzf@math@lucida
-\newif\ifzf@package@euler@loaded
-\newif\if@zf@configfile
-\newif\if@zf@math
+\bool_new:N \l_fontspec_firsttime_bool
+\bool_new:N \l_fontspec_nobf_bool
+\bool_new:N \l_fontspec_noit_bool
+\bool_new:N \l_fontspec_nosc_bool
+\bool_new:N \l_fontspec_tfm_bool
+\bool_new:N \l_fontspec_atsui_bool
+\bool_new:N \l_fontspec_icu_bool
+\bool_new:N \l_fontspec_mm_bool
+\bool_new:N \l_fontspec_graphite_bool
+\bool_new:N \g_fontspec_math_euler_bool
+\bool_new:N \g_fontspec_math_lucida_bool
+\bool_new:N \g_fontspec_package_euler_loaded_bool
+\bool_new:N \g_fontspec_cfg_bool
+\bool_new:N \g_fontspec_math_bool
 \int_new:N \l_fontspec_script_int
 \int_new:N \l_fontspec_language_int
 \int_new:N \l_fontspec_strnum_int
@@ -153,11 +153,15 @@
 {
   Option~ '#2'~ of~ font~ feature~ '#1'~ overwritten.
 }
-\msg_new:nnn {fontspec} {script-not-exist}
+\msg_new:nnn {fontspec} {script-not-exist-latn}
 {
   Font~ '\l_fontspec_fontname_tl'~ does~ not~ contain~ script~ '#1'.\\
   'Latin'~ script~ used~ instead.
 }
+\msg_new:nnn {fontspec} {script-not-exist}
+{
+  Font~ '\l_fontspec_fontname_tl'~ does~ not~ contain~ script~ '#1'.
+}
 \msg_new:nnn {fontspec} {aat-feature-not-exist}
 {
   '\XKV@tfam=\XKV@tkey'~ feature~ not~ supported\\
@@ -213,7 +217,7 @@
 }
 \msg_new:nnn {fontspec} {defining-font}
 {
-  Defining~ font~ family~ for~ '#2'~ with~ options~ [\g_fontspec_default_fontopts_tl #1].
+  Defining~ font~ family~'\zf@family'~ for~ font~ '#2'~ with~ options~ [\g_fontspec_default_fontopts_tl #1].
 }
 \msg_new:nnn {fontspec} {defining-raw}
 {
@@ -228,8 +232,11 @@
     {\bfdefault/\itdefault} {bold~ italic}
     {\bfdefault/\sidefault} {bold~ italic~ small~ caps}
   } {#1}'~
-  with~ NFSS~ specification: \\
+  with~ NFSS~ spec.: \\
   \l_fontspec_nfss_tl
+  \tl_if_empty:NF \l_fontspec_postadjust_tl {
+    \\ and~ font~ adjustment~ code: \\ \l_fontspec_postadjust_tl
+  }
 }
 \msg_new:nnn {fontspec} {no-font-shape}
 {
@@ -268,10 +275,10 @@
 \DeclareOption{cm-default}{
   \fontspec_warning:n {cm-default-obsolete}
 }
-\DeclareOption{math}{\@zf@mathtrue}
-\DeclareOption{no-math}{\@zf@mathfalse}
-\DeclareOption{config}{\@zf@configfiletrue}
-\DeclareOption{no-config}{\@zf@configfilefalse}
+\DeclareOption{math}{\bool_set_true:N \g_fontspec_math_bool}
+\DeclareOption{no-math}{\bool_set_false:N \g_fontspec_math_bool}
+\DeclareOption{config}{\bool_set_true:N \g_fontspec_cfg_bool}
+\DeclareOption{no-config}{\bool_set_false:N \g_fontspec_cfg_bool}
 \DeclareOption{quiet}{
   \msg_redirect_module:nnn { fontspec } { warning } { info }
   \msg_redirect_module:nnn { fontspec } { info } { none }
@@ -345,6 +352,7 @@
 \def\g_fontspec_mathrm_tl{\rmdefault}
 \def\g_fontspec_mathsf_tl{\sfdefault}
 \def\g_fontspec_mathtt_tl{\ttdefault}
+\tl_clear:N \g_fontspec_bfmathrm_tl
 \DeclareDocumentCommand \newfontfamily { m O{} m } {
   \fontspec_select:nn{#2}{#3}
   \use:x {
@@ -420,8 +428,12 @@
       \tl_set:Nn \l_fontspec_script_tl {#2}
       \int_set:Nn \l_fontspec_script_int {\l_fontspec_strnum_int}
     }{
-      \fontspec_warning:nx {script-not-exist} {#1}
-      \setkeys[zf@feat]{Script}{Latin}
+      \fontspec_check_script:nTF {latn} {
+        \fontspec_warning:nx {script-not-exist-latn} {#1}
+        \setkeys[zf@feat]{Script}{Latin}
+      }{
+        \fontspec_warning:nx {script-not-exist} {#1}
+      }
     }
   }
 }
@@ -449,21 +461,21 @@
 }
 \DeclareFontsExtensions{.otf,.ttf,.OTF,.TTF,.ttc,.TTC,.dfont}
 \prg_new_conditional:Nnn \fontspec_if_fontspec_font: {TF,T,F} {
-  \ifcsname zf@family@fontdef\f@family\endcsname
+  \cs_if_exist:cTF {g_fontspec_ \f@family _prop} {
     \prg_return_true:
-  \else
+  }{
     \prg_return_false:
-  \fi
+  }
 }
 \prg_new_conditional:Nnn \fontspec_if_aat_feature:nn {TF,T,F} {
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\use:c{zf@family@fontdef\f@family}} {\f@size pt}
-    \ifzf@atsui
+    \bool_if:NTF \l_fontspec_atsui_bool {
       \fontspec_make_AAT_feature_string:nnTF {#1}{#2}
         \prg_return_true: \prg_return_false:
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -472,11 +484,7 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
-      \prg_return_true:
-    \else
-      \prg_return_false:
-    \fi
+    \bool_if:NTF \l_fontspec_icu_bool \prg_return_true: \prg_return_false:
   }{
     \prg_return_false:
   }
@@ -485,15 +493,15 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \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:
-    \else
+      \fontspec_check_ot_feat:nTF {#1} {\prg_return_true:} {\prg_return_false:}
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -502,13 +510,13 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \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:
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -517,11 +525,11 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \fontspec_check_script:nTF {#1} \prg_return_true: \prg_return_false:
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -530,13 +538,13 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \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:
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -545,13 +553,13 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \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:
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -560,12 +568,12 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \str_if_eq:nvTF {#1} {g_fontspec_script_(\f@family)_tl}
         {\prg_return_true:} {\prg_return_false:}
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -574,12 +582,12 @@
   \fontspec_if_fontspec_font:TF {
     \font_set:Nnn \zf@basefont {\csname zf@family@fontdef\f@family\endcsname} {\f@size pt}
     \fontspec_set_font_type:
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \str_if_eq:nvTF {#1} {g_fontspec_lang_(\f@family)_tl}
         {\prg_return_true:} {\prg_return_false:}
-    \else
+    }{
       \prg_return_false:
-    \fi
+    }
   }{
     \prg_return_false:
   }
@@ -616,7 +624,7 @@
   \fontspec_preparse_features:nn {#1}{#2}
   \fontspec_set_scriptlang:
   \fontspec_get_features:n {}
-  \zf@firsttimefalse
+  \bool_set_false:N \l_fontspec_firsttime_bool
   \fontspec_save_family:nT {#2} {
     \fontspec_info:nxx {defining-font} {#1} {#2}
     \fontspec_save_fontinfo:nn {#1} {#2}
@@ -674,11 +682,11 @@
     }
   }
   \tl_gset:Nv \zf@family {g_fontspec_UID_\l_fontspec_fontid_tl}
-  \cs_if_exist:cTF {zf@family@fontname\zf@family}
+  \cs_if_exist:cTF {g_fontspec_ \zf@family _prop}
     \prg_return_false: \prg_return_true:
 }
 \cs_new:Npn \fontspec_set_scriptlang: {
-  \ifzf@icu
+  \bool_if:NT \l_fontspec_firsttime_bool {
     \tl_if_empty:NTF \l_fontspec_script_name_tl {
       \fontspec_check_script:nTF {latn}
       {
@@ -700,9 +708,24 @@
       \fontspec_setkeys:xxx {feat} {Script} {\l_fontspec_script_name_tl}
       \fontspec_setkeys:xxx {feat} {Lang}   {\l_fontspec_lang_name_tl}
     }
-  \fi
+  }
 }
+\cs_generate_variant:Nn \prop_gput:Nnn {cnV}
+\cs_generate_variant:Nn \prop_gput:Nnn {cnx}
 \cs_new:Npn \fontspec_save_fontinfo:nn #1#2 {
+
+  \prop_new:c {g_fontspec_ \zf@family _prop}
+  \prop_gput:cnx {g_fontspec_ \zf@family _prop} {fontname} {#2}
+  \prop_gput:cnx {g_fontspec_ \zf@family _prop} {options} {\g_fontspec_default_fontopts_tl #1}
+  \prop_gput:cnx {g_fontspec_ \zf@family _prop} {fontdef} {
+        \fontspec_fullname:n {\l_fontspec_fontname_tl} :
+        \l_fontspec_pre_feat_sclist \l_fontspec_rawfeatures_sclist
+  }
+  \prop_gput:cnV {g_fontspec_ \zf@family _prop} {script-num} \l_fontspec_script_int
+  \prop_gput:cnV {g_fontspec_ \zf@family _prop} {lang-num} \l_fontspec_language_int
+  \prop_gput:cnV {g_fontspec_ \zf@family _prop} {script-tag} \l_fontspec_script_tl
+  \prop_gput:cnV {g_fontspec_ \zf@family _prop} {lang-tag} \l_fontspec_lang_tl
+
     \tl_gset:cx {zf@family@fontname\zf@family} {#2}
     \tl_gset:cx {zf@family@options\zf@family} {\g_fontspec_default_fontopts_tl #1}
     \tl_gset:cx {zf@family@fontdef\zf@family} {
@@ -719,7 +742,7 @@
     \mddefault \updefault \l_fontspec_fontfeat_up_clist
 }
 \cs_new:Npn \fontspec_set_bold: {
-  \unless\ifzf@nobf
+  \bool_if:NF \l_fontspec_nobf_bool {
     \tl_if_empty:NTF \l_fontspec_fontname_bf_tl {
       \fontspec_make_font_shapes:nnnnn \l_fontspec_fontname_tl {/B}
         \bfdefault \updefault \l_fontspec_fontfeat_bf_clist
@@ -727,15 +750,15 @@
       \fontspec_make_font_shapes:nnnn \l_fontspec_fontname_bf_tl
         \bfdefault \updefault \l_fontspec_fontfeat_bf_clist
     }
-  \fi
+  }
 }
 \cs_new:Npn \fontspec_set_italic: {
-  \unless\ifzf@noit
+  \bool_if:NF \l_fontspec_noit_bool {
     \tl_if_empty:NTF \l_fontspec_fontname_it_tl
     { \fontspec_make_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
-  \fi
+  }
 }
 \cs_new:Npn \fontspec_set_slanted: {
   \tl_if_empty:NF \l_fontspec_fontname_sl_tl {
@@ -744,11 +767,7 @@
   }
 }
 \cs_new:Npn \fontspec_set_bold_italic: {
-  \@tempswatrue
-  \ifzf@nobf\@tempswafalse\fi
-  \ifzf@noit\@tempswafalse\fi
-  \bool_if:NT \l_fontspec_external_bool \@tempswafalse
-  \if@tempswa
+  \bool_if:nF {\l_fontspec_nobf_bool || \l_fontspec_nobf_bool} {
     \tl_if_empty:NTF \l_fontspec_fontname_bfit_tl
     {
       \tl_if_empty:NTF \l_fontspec_fontname_bf_tl
@@ -769,7 +788,7 @@
       \fontspec_make_font_shapes:nnnn  \l_fontspec_fontname_bfit_tl
     }
     \bfdefault \itdefault \l_fontspec_fontfeat_bfit_clist
-  \fi
+  }
 }
 \cs_new:Npn \fontspec_set_bold_slanted: {
   \tl_if_empty:NTF \l_fontspec_fontname_bfsl_tl {
@@ -784,27 +803,33 @@
 }
 \xetex_or_luatex:nnn { \cs_new:Npn \fontspec_set_font_type: }
    {
-    \zf@tfmfalse \zf@atsuifalse \zf@icufalse \zf@mmfalse \zf@graphitefalse
+    \bool_set_false:N \l_fontspec_tfm_bool
+    \bool_set_false:N \l_fontspec_atsui_bool
+    \bool_set_false:N \l_fontspec_icu_bool
+    \bool_set_false:N \l_fontspec_mm_bool
+    \bool_set_false:N \l_fontspec_graphite_bool
     \ifcase\XeTeXfonttype\zf@basefont
-      \zf@tfmtrue
+      \bool_set_true:N \l_fontspec_tfm_bool
     \or
-      \zf@atsuitrue
+      \bool_set_true:N \l_fontspec_atsui_bool
       \ifnum\XeTeXcountvariations\zf@basefont > \c_zero
-        \zf@mmtrue
+        \bool_set_true:N \l_fontspec_mm_bool
       \fi
     \or
-      \zf@icutrue
+      \bool_set_true:N \l_fontspec_icu_bool
     \fi
     \tl_if_empty:NT \l_fontspec_renderer_tl {
-      \ifzf@atsui
+      \bool_if:NTF \l_fontspec_atsui_bool {
         \tl_set:Nn \l_fontspec_renderer_tl {/AAT}
-      \else\ifzf@icu
-        \tl_set:Nn \l_fontspec_renderer_tl {/ICU}
-      \fi\fi
+      }{
+        \bool_if:NT \l_fontspec_icu_bool {
+          \tl_set:Nn \l_fontspec_renderer_tl {/ICU}
+        }
+      }
     }
   }
   {
-    \zf@icutrue
+    \bool_set_true:N \l_fontspec_icu_bool
   }
 \cs_new:Nn \fontspec_make_font_shapes:nnnnn {
   \font_set:Nnn \l_tmpa_font {\fontspec_fullname:n {#1}}   {\f@size pt}
@@ -821,13 +846,13 @@
     \font_set:Nnn \zf@basefont {\fontspec_fullname:n {#1}} {\f@size pt}
     \fontspec_declare_shape:nnnn {}{#2}{#3}{#4}
     \tl_if_empty:NTF \l_fontspec_fontname_sc_tl {
-      \unless\ifzf@nosc
+      \bool_if:NF \l_fontspec_nosc_bool {
         \fontspec_make_smallcaps:T {
           \fontspec_declare_shape:nnnn {\l_fontspec_sc_featstr_sclist} {#2}
             { \tl_if_eq:NNTF #3 \itdefault \sidefault \scdefault }
             { #4 \l_fontspec_fontfeat_sc_clist }
         }
-      \fi
+      }
     }{
       \tl_set:Nx \l_fontspec_fontname_tl {\l_fontspec_fontname_sc_tl}
       \fontspec_declare_shape:nnnn {}{#2}
@@ -874,7 +899,10 @@
     \exp_not:N\DeclareFontShape{\zf@enc}{\zf@family}{#2}{#3}
       {\l_fontspec_nfss_tl}{\l_fontspec_postadjust_tl}
   }
-  \str_if_eq:xxT {#3} {\itdefault}
+  \bool_if:nT {
+     \str_if_eq_p:xx {#3} {\itdefault}  &&
+    !(\str_if_eq_p:xx {\itdefault} {\sldefault})
+  }
   {
     \use:x {
       \exp_not:N \DeclareFontShape {\zf@enc}{\zf@family}{#2}{\sldefault}
@@ -884,13 +912,13 @@
 }
 \xetex_or_luatex:nnn { \tl_set:Nn \l_fontspec_pre_feat_sclist }
   {
-    \ifzf@icu
+    \bool_if:NT \l_fontspec_icu_bool {
       \tl_if_empty:NF \l_fontspec_script_tl
       {
         script   = \l_fontspec_script_tl ;
         language = \l_fontspec_lang_tl   ;
       }
-    \fi
+    }
   }
   {
     mode     = \l_fontspec_mode_tl   ;
@@ -901,9 +929,9 @@
     }
   }
 \cs_new:Nn \fontspec_update_fontid:n {
-  \ifzf@firsttime
+  \bool_if:NT \l_fontspec_firsttime_bool {
     \tl_gput_right:Nx \l_fontspec_fontid_tl {#1}
-  \fi
+  }
 }
 \cs_set:Npn \fontspec_get_features:n #1 {
   \sclist_clear:N \l_fontspec_rawfeatures_sclist
@@ -912,8 +940,10 @@
   \tl_set_eq:NN \l_fontspec_hexcol_tl \g_fontspec_hexcol_tl
   \tl_clear:N \l_fontspec_postadjust_tl
   \fontspec_setkeys:xx {options} {\l_fontspec_fontfeat_clist #1}
-  \tl_if_empty:NF \XKV@rm {
-    \fontspec_error:nx {unknown-options} { \exp_not:V \XKV@rm }
+  \bool_if:NT \l_fontspec_firsttime_bool {
+    \tl_if_empty:NF \XKV@rm {
+      \fontspec_error:nx {unknown-options} { \exp_not:V \XKV@rm }
+    }
   }
   \str_if_eq:xxF { \l_fontspec_hexcol_tl \l_fontspec_opacity_tl }
                 { \g_fontspec_hexcol_tl \g_fontspec_opacity_tl }
@@ -944,8 +974,8 @@
 \tl_new:Nn \g_fontspec_hexcol_tl {000000}
 \tl_new:Nn \g_fontspec_opacity_tl {FF~}
 \newcommand*\fontspec_init:{
-  \zf@icufalse
-  \zf@firsttimetrue
+  \bool_set_false:N \l_fontspec_icu_bool
+  \bool_set_true:N \l_fontspec_firsttime_bool
   \xetex_or_luatex:nnn { \cs_set:Npn \fontspec_namewrap:n ##1 }
     { ##1 }
     { name:##1 }
@@ -969,16 +999,18 @@
 \xetex_or_luatex:nn
 {
   \cs_set:Nn \fontspec_make_smallcaps:T {
-    \ifzf@atsui
-      \tl_clear:N \l_fontspec_sc_featstr_sclist
-      \fontspec_make_AAT_feature_string:nnT {3}{3} {
-        \tl_set:Nx \l_fontspec_sc_featstr_sclist {\l_fontspec_feature_string_tl;}
-        #1
-      }
-    \fi
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \fontspec_make_ot_smallcaps:T {#1}
-    \fi
+    }{
+      \bool_if:NT \l_fontspec_atsui_bool {
+        \tl_clear:N \l_fontspec_sc_featstr_sclist
+        \fontspec_make_AAT_feature_string:nnT {3}{3} {
+          \tl_set:Nx \l_fontspec_sc_featstr_sclist
+              {\l_fontspec_feature_string_tl;}
+          #1
+        }
+      }
+    }
   }
 }
 {
@@ -991,19 +1023,20 @@
 }
 \cs_generate_variant:Nn \sclist_gput_right:Nn {Nx}
 \cs_new:Nn \fontspec_update_featstr:n {
-  \unless\ifzf@firsttime
-    \sclist_gput_right:Nx \l_fontspec_rawfeatures_sclist {#1}
-  \fi
+  \bool_if:NF \l_fontspec_firsttime_bool {
+    \sclist_gput_right:Nx \l_fontspec_rawfeatures_sclist {#1;}
+  }
 }
 \cs_new:Npn \fontspec_make_feature:nnn #1#2#3 {
   \xetex_or_luatex:nn
   {
-    \ifzf@atsui
-      \fontspec_make_AAT_feature:nn {#1}{#2}
-    \fi
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \fontspec_make_ICU_feature:n {#3}
-    \fi
+    }{
+      \bool_if:NT \l_fontspec_atsui_bool {
+        \fontspec_make_AAT_feature:nn {#1}{#2}
+      }
+    }
   }
   {
     \fontspec_make_ICU_feature:n {#3}
@@ -1062,11 +1095,11 @@
   \tl_if_empty:NTF \l_tmpa_tl
   { \prg_return_false: }
   {
-    \intexpr_compare:nTF { \XeTeXisexclusivefeature\zf@basefont #1 > 0 }
+    \int_compare:nTF { \XeTeXisexclusivefeature\zf@basefont #1 > 0 }
     {
       \tl_set:Nx \l_tmpb_tl {\XeTeXselectorname\zf@basefont #1\space #2}
     }{
-      \intexpr_if_even:nTF {#2}
+      \int_if_even:nTF {#2}
       {
         \tl_set:Nx \l_tmpb_tl {\XeTeXselectorname\zf@basefont #1\space #2}
       }{
@@ -1111,7 +1144,7 @@
     \int_set:Nn \l_tmpb_int { \XeTeXOTcountscripts\zf@basefont }
     \int_zero:N \l_tmpa_int
     \@tempswafalse
-    \bool_until_do:nn { \intexpr_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
+    \bool_until_do:nn { \int_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
     {
       \ifnum \XeTeXOTscripttag\zf@basefont \l_tmpa_int = \l_fontspec_strnum_int
         \@tempswatrue
@@ -1134,7 +1167,7 @@
     }
     \int_zero:N \l_tmpa_int
     \@tempswafalse
-    \bool_until_do:nn { \intexpr_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
+    \bool_until_do:nn { \int_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
     {
       \ifnum\XeTeXOTlanguagetag\zf@basefont\l_fontspec_script_int \l_tmpa_int =\l_fontspec_strnum_int
         \@tempswatrue
@@ -1162,7 +1195,7 @@
     \fontspec_v_str_to_num:Nn \l_fontspec_strnum_int {#1}
     \int_zero:N \l_tmpa_int
     \@tempswafalse
-    \bool_until_do:nn { \intexpr_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
+    \bool_until_do:nn { \int_compare_p:nNn \l_tmpa_int = \l_tmpb_int }
     {
       \ifnum\XeTeXOTfeaturetag\zf@basefont\l_fontspec_script_int\l_fontspec_language_int
            \l_tmpa_int =\l_fontspec_strnum_int
@@ -1185,8 +1218,8 @@
   }
 \bool_new:N \l_fontspec_external_bool
 \define@key[zf]{preparse-external}{ExternalLocation}[]{
-  \zf@nobftrue
-  \zf@noittrue
+  \bool_set_true:N \l_fontspec_nobf_bool
+  \bool_set_true:N \l_fontspec_noit_bool
   \bool_set_true:N \l_fontspec_external_bool
   \xetex_or_luatex:nnn { \cs_gset:Npn \fontspec_namewrap:n ##1 }
     {     [ #1 ##1 ] }
@@ -1204,7 +1237,7 @@
 \define@choicekey[zf]{preparse}{Renderer}[\l_tmpa_tl\l_tmpa_num]
     {AAT,ICU,Graphite,Full,Basic}{
   \fontspec_update_fontid:n {+rend:#1}
-  \intexpr_compare:nTF {\l_tmpa_num < 3} {
+  \int_compare:nTF {\l_tmpa_num < 3} {
     \xetex_or_luatex:nn
     {
       \tl_set:Nv \l_fontspec_renderer_tl {g_fontspec_renderer_tag_\l_tmpa_tl}
@@ -1240,11 +1273,11 @@
 \define@key[zf]{preparse-external}{BoldFont}{
   \tl_if_empty:nTF {#1}
   {
-    \zf@nobftrue
+    \bool_set_true:N \l_fontspec_nobf_bool
     \fontspec_update_fontid:n {nobf}
   }
   {
-    \zf@nobffalse
+    \bool_set_false:N \l_fontspec_nobf_bool
     \fontspec_complete_fontname:Nn \l_fontspec_fontname_bf_tl {#1}
     \fontspec_update_fontid:n {bf:#1}
   }
@@ -1252,10 +1285,10 @@
 \define@key[zf]{preparse-external}{ItalicFont}{
   \tl_if_empty:nTF {#1}
   {
-    \zf@noittrue
+    \bool_set_true:N \l_fontspec_noit_bool
     \fontspec_update_fontid:n {noit}
   }{
-    \zf@noitfalse
+    \bool_set_false:N \l_fontspec_noit_bool
     \fontspec_complete_fontname:Nn \l_fontspec_fontname_it_tl {#1}
     \fontspec_update_fontid:n {it:#1}
   }
@@ -1275,10 +1308,10 @@
 \define@key[zf]{options}{SmallCapsFont}{
   \tl_if_empty:nTF {#1}
   {
-    \zf@nosctrue
+    \bool_set_true:N \l_fontspec_nosc_bool
     \fontspec_update_fontid:n {nosc}
   }{
-    \zf@noscfalse
+    \bool_set_true:N \l_fontspec_nosc_bool
     \fontspec_complete_fontname:Nn \l_fontspec_fontname_sc_tl {#1}
     \fontspec_update_fontid:n {sc:\zap@space #1~\@empty}
   }
@@ -1316,7 +1349,9 @@
   \fontspec_update_fontid:n {bfslfeat:#1}
 }
 \define@key[zf]{options}{SmallCapsFeatures}{
-  \unless\ifzf@firsttime\def\l_fontspec_fontfeat_sc_clist{, #1}\fi
+  \bool_if:NF \l_fontspec_firsttime_bool {
+    \def\l_fontspec_fontfeat_sc_clist{, #1}
+  }
   \fontspec_update_fontid:n {scfeat:\zap@space #1~\@empty}
 }
 \define@key[zf]{preparse}{SizeFeatures}{
@@ -1362,9 +1397,9 @@
 }
 \define@key[zf]{options}{WordSpace}{
   \fontspec_update_fontid:n {+wordspace:#1}
-  \unless\ifzf@firsttime
+  \bool_if:NF \l_fontspec_firsttime_bool {
     \_fontspec_parse_wordspace:w #1,,,\q_stop
-  \fi
+  }
 }
 \cs_set:Npn \_fontspec_parse_wordspace:w #1,#2,#3,#4 \q_stop {
   \tl_if_empty:nTF {#4}
@@ -1377,8 +1412,7 @@
     \dim_set:Nn \@tempdimb {#2\fontdimen3\zf@basefont}
     \dim_set:Nn \@tempdimc {#3\fontdimen4\zf@basefont}
   }
-  \tl_set:Nx \l_fontspec_postadjust_tl {
-    \l_fontspec_postadjust_tl
+  \tl_put_right:Nx \l_fontspec_postadjust_tl {
     \fontdimen2\font\the\@tempdima
     \fontdimen3\font\the\@tempdimb
     \fontdimen4\font\the\@tempdimc
@@ -1387,7 +1421,11 @@
 \define@key[zf]{options}{PunctuationSpace}{
   \fontspec_update_fontid:n {+punctspace:#1}
   \setlength\@tempdima{#1\fontdimen7\zf@basefont}
-  \tl_set:Nx \l_fontspec_postadjust_tl {\l_fontspec_postadjust_tl\fontdimen7\font\the\@tempdima}
+  \tl_put_right:Nx \l_fontspec_postadjust_tl {\fontdimen7\font\the\@tempdima}
+}
+\define@key[zf]{options}{FontAdjustment}{
+  \fontspec_update_fontid:n {+fontadjust:\detokenize{#1}}
+  \tl_put_right:Nx \l_fontspec_postadjust_tl {#1}
 }
 \define@key[zf]{options}{LetterSpace}{
   \fontspec_update_fontid:n {+tracking:#1}
@@ -1422,15 +1460,15 @@
     \convertcolorspec{named}{#1}{HTML}\l_fontspec_hexcol_tl
   }
   {
-    \intexpr_compare:nTF { \tl_elt_count:n {#1} == 6 }
+    \int_compare:nTF { \tl_elt_count:n {#1} == 6 }
     { \tl_set:Nn \l_fontspec_hexcol_tl {#1} }
     {
-      \intexpr_compare:nTF { \tl_elt_count:n {#1} == 8 }
+      \int_compare:nTF { \tl_elt_count:n {#1} == 8 }
       { \fontspec_parse_colour:viii #1 }
       {
-        \ifzf@firsttime\else
+        \bool_if:NF \l_fontspec_firsttime_bool {
           \fontspec_warning:nx {bad-colour} {#1}
-        \fi
+        }
       }
     }
   }
@@ -1439,9 +1477,9 @@
   \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
    {
-    \ifzf@firsttime\else
+    \bool_if:NF \l_fontspec_firsttime_bool {
       \fontspec_warning:nx {opa-twice-col} {#7#8}
-    \fi
+    }
    }
   \tl_set:Nn \l_fontspec_opacity_tl {#7#8}
 }
@@ -1452,9 +1490,9 @@
   \setcounter {fontspec_tmp_int} { 255*\real{#1} }
   \tl_if_eq:NNF \l_fontspec_opacity_tl \g_fontspec_opacity_tl
    {
-    \ifzf@firsttime\else
+    \bool_if:NF \l_fontspec_firsttime_bool {
       \fontspec_warning:nx {opa-twice} {#1}
-    \fi
+    }
    }
   \tl_set:Nx \l_fontspec_opacity_tl
    { \nhex2 { \value{fontspec_tmp_int} } }
@@ -1487,21 +1525,20 @@
 }
 \define@key[zf]{options}{OpticalSize}{
   \xetex_or_luatex:nn {
-    \ifzf@icu
+    \bool_if:NTF \l_fontspec_icu_bool {
       \tl_set:Nn \l_fontspec_optical_size_tl {/ S = #1}
       \fontspec_update_fontid:n {+size:#1}
-    \fi
-    \ifzf@mm
-      \fontspec_update_fontid:n {+size:#1}
-      \fontspec_update_featstr:n{optical size=#1}
-    \fi
-    \ifzf@icu\else
-      \ifzf@mm\else
-        \ifzf@firsttime
-          \fontspec_warning:n {no-opticals}
-        \fi
-      \fi
-    \fi
+    }{
+      \bool_if:NT \l_fontspec_mm_bool {
+        \fontspec_update_fontid:n {+size:#1}
+        \fontspec_update_featstr:n{optical size=#1}
+      }
+    }
+    \bool_if:nT { !\l_fontspec_icu_bool && !\l_fontspec_mm_bool }{
+      \bool_if:NT \l_fontspec_firsttime_bool {
+        \fontspec_warning:n {no-opticals}
+      }
+    }
   }{
     \tl_set:Nn \l_fontspec_optical_size_tl {/ S = #1}
     \fontspec_update_fontid:n {+size:#1}
@@ -1520,7 +1557,7 @@
   \fontspec_update_featstr:n{embolden=#1}
 }
 \define@key[zf]{options}{AutoFakeSlant}[0.2]{
-  \ifzf@firsttime
+  \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
@@ -1530,10 +1567,10 @@
         {,FakeBold=\l_fontspec_fake_embolden_tl,FakeSlant=#1}
       \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl
     }
-  \fi
+  }
 }
 \define@key[zf]{options}{AutoFakeBold}[1.5]{
-  \ifzf@firsttime
+  \bool_if:NT \l_fontspec_firsttime_bool {
     \tl_set:Nn \l_fontspec_fake_embolden_tl {#1}
     \tl_put_right:Nn \l_fontspec_fontfeat_bf_clist {,FakeBold=#1}
     \tl_set_eq:NN \l_fontspec_fontname_bf_tl \l_fontspec_fontname_tl
@@ -1543,7 +1580,7 @@
         {,FakeSlant=\l_fontspec_fake_slant_tl,FakeBold=#1}
       \tl_set_eq:NN \l_fontspec_fontname_bfit_tl \l_fontspec_fontname_tl
     }
-  \fi
+  }
 }
 \fontspec_define_font_feature:n{Ligatures}
 \fontspec_define_feature_option:nnnnn{Ligatures}{Required}       {1}{0}{+rlig}
@@ -1655,7 +1692,7 @@
   \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist
 }
 \xetex_or_luatex:nnn { \cs_set:Npn \fontspec_salt:n #1 }
-  {+salt=#1} { +salt= \intexpr_eval:n {#1+1} }
+  {+salt=#1} { +salt= \int_eval:n {#1+1} }
 \define@key[zf]{options}{Variant}{
   \clist_set_eq:NN \l_fontspec_tmpa_clist \XKV@rm
   \setkeys*[zf@feat]{Variant}{#1}
@@ -1675,6 +1712,24 @@
   }
   \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist
 }
+\xetex_or_luatex:nnn {\define@key[zf]{options}{ScriptStyle}[]}
+{
+  \fontspec_update_fontid:n {+ssty=0}
+  \fontspec_update_featstr:n{+ssty=0}
+}
+{
+  \fontspec_update_fontid:n {+ssty=1}
+  \fontspec_update_featstr:n{+ssty=1}
+}
+\xetex_or_luatex:nnn {\define@key[zf]{options}{ScriptScriptStyle}[]}
+{
+  \fontspec_update_fontid:n {+ssty=1}
+  \fontspec_update_featstr:n{+ssty=1}
+}
+{
+  \fontspec_update_fontid:n {+ssty=2}
+  \fontspec_update_featstr:n{+ssty=2}
+}
 \fontspec_define_font_feature:n{Style}
 \fontspec_define_feature_option:nnnnn{Style}{Alternate}     {}  {} {+salt}
 \fontspec_define_feature_option:nnnnn{Style}{Italic}        {32}{2}{+ital}
@@ -1726,17 +1781,17 @@
   \clist_set_eq:NN \XKV@rm \l_fontspec_tmpa_clist
 }
 \xetex_or_luatex:nnn { \cs_set:Npn \fontspec_nalt:n #1 }
-  {+nalt=#1} { +nalt= \intexpr_eval:n {#1+1} }
+  {+nalt=#1} { +nalt= \int_eval:n {#1+1} }
 \fontspec_define_font_feature:n{Vertical}
 \define@key[zf@feat]{Vertical}{RotatedGlyphs}[]{
-  \ifzf@icu
+  \bool_if:NTF \l_fontspec_icu_bool {
     \fontspec_make_feature:nnn{}{}{+vrt2}
     \fontspec_update_fontid:n {+vert}
     \fontspec_update_featstr:n{vertical}
-  \else
+  }{
     \fontspec_update_fontid:n {+vert}
     \fontspec_update_featstr:n{vertical}
-  \fi
+  }
 }
 \newfontscript{Arabic}{arab}            \newfontscript{Armenian}{armn}
 \newfontscript{Balinese}{bali}          \newfontscript{Bengali}{beng}
@@ -2029,19 +2084,22 @@
   \not@math@alphabet\upshape\relax
   \fontspec_blend_shape:nnn\updefault\sidefault\scdefault
 }
-\@ifpackageloaded{euler}{\zf@package@euler@loadedtrue}
-                        {\zf@package@euler@loadedfalse}
+\@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}{
-    \ifzf@package@euler@loaded
-      \zf@math@eulertrue
-    \else
+    \bool_if:NTF \g_fontspec_package_euler_loaded_bool {
+      \bool_set_true:N \g_fontspec_math_euler_bool
+    }{
       \fontspec_error:n {euler-too-late}
-    \fi
+    }
   }{}
-  \@ifpackageloaded{lucbmath}{\zf@math@lucidatrue}{}
-  \@ifpackageloaded{lucidabr}{\zf@math@lucidatrue}{}
-  \@ifpackageloaded{lucimatx}{\zf@math@lucidatrue}{}
+  \@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}{}
   \DeclareSymbolFont{legacymaths}{OT1}{cmr}{m}{n}
   \SetSymbolFont{legacymaths}{bold}{OT1}{cmr}{bx}{n}
   \DeclareMathAccent{\acute}   {\mathalpha}{legacymaths}{19}
@@ -2060,12 +2118,12 @@
       \DeclareMathSymbol{\colon}{\mathpunct}{legacymaths}{58}
     \fi
   \group_end:
-  \ifzf@math@euler\else
+  \bool_if:NF \g_fontspec_math_euler_bool {
     \DeclareMathSymbol{!}{\mathclose}{legacymaths}{33}
     \DeclareMathSymbol{:}{\mathrel}  {legacymaths}{58}
     \DeclareMathSymbol{;}{\mathpunct}{legacymaths}{59}
     \DeclareMathSymbol{?}{\mathclose}{legacymaths}{63}
-    \ifzf@math@lucida\else
+    \bool_if:NF \g_fontspec_math_lucida_bool {
       \DeclareMathSymbol{0}{\mathalpha}{legacymaths}{`0}
       \DeclareMathSymbol{1}{\mathalpha}{legacymaths}{`1}
       \DeclareMathSymbol{2}{\mathalpha}{legacymaths}{`2}
@@ -2095,8 +2153,8 @@
       \DeclareMathDelimiter{]}{\mathclose}{legacymaths}{93}{largesymbols}{3}
       \DeclareMathDelimiter{/}{\mathord}{legacymaths}{47}{largesymbols}{14}
       \DeclareMathSymbol{\mathdollar}{\mathord}{legacymaths}{36}
-    \fi
-  \fi
+    }
+  }
   \DeclareSymbolFont{operators}\zf@enc\g_fontspec_mathrm_tl\mddefault\updefault
   \SetSymbolFont{operators}{normal}\zf@enc\g_fontspec_mathrm_tl\mddefault\updefault
   \SetMathAlphabet\mathrm{normal}\zf@enc\g_fontspec_mathrm_tl\mddefault\updefault
@@ -2105,52 +2163,52 @@
   \SetMathAlphabet\mathsf{normal}\zf@enc\g_fontspec_mathsf_tl\mddefault\updefault
   \SetMathAlphabet\mathtt{normal}\zf@enc\g_fontspec_mathtt_tl\mddefault\updefault
   \SetSymbolFont{operators}{bold}\zf@enc\g_fontspec_mathrm_tl\bfdefault\updefault
-  \ifdefined\g_fontspec_bfmathrm_tl
+  \tl_if_empty:NTF \g_fontspec_bfmathrm_tl {
+    \SetMathAlphabet\mathrm{bold}\zf@enc\g_fontspec_mathrm_tl\bfdefault\updefault
+    \SetMathAlphabet\mathit{bold}\zf@enc\g_fontspec_mathrm_tl\bfdefault\itdefault
+  }{
     \SetMathAlphabet\mathrm{bold}\zf@enc\g_fontspec_bfmathrm_tl\mddefault\updefault
     \SetMathAlphabet\mathbf{bold}\zf@enc\g_fontspec_bfmathrm_tl\bfdefault\updefault
     \SetMathAlphabet\mathit{bold}\zf@enc\g_fontspec_bfmathrm_tl\mddefault\itdefault
-  \else
-    \SetMathAlphabet\mathrm{bold}\zf@enc\g_fontspec_mathrm_tl\bfdefault\updefault
-    \SetMathAlphabet\mathit{bold}\zf@enc\g_fontspec_mathrm_tl\bfdefault\itdefault
-  \fi
+  }
   \SetMathAlphabet\mathsf{bold}\zf@enc\g_fontspec_mathsf_tl\bfdefault\updefault
   \SetMathAlphabet\mathtt{bold}\zf@enc\g_fontspec_mathtt_tl\bfdefault\updefault
 }
 \cs_new:Nn \fontspec_maybe_setup_maths: {
   \@ifpackageloaded{anttor}{
-    \ifx\define@antt@mathversions a\@zf@mathfalse\fi}{}
-  \@ifpackageloaded{arev}{\@zf@mathfalse}{}
-  \@ifpackageloaded{eulervm}{\@zf@mathfalse}{}
-  \@ifpackageloaded{mathdesign}{\@zf@mathfalse}{}
-  \@ifpackageloaded{concmath}{\@zf@mathfalse}{}
-  \@ifpackageloaded{cmbright}{\@zf@mathfalse}{}
-  \@ifpackageloaded{mathesf}{\@zf@mathfalse}{}
-  \@ifpackageloaded{gfsartemisia}{\@zf@mathfalse}{}
-  \@ifpackageloaded{gfsneohellenic}{\@zf@mathfalse}{}
+    \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}{}
+  \@ifpackageloaded{concmath}{\bool_set_false:N \g_fontspec_math_bool}{}
+  \@ifpackageloaded{cmbright}{\bool_set_false:N \g_fontspec_math_bool}{}
+  \@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\@zf@mathfalse\fi}{}
-  \@ifpackageloaded{kpfonts}{\@zf@mathfalse}{}
-  \@ifpackageloaded{kmath}{\@zf@mathfalse}{}
+    \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\@zf@mathfalse\fi}{}
-  \@ifpackageloaded{fouriernc}{\@zf@mathfalse}{}
-  \@ifpackageloaded{fourier}{\@zf@mathfalse}{}
-  \@ifpackageloaded{mathpazo}{\@zf@mathfalse}{}
-  \@ifpackageloaded{mathptmx}{\@zf@mathfalse}{}
-  \@ifpackageloaded{MinionPro}{\@zf@mathfalse}{}
-  \@ifpackageloaded{unicode-math}{\@zf@mathfalse}{}
-  \@ifpackageloaded{breqn}{\@zf@mathfalse}{}
-  \if@zf@math
+    \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{mathpazo}{\bool_set_false:N \g_fontspec_math_bool}{}
+  \@ifpackageloaded{mathptmx}{\bool_set_false:N \g_fontspec_math_bool}{}
+  \@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 {
     \fontspec_info:n {setup-math}
     \fontspec_setup_maths:
-  \fi
+  }
 }
 \AtBeginDocument{\fontspec_maybe_setup_maths:}
-\if@zf@configfile
+\bool_if:NT \g_fontspec_cfg_bool {
   \InputIfFileExists{fontspec.cfg}
     {}
     {\typeout{No~ fontspec.cfg~ file~ found;~ no~ configuration~ loaded.}}
-\fi
+}
 %% 
 %% Copyright 2004--2010 Will Robertson <wspr81@gmail.com>
 %% Copyright 2009--2010 Khaled Hosny <khaledhosny@eglug.org>
-- 
cgit v1.2.3

