Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

819 lines (762 sloc) 30.201 kb
% \iffalse
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{luaotfload}
\RequirePackage{etoolbox}
\RequirePackage{expl3}
\RequirePackage{xparse}
\RequirePackage{l3keys2e}
\ProvidesExplPackage{otfsetup}{2013/07/29}{2.0}{Setup OpenType fonts}
% \fi
%
% \section{OTFSetup}
%
% The \pkg{otfsetup} package setups the main, sans, mono and math fonts with
% LuaTeX XeTeX, using the \pkg{fontspec} and \pkg{unicode-math} packages. The
% LuaTeX engine is tested more than the XeTeX engine. It provides simple
% options to setup fonts and scales. It takes care of things like optical
% sizes, weights, microtype setups, etc. Without this package, using the
% \pkg{fontspec} package the setting for many fonts is very convenient. But
% for some others, it can be painful. The package provide support for most
% fonts found in Adobe Font Folio 11, those included in TeXLive, and Microsoft
% ClearType fonts. The choices of which font to support is clearly very
% subjective.
%
% \subsection{Options}
%
% Options can be passed to \mac{usepackage} or through the \mac{otfsetup}
% macro. All options are key-value pairs. For options \opt{mainfont},
% \opt{sansfont}, \opt{monofont}, the allowed values are listed in
% tables~\ref{tab:mainfont-1} to~\ref{tab:capital}.
%
% \optdefine{predef}{<bool>}{true}
% Predefine \mac{calN} etc.
%
% \optdefine{mainfont}{<string>}{NULL}
% Setup the main document font. If set to be \val{NULL} or an invalid value,
% \val{LMRoman} will be used.
%
% \optdefine{sansfont}{<string>}{NULL}
% Setup the sans document font. If set to be \val{NULL} or an invalid value,
% \val{LMSans} will be used.
%
% \optdefine{monofont}{<string>}{NULL}
% Setup the mono document font. If set to be \val{NULL} or an invalid value,
% \val{LMMono} will be used.
%
% \optdefine{mathfont}{<string>}{NULL}
% Setup the math font. Allowed values are listed in table~\ref{tab:mathfont}.
% If set to be \val{NULL} or an invalid value, \val{LMMath} will be used.
%
% \optdefine{psmathfont}{<string>}{NULL}
% Setup the math font using a Type 1 PostScript font. Allowed values ar listed
% in table~\ref{tab:psmathfont}. A valid value will override \opt{mathfont}.
%
% \optdefine{mainscale}{<string>}{NULL}
% Set the scale of the main document font. Allowed values are real numbers and
% \val{MatchLowercase}, etc. (see documents of the \pkg{fontspec} for all
% allowed values of a font scale). The special value \val{NULL} is
% coresponding to no scaling.
%
% \optdefine{sansscale}{<string>}{NULL}
% Set the scale of the sans document font. Allowed values are real numbers and
% \val{MatchLowercase}, etc. (see documents of the \pkg{fontspec} for all
% allowed values of a font scale). The special value \val{NULL} is
% coresponding to no scaling.
%
% \optdefine{monoscale}{<string>}{NULL}
% Set the scale of the mono document font. Allowed values are real numbers and
% \val{MatchLowercase}, etc. (see documents of the \pkg{fontspec} for all
% allowed values of a font scale). The special value \val{NULL} is
% coresponding to no scaling.
%
% \optdefine{mathscale}{<string>}{NULL}
% Set the scale of the math font. Allowed values are real numbers and
% \val{MatchLowercase}, etc. (see documents of the \pkg{fontspec} for all
% allowed values of a font scale). The special value \val{NULL} is
% coresponding to no scaling.
%
% \optdefine{fontscale}{<string>}{NULL}
% Set the options \opt{mainscale}, \opt{sanscale}, \opt{monoscale} and
% \opt{mathscale} to the same value. Allowed values are real numbers and
% \val{MatchLowercase}, etc. (see documents of the \pkg{fontspec} for all
% allowed values of a font scale). The special value \val{NULL} is
% coresponding to no scaling. It can be partially overrided by each of those
% four options.
%
% \optdefine{fontset}{<string>}{Minion}
% Set the options \opt{mainfont}, \opt{sansfont}, \opt{monofont},
% \opt{mathfont} to a predefined set of values. Allowed values are listed in
% table~\ref{tab:fontset}. If set to \val{NULL} or an invalid value, it has no
% effect. When set to a valid value, it can partially overrided by each of
% those four options as well as the option \opt{psmathfont}.
%
% {\input{otfsetup-table}}
%
% \subsection{Macros}
%
% This package can also load an individual font family in the middle of
% documents.
%
% \macdefine{LoadFontFamily}{[<scale>][<macro name>]\{<FontOptionName>\}}
% This macro takes one mandatory argument which can be any of the option
% values listed in tables~\ref{tab:mainfont-1} to~\ref{tab:capital}. It can
% also take an optional argument as the scale factor, default to
% \val{MatchLowercase}. It will define a new font family with the name of its
% argument through \pkg{fontspec}'s \mac{newfontfamily}. A second optional
% argument can be provided to give a differnt name of the macro defined
% (without the backslash). For example,\par
% \mac{LoadFontFamily\{Brioso\}}\par
% \mac{LoadFontFamily[][Bickham]\{Bickham\}}\par
% \mac{Brioso The quick brown fox jumps over the lazy dog.}\par\noindent
% \mac{Bickham The quick brown fox jumps over the lazy dog.}\par\noindent
% give \par
% \LoadFontFamily{Brioso}
% \LoadFontFamily[][Bickham]{Bickham}
% {\Brioso The quick brown fox jumps over the lazy dog.\par}\noindent
% {\Bickham The quick brown fox jumps over the lazy dog.\par}\noindent
% while \par
% \mac{LoadFontFamily[2.0][briosofont]\{Brioso\}}\par
% \mac{briosofont The quick brown fox jumps over the lazy dog.}\par\noindent
% give \par
% \LoadFontFamily[2.0][briosofont]{Brioso}
% {\Brioso The quick brown fox jumps over the lazy dog.\par}\noindent
% Note that, even two different macro names are given to the same font family
% (with different scales), they have the same effect as the last one defined.
% For example, now\par
% \mac{Brioso The quick brown fox jumps over the lazy dog.}\par\noindent
% also gives\par
% {\briosofont The quick brown fox jumps over the lazy dog.\par}
%
% \macdefine{UseMathCal}{[<macro name>]\{A-Za-z|<greek letter name>\}}
% \macdefine{UseMathScr}{[<macro name>]\{A-Za-z|<greek letter name>\}}
% \macdefine{UseMathFrak}{[<macro name>]\{A-Za-z|<greek letter name>\}}
% \macdefine{UseMathBB}{[<macro name>]\{A-Za-z|<greek letter name>\}}
% \macdefine{UseMathBold}{[<macro name>]\{A-Za-z|<greek letter name>\}}
% This package also provides macros that can be used to define macros like
% \mac{calN} which expands to \mac{mathcal\{N\}}. If the required math
% alphabet (\mac{mathcal} etc.) does not exist, then defined macro simply use
% the math italic font. In addition, it provides the macro \mac{UseMathBold}
% which is similar to the above but will use bold itlaic math fonts if
% available and the macros defined will be prefixed by \mac{bf} instead of
% \mac{bold}. If no bold italic font are detected, then \mac{mathbf} will be
% used. An optional argument can be provided to specify a different macro
% name. Table~\ref{tab:use_math_alpha} list the definitions, macros and
% effects.
%
% \UseMathCal{A}
% \UseMathScr{A}
% \UseMathFrak{A}
% \UseMathBB{A}
% \UseMathBold{A}
% \UseMathBold{a}
% \UseMathBold{Gamma}
% \UseMathBold{gamma}
% \UseMathBold[\bOmega]{Omega}
% \begin{table}[t]
% \caption[Effects of \protect\textbackslash UseMathCal, etc., macros]
% {Effects of \mac{UseMathCal}, etc., macros}
% \label{tab:use_math_alpha}
% \begin{tabu}{XXX}
% \toprule
% Definitions & Macros & Symbols \\
% \midrule
% \mac{UseMathCal\{A\}} & \mac{calA} & $\calA$ \\
% \mac{UseMathScr\{A\}} & \mac{scrA} & $\scrA$ \\
% \mac{UseMathFrak\{A\}} & \mac{frakA} & $\frakA$ \\
% \mac{UseMathBB\{A\}} & \mac{bbA} & $\bbA$ \\
% \mac{UseMathBold\{A\}} & \mac{bfA} & $\bfA$ \\
% \mac{UseMathBold\{a\}} & \mac{bfa} & $\bfa$ \\
% \mac{UseMathBold\{Gamma\}} & \mac{bfGamma} & $\bfGamma$ \\
% \mac{UseMathBold\{gamma\}} & \mac{bfgamma} & $\bfgamma$ \\
% \mac{UseMathBold[}\mac{bOmega]\{Omega\}} & \mac{bOmega} & $\bOmega$ \\
% \bottomrule
% \end{tabu}
% \end{table}
%
% \subsection{Implementations}
%
% Options.
% \begin{macrocode}
\bool_new:N \otfs_predef \bool_set_true:N \otfs_predef
\cs_new:Nn \otfs_mainfont: {NULL}
\cs_new:Nn \otfs_sansfont: {NULL}
\cs_new:Nn \otfs_monofont: {NULL}
\cs_new:Nn \otfs_mathfont: {NULL}
\cs_new:Nn \otfs_mainscale: {NULL}
\cs_new:Nn \otfs_sansscale: {NULL}
\cs_new:Nn \otfs_monoscale: {NULL}
\cs_new:Nn \otfs_mathscale: {NULL}
\cs_new:Nn \otfs_psmathfont: {NULL}
\cs_new:Nn \otfs_fontscale: {NULL}
\cs_new:Nn \otfs_fontset: {Minion}
\keys_define:nn {otfs} {
predef .bool_set:N = \otfs_predef,
mainfont .code:n = \cs_gset:Nn \otfs_mainfont: {#1},
sansfont .code:n = \cs_gset:Nn \otfs_sansfont: {#1},
monofont .code:n = \cs_gset:Nn \otfs_monofont: {#1},
mathfont .code:n = \cs_gset:Nn \otfs_mathfont: {#1},
mainscale .code:n = \cs_gset:Nn \otfs_mainscale: {#1},
sansscale .code:n = \cs_gset:Nn \otfs_sansscale: {#1},
monoscale .code:n = \cs_gset:Nn \otfs_monoscale: {#1},
mathscale .code:n = \cs_gset:Nn \otfs_mathscale: {#1},
psmathfont .code:n = \cs_gset:Nn \otfs_psmathfont: {#1},
fontscale .code:n = \cs_gset:Nn \otfs_fontscale: {#1},
fontset .code:n = \cs_gset:Nn \otfs_fontset: {#1},
}
\ProcessKeysOptions{otfs}
% \end{macrocode}
%
% Setup engines.
% \begin{macrocode}
\input{FontBook.ltx}
\luatex_if_engine:T {
\pdfprotrudechars=2
\pdfadjustspacing=2
\directlua{
local~FontBook = kpse.find_file('FontBook.lua', 'lua')
local~FontMicro = kpse.find_file('FontMicro.lua', 'lua')
dofile(FontBook)
dofile(FontMicro)
}
}
\xetex_if_engine:T {
\XeTeXprotrudechars=2
}
\cs_gset:Npn \otfsetup #1 {\keys_set:nn{otfs}{#1}}
% \end{macrocode}
%
% Utility macros.
% \begin{macrocode}
\cs_new:Nn \otfs_check_use:n {\cs_if_exist:cT{#1}{\use:c{#1}}}
\cs_new:Nn \otfs_check_use:nn {\cs_if_exist:cTF{#1}{\use:c{#1}}{#2}}
\cs_new:Nn \otfs_setup_font:x {
\otfs_check_use:n{otfs_font_bd_#1:}
\otfs_check_use:n{otfs_font_it_#1:}
\otfs_check_use:n{otfs_font_bi_#1:}
\otfs_check_use:n{otfs_font_size_#1:}
\otfs_check_use:n{otfs_font_extra_#1:}
}
\cs_new:Nn \otfs_setup_microtype:x {
\luatex_if_engine:T {
UprightFeatures = {RawFeature={
protrusion=\otfs_check_use:nn{otfs_font_protrusion_up_#1:}{default};
expansion=\otfs_check_use:nn{otfs_font_expansion_up_#1:}{default}
}
},
BoldFeatures = {RawFeature={
protrusion=\otfs_check_use:nn{otfs_font_protrusion_bd_#1:}{default};
expansion=\otfs_check_use:nn{otfs_font_expansion_bd_#1:}{default}
}
},
ItalicFeatures = {RawFeature={
protrusion=\otfs_check_use:nn{otfs_font_protrusion_it_#1:}{default};
expansion=\otfs_check_use:nn{otfs_font_expansion_it_#1:}{default}
}
},
BoldItalicFeatures = {RawFeature={
protrusion=\otfs_check_use:nn{otfs_font_protrusion_bi_#1:}{default};
expansion=\otfs_check_use:nn{otfs_font_expansion_bi_#1:}{default}
}
},
}
}
\cs_new:Nn \otfs_setup_engine:x {
\luatex_if_engine:T {\otfs_check_use:n{otfs_font_luatex_#1:}},
\xetex_if_engine:T {\otfs_check_use:n{otfs_font_xetex_#1:}},
}
\cs_new:Nn \otfs_setup_feature:n {
\otfs_setup_font:x{#1}
\otfs_setup_microtype:x{#1}
\otfs_setup_engine:x{#1}
}
\DeclareDocumentCommand \LoadFontFamily {o o m} {
\IfNoValueTF{#1}{
\cs_set:cn {otfs_loadfont_scale_#3:} {MatchLowercase}
}{
\cs_set:cx {otfs_loadfont_scale_#3:} {#1}
}
\IfNoValueTF{#2}{
\cs_set:Nx \otfs_loadfont_macro: {#3}
}{
\cs_set:Nx \otfs_loadfont_macro: {#2}
}
\cs_if_exist:cTF{otfs_font_up_#3:}{
\cs_set:cx {otfs_loadfont_up_#3:} {\use:c{otfs_font_up_#3:}}
\cs_set:cx {otfs_loadfont_options_#3:} {
Scale = \use:c{otfs_loadfont_scale_#3:},
\str_if_eq_x:nnTF {\use:c{otfs_font_type_#3:}}{Mono} {
Ligatures = {NoRequired, NoCommon, NoContextual},
Numbers = {Lining, Monospaced},
}{
Ligatures = {Required, Common, Contextual, TeX},
Numbers = {OldStyle, Proportional},
}
\otfs_setup_feature:n{#3}
}
\fontspec_set_family:cnn {otfs_loadfont_family_#3:}
{\use:c{otfs_loadfont_options_#3:}}{\use:c{otfs_loadfont_up_#3:}}
\cs_set:Nn \otfs_loadfont_select: {
\fontencoding{\g_fontspec_encoding_tl}
\fontfamily{\use:c{otfs_loadfont_family_#3:}}
\selectfont
}
\cs_gset_eq:cN \otfs_loadfont_macro: \otfs_loadfont_select:
}{
\cs_gset_eq:cN \otfs_loadfont_macro: \prg_do_nothing:
}
}
% \end{macrocode}
%
% Bold math symbols.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_alpha:NN {
\cs_gset:Npn \otfs_bf_a: {#1{a}} \cs_gset:Npn \otfs_bf_A: {#2{A}}
\cs_gset:Npn \otfs_bf_b: {#1{b}} \cs_gset:Npn \otfs_bf_B: {#2{B}}
\cs_gset:Npn \otfs_bf_c: {#1{c}} \cs_gset:Npn \otfs_bf_C: {#2{C}}
\cs_gset:Npn \otfs_bf_d: {#1{d}} \cs_gset:Npn \otfs_bf_D: {#2{D}}
\cs_gset:Npn \otfs_bf_e: {#1{e}} \cs_gset:Npn \otfs_bf_E: {#2{E}}
\cs_gset:Npn \otfs_bf_f: {#1{f}} \cs_gset:Npn \otfs_bf_F: {#2{F}}
\cs_gset:Npn \otfs_bf_g: {#1{g}} \cs_gset:Npn \otfs_bf_G: {#2{G}}
\cs_gset:Npn \otfs_bf_h: {#1{h}} \cs_gset:Npn \otfs_bf_H: {#2{H}}
\cs_gset:Npn \otfs_bf_i: {#1{i}} \cs_gset:Npn \otfs_bf_I: {#2{I}}
\cs_gset:Npn \otfs_bf_j: {#1{j}} \cs_gset:Npn \otfs_bf_J: {#2{J}}
\cs_gset:Npn \otfs_bf_k: {#1{k}} \cs_gset:Npn \otfs_bf_K: {#2{K}}
\cs_gset:Npn \otfs_bf_l: {#1{l}} \cs_gset:Npn \otfs_bf_L: {#2{L}}
\cs_gset:Npn \otfs_bf_m: {#1{m}} \cs_gset:Npn \otfs_bf_M: {#2{M}}
\cs_gset:Npn \otfs_bf_n: {#1{n}} \cs_gset:Npn \otfs_bf_N: {#2{N}}
\cs_gset:Npn \otfs_bf_o: {#1{o}} \cs_gset:Npn \otfs_bf_O: {#2{O}}
\cs_gset:Npn \otfs_bf_p: {#1{p}} \cs_gset:Npn \otfs_bf_P: {#2{P}}
\cs_gset:Npn \otfs_bf_q: {#1{q}} \cs_gset:Npn \otfs_bf_Q: {#2{Q}}
\cs_gset:Npn \otfs_bf_r: {#1{r}} \cs_gset:Npn \otfs_bf_R: {#2{R}}
\cs_gset:Npn \otfs_bf_s: {#1{s}} \cs_gset:Npn \otfs_bf_S: {#2{S}}
\cs_gset:Npn \otfs_bf_t: {#1{t}} \cs_gset:Npn \otfs_bf_T: {#2{T}}
\cs_gset:Npn \otfs_bf_u: {#1{u}} \cs_gset:Npn \otfs_bf_U: {#2{U}}
\cs_gset:Npn \otfs_bf_v: {#1{v}} \cs_gset:Npn \otfs_bf_V: {#2{V}}
\cs_gset:Npn \otfs_bf_w: {#1{w}} \cs_gset:Npn \otfs_bf_W: {#2{W}}
\cs_gset:Npn \otfs_bf_x: {#1{x}} \cs_gset:Npn \otfs_bf_X: {#2{X}}
\cs_gset:Npn \otfs_bf_y: {#1{y}} \cs_gset:Npn \otfs_bf_Y: {#2{Y}}
\cs_gset:Npn \otfs_bf_z: {#1{z}} \cs_gset:Npn \otfs_bf_Z: {#2{Z}}
}
\cs_new:Nn \otfs_setup_greek:NN {
\cs_gset:Npn \otfs_bf_alpha: {#1{\alpha}}
\cs_gset:Npn \otfs_bf_beta: {#1{\beta}}
\cs_gset:Npn \otfs_bf_gamma: {#1{\gamma}}
\cs_gset:Npn \otfs_bf_delta: {#1{\delta}}
\cs_gset:Npn \otfs_bf_epsilon: {#1{\epsilon}}
\cs_gset:Npn \otfs_bf_varepsilon: {#1{\varepsilon}}
\cs_gset:Npn \otfs_bf_zeta: {#1{\zeta}}
\cs_gset:Npn \otfs_bf_eta: {#1{\eta}}
\cs_gset:Npn \otfs_bf_theta: {#1{\theta}}
\cs_gset:Npn \otfs_bf_vartheta: {#1{\vartheta}}
\cs_gset:Npn \otfs_bf_iota: {#1{\iota}}
\cs_gset:Npn \otfs_bf_kappa: {#1{\kappa}}
\cs_gset:Npn \otfs_bf_lambda: {#1{\lambda}}
\cs_gset:Npn \otfs_bf_mu: {#1{\mu}}
\cs_gset:Npn \otfs_bf_nu: {#1{\nu}}
\cs_gset:Npn \otfs_bf_xi: {#1{\xi}}
\cs_gset:Npn \otfs_bf_pi: {#1{\pi}}
\cs_gset:Npn \otfs_bf_varpi: {#1{\varpi}}
\cs_gset:Npn \otfs_bf_rho: {#1{\rho}}
\cs_gset:Npn \otfs_bf_varrho: {#1{\varrho}}
\cs_gset:Npn \otfs_bf_sigma: {#1{\sigma}}
\cs_gset:Npn \otfs_bf_varsigma: {#1{\varsigma}}
\cs_gset:Npn \otfs_bf_tau: {#1{\tau}}
\cs_gset:Npn \otfs_bf_upsilon: {#1{\upsilon}}
\cs_gset:Npn \otfs_bf_phi: {#1{\phi}}
\cs_gset:Npn \otfs_bf_varphi: {#1{\varphi}}
\cs_gset:Npn \otfs_bf_chi: {#1{\chi}}
\cs_gset:Npn \otfs_bf_psi: {#1{\psi}}
\cs_gset:Npn \otfs_bf_omega: {#1{\omega}}
\cs_gset:Npn \otfs_bf_Gamma: {#2{\Gamma}}
\cs_gset:Npn \otfs_bf_Delta: {#2{\Delta}}
\cs_gset:Npn \otfs_bf_Theta: {#2{\Theta}}
\cs_gset:Npn \otfs_bf_Lambda: {#2{\Lambda}}
\cs_gset:Npn \otfs_bf_Xi: {#2{\Xi}}
\cs_gset:Npn \otfs_bf_Pi: {#2{\Pi}}
\cs_gset:Npn \otfs_bf_Sigma: {#2{\Sigma}}
\cs_gset:Npn \otfs_bf_Upsilon: {#2{\Upsilon}}
\cs_gset:Npn \otfs_bf_Phi: {#2{\Phi}}
\cs_gset:Npn \otfs_bf_Psi: {#2{\Psi}}
\cs_gset:Npn \otfs_bf_Omega: {#2{\Omega}}
}
% \end{macrocode}
%
% Captial Greek letters.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_greek: {
\DeclareMathSymbol{\Gamma} {\mathalpha}{letters}{0}
\DeclareMathSymbol{\Delta} {\mathalpha}{letters}{1}
\DeclareMathSymbol{\Theta} {\mathalpha}{letters}{2}
\DeclareMathSymbol{\Lambda} {\mathalpha}{letters}{3}
\DeclareMathSymbol{\Xi} {\mathalpha}{letters}{4}
\DeclareMathSymbol{\Pi} {\mathalpha}{letters}{5}
\DeclareMathSymbol{\Sigma} {\mathalpha}{letters}{6}
\DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{7}
\DeclareMathSymbol{\Phi} {\mathalpha}{letters}{8}
\DeclareMathSymbol{\Psi} {\mathalpha}{letters}{9}
\DeclareMathSymbol{\Omega} {\mathalpha}{letters}{11}
}
% \end{macrocode}
%
% Script fonts.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_script: {
\cs_gset:Npn \bmmax {2}
\cs_gset:Npn \hmmax {0}
\RequirePackage{eufrak,mathrsfs,bm}
\cs_if_exist:NF \mathbb {\DeclareMathAlphabet{\mathbb}{U}{fplmbb}{m}{n}}
\cs_gset_eq:NN \mathbfup \mathbf
\cs_gset_eq:NN \mathbfit \mathbold
\cs_gset:Npn \mathbfcal ##1 {\bm{\mathcal{##1}}}
\cs_gset:Npn \mathbffrak ##1 {\bm{\mathfrak{##1}}}
\otfs_setup_alpha:NN \mathbold \mathbold
\otfs_setup_greek:NN \mathbold \mathbold
}
% \end{macrocode}
%
% Setup optical sized fonts.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_fontset:nnnnnnnnn {
\str_if_eq_x:nnT{\otfs_fontset:}{#1}{
\str_if_eq_x:nnT{\otfs_mainfont:}{NULL}{
\keys_set:nn{otfs}{mainfont=#2}}
\str_if_eq_x:nnT{\otfs_sansfont:}{NULL}{
\keys_set:nn{otfs}{sansfont=#3}}
\str_if_eq_x:nnT{\otfs_monofont:}{NULL}{
\keys_set:nn{otfs}{monofont=#4}}
\str_if_eq_x:nnT{\otfs_mathfont:}{NULL}{
\keys_set:nn{otfs}{mathfont=#5}}
\str_if_eq_x:nnT{\otfs_psmathfont:}{NULL}{
\keys_set:nn{otfs}{psmathfont=#6}}
\str_if_eq_x:nnT{\otfs_sansscale:}{NULL}{
\keys_set:nn{otfs}{sansscale=#7}}
\str_if_eq_x:nnT{\otfs_monoscale:}{NULL}{
\keys_set:nn{otfs}{monoscale=#8}}
\str_if_eq_x:nnT{\otfs_mathscale:}{NULL}{
\keys_set:nn{otfs}{mathscale=#9}}
}
}
% \end{macrocode}
%
% Process \opt{fontset}.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_fontset: {
\otfs_setup_fontset:nnnnnnnnn{Arno}
{Arno}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Cambria}
{Cambira}{Calibri}{Consolas}{CambriaMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Constantia}
{Constantia}{Calibri}{Consolas}{CambriaMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Garamond}
{Garamond}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Jenson}
{Jenson}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Kepler}
{Kepler}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{LatinModern}
{LMRoman}{LMSans}{LMMono}{LMMath}{NULL}
{NULL}{NULL}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Lucida}
{LucidaBright}{LucidaSans}{LucidaST}{LucidaBrightMath}{NULL}
{NULL}{NULL}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Minion}
{Minion}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Palatino}
{Palatino}{Optima}{Consolas}{NULL}{PAMath}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{TEOTS}
{Minion}{Syntax}{Consolas}{MinionMath}{NULL}
{MatchLowercase}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Times}
{TimesTen}{Helvetica}{Consolas}{NULL}{MTPro}
{MatchLowercase}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Scala}
{Scala}{ScalaSans}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{MatchLowercase}
\otfs_setup_fontset:nnnnnnnnn{Utopia}
{Utopia}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\otfs_setup_fontset:nnnnnnnnn{Warnock}
{Warnock}{Cronos}{Consolas}{MinionMath}{NULL}
{NULL}{MatchLowercase}{NULL}
\cs_if_exist:cF{otfs_font_type_\otfs_mainfont: :}{
\keys_set:nn{otfs}{mainfont=LMRoman}}
\cs_if_exist:cF{otfs_font_type_\otfs_sansfont: :}{
\keys_set:nn{otfs}{sansfont=LMSans}}
\cs_if_exist:cF{otfs_font_type_\otfs_monofont: :}{
\keys_set:nn{otfs}{monofont=LMMono}}
\cs_if_exist:cF{otfs_font_type_\otfs_mathfont: :}{
\keys_set:nn{otfs}{mathfont=LMMath}}
}
% \end{macrocode}
%
% Process \opt{fontscale} etc.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_fontscale: {
\str_if_eq_x:nnF{\otfs_fontscale:}{NULL}{
\str_if_eq_x:nnT{\otfs_sansscale:}{NULL}{
\keys_set:nn{otfs}{sansscale=\otfs_fontscale:}}
\str_if_eq_x:nnT{\otfs_monoscale:}{NULL}{
\keys_set:nn{otfs}{monoscale=\otfs_fontscale:}}
\str_if_eq_x:nnT{\otfs_mathscale:}{NULL}{
\keys_set:nn{otfs}{mathscale=\otfs_fontscale:}}
}
\str_if_eq_x:nnT{\otfs_mainscale:}{NULL}{
\keys_set:nn{otfs}{mainscale=1}}
\str_if_eq_x:nnT{\otfs_sansscale:}{NULL}{
\keys_set:nn{otfs}{sansscale=1}}
\str_if_eq_x:nnT{\otfs_monoscale:}{NULL}{
\keys_set:nn{otfs}{monoscale=1}}
\str_if_eq_x:nnT{\otfs_mathscale:}{NULL}{
\keys_set:nn{otfs}{mathscale=1}}
}
% \end{macrocode}
%
% Process \opt{mainfont} etc.
% \begin{macrocode}
\cs_new:Nn \otfs_setup_mainfont: {
\cs_if_exist:cT {otfs_font_up_\otfs_mainfont: :} {
\cs_set:Nx \otfs_mainfont_up: {\use:c{otfs_font_up_\otfs_mainfont: :}}
\cs_set:Nx \otfs_mainfont_options: {
Scale = \otfs_mainscale:,
Ligatures = {Required, Common, Contextual, TeX},
Numbers = {OldStyle, Proportional},
\otfs_setup_feature:n{\otfs_mainfont:}
}
\setmainfont[\otfs_mainfont_options:]{\otfs_mainfont_up:}
}
}
\cs_new:Nn \otfs_setup_sansfont: {
\cs_if_exist:cT {otfs_font_up_\otfs_sansfont: :} {
\cs_set:Nx \otfs_sansfont_up: {\use:c{otfs_font_up_\otfs_sansfont: :}}
\cs_set:Nx \otfs_sansfont_options: {
Scale = \otfs_sansscale:,
Ligatures = {Required, Common, Contextual, TeX},
Numbers = {OldStyle, Proportional},
\otfs_setup_feature:n{\otfs_sansfont:}
}
\setsansfont[\otfs_sansfont_options:]{\otfs_sansfont_up:}
}
}
\cs_new:Nn \otfs_setup_monofont: {
\cs_if_exist:cT {otfs_font_up_\otfs_monofont: :} {
\cs_set:Nx \otfs_monofont_up: {\use:c{otfs_font_up_\otfs_monofont: :}}
\cs_set:Nx \otfs_monofont_options: {
Scale = \otfs_monoscale:,
Ligatures = {NoRequired, NoCommon, NoContextual},
Numbers = {Lining, Monospaced},
\otfs_setup_feature:n{\otfs_monofont:}
}
\setmonofont[\otfs_monofont_options:]{\otfs_monofont_up:}
}
}
% \end{macrocode}
%
% Setup the math font.
% \begin{macrocode}
\PassOptionsToPackage{slantedGreek}{mathpazo}
\PassOptionsToPackage{slantedGreek,subscriptcorrection}{mtpro2}
\cs_gset:Nn \otfs_setup_mathfont: {
\str_if_eq_x:nnT {\otfs_mathfont:}{MinionMath} {
\setmathfont[
Scale = \otfs_mathscale:,
SizeFeatures = {
{Size = -6.01, Font = MinionMath-Tiny},
{Size = 6.01-8.41, Font = MinionMath-Capt},
{Size = 8.41-13.01, Font = MinionMath-Regular},
{Size = 13.01-19.91, Font = MinionMath-Subh},
{Size = 19.91-, Font = MinionMath-Disp}}]{Minion~Math}
\setmathfont[
Scale = \otfs_mathscale:,
range = {\mathup->\mathup, \mathit->\mathit},
SizeFeatures = {
{Size = -6.01, Font = MinionMath-Tiny},
{Size = 6.01-8.41, Font = MinionMath-Capt},
{Size = 8.41-13.01, Font = MinionMath-Regular},
{Size = 13.01-19.91, Font = MinionMath-Subh},
{Size = 19.91-, Font = MinionMath-Disp}}]{Minion~Math}
\setmathfont[
Scale = \otfs_mathscale:,
range = {\mathbfup->\mathup, \mathbfit->\mathit},
SizeFeatures = {
{Size = -6.01, Font = MinionMath-BoldTiny},
{Size = 6.01-8.41, Font = MinionMath-BoldCapt},
{Size = 8.41-13.01, Font = MinionMath-Bold},
{Size = 13.01-19.91, Font = MinionMath-BoldSubh},
{Size = 19.91-, Font = MinionMath-BoldDisp}}]{Minion~Math}
\setmathfont[Scale = MatchLowercase,
range = {\mathcal,\mathbfcal}, StylisticSet = 1]{XITS~Math}
\setmathfont[Scale = MatchLowercase,
range = {\mathtt,\mathsf,\mathsfup,\mathbfsfup,\mathsfit,\mathbfsfit,
\mathscr,\mathbfscr,\mathfrak,\mathbffrak}]{XITS~Math}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{AsanaMath} {
\luatex_if_engine:T {\directlua{FontBook.Fonts.AsanaMath.LargeOp()}}
\setmathfont[Scale = \otfs_mathscale:]{Asana~Math}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{CambriaMath} {
\luatex_if_engine:T {\directlua{FontBook.Fonts.CambriaMath.LargeOp()}}
\unimathsetup{slash-delimiter = frac}
\setmathfont[Scale = \otfs_mathscale:]{Cambria~Math}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{LMMath} {
\setmathfont[Scale = \otfs_mathscale:]{Latin~Modern~Math}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{LucidaBrightMath} {
\setmathfont[Scale = \otfs_mathscale:]{Lucida~Bright~Math~OT}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{NeoEulerMath} {
\setmathfont[Scale = \otfs_mathscale:]{Neo~Euler}
\setmathfont[Scale = \otfs_mathscale:,
range = {\mathit->\mathup,\mathbf->\mathbfup,\mathbfit->\mathbfup}]
{Neo~Euler}
\setmathfont[Scale = MatchLowercase,
range = {\mathtt,\mathsf,\mathsfup,\mathbfsfup,\mathsfit,\mathbfsfit,
\mathscr,\mathbfscr,\mathbb,\mathbbit}]{XITS~Math}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{PagellaMath} {
\setmathfont[Scale = \otfs_mathscale:]{TeXGyrePagellaMath-Regular}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{TermesMath} {
\setmathfont[Scale = \otfs_mathscale:]{TeXGyreTermesMath-Regular}
}
\str_if_eq_x:nnT {\otfs_mathfont:}{XITSMath} {
\setmathfont[Scale = \otfs_mathscale:]{XITS~Math}
\setmathfont[Scale = \otfs_mathscale:,
range = {\mathcal,\mathbfcal}, StylisticSet = 1]{XITS~Math}
}
\otfs_setup_alpha:NN \mathbf \mathbf
\otfs_setup_greek:NN \mathbf \mathbf
}
\cs_new:Nn \otfs_setup_psmathfont: {
\str_if_eq_x:nnT{\otfs_psmathfont:}{MathPazo}{
\RequirePackage{mathpazo}
\RequirePackage{eucal}
\otfs_setup_script:
}
\str_if_eq_x:nnT{\otfs_psmathfont:}{MTPro}{
\RequirePackage{tgtermes}
\RequirePackage{mtpro2}
\DeclareMathAlphabet{\mathbb} {U}{mt2hrb}{m}{n}
\DeclareMathAlphabet{\mathbbit}{U}{mt2hrb}{m}{it}
\DeclareMathAlphabet{\mathcal} {U}{mt2ms} {m}{it}
\DeclareMathAlphabet{\mathfrak}{U}{mt2mf} {m}{n}
\SetMathAlphabet{\mathcal} {bold}{U}{mt2ms}{b}{it}
\SetMathAlphabet{\mathfrak}{bold}{U}{mt2mf}{b}{n}
\cs_gset:Npn \bmmax {2}
\cs_gset:Npn \hmmax {0}
\RequirePackage{bm}
\cs_gset:Npn \mathbfcal ##1 {\bm{\mathcal{##1}}}
\cs_gset:Npn \mathbffrak ##1 {\bm{\mathfrak{##1}}}
\cs_gset_eq:NN \mathbfup \mbf
\cs_gset_eq:NN \mathbfit \mathbold
\cs_gset_eq:NN \mathscr \mathcal
\cs_gset_eq:NN \mathbfscr \mathbfcal
\otfs_setup_alpha:NN \mathbold \mathbold
\otfs_setup_greek:NN \mathbold \mathbold
}
\str_if_eq_x:nnT{\otfs_psmathfont:}{BAMath}{
\RequirePackage{bamath,baams}
\otfs_setup_greek:
\otfs_setup_script:
}
\str_if_eq_x:nnT{\otfs_psmathfont:}{CHMath}{
\RequirePackage{chmath,chams}
\otfs_setup_greek:
\otfs_setup_script:
}
\str_if_eq_x:nnT{\otfs_psmathfont:}{PAMath}{
\RequirePackage{pamath,paams}
\otfs_setup_greek:
\otfs_setup_script:
}
}
% \end{macrocode}
%
% Loading fonts
% \begin{macrocode}
\PassOptionsToPackage{silent, no-math}{fontspec}
\PassOptionsToPackage{math-style=ISO, bold-style=ISO}{unicode-math}
\bool_new:N \otfs_loaded \bool_set_false:N \otfs_loaded
\AtEndPreamble{
\otfs_setup_fontset:
\otfs_setup_fontscale:
\otfs_setup_psmathfont:
\RequirePackage{fontspec}
\otfs_setup_mainfont:
\otfs_setup_sansfont:
\otfs_setup_monofont:
\str_if_eq_x:nnT {\otfs_psmathfont:}{NULL}{
\RequirePackage{unicode-math}
\otfs_setup_mathfont:
}
\cs_gset:Nn \otfs_use_math_cal:cn {
\cs_if_exist:cTF {mathcal} {
\cs_gset:cn{otfs_cal_#2:}{\mathcal{#2}}
}{
\cs_gset:cn{otfs_cal_#2:}{#2}
}
\cs_gset_eq:cc{#1}{otfs_cal_#2:}
}
\cs_gset:Nn \otfs_use_math_scr:cn {
\cs_if_exist:cTF {mathscr} {
\cs_gset:cn{otfs_scr_#2:}{\mathscr{#2}}
}{
\cs_gset:cn{otfs_scr_#2:}{#2}
}
\cs_gset_eq:cc{#1}{otfs_scr_#2:}
}
\cs_gset:Nn \otfs_use_math_frak:cn {
\cs_if_exist:cTF {mathfrak} {
\cs_gset:cn{otfs_frak_#2:}{\mathfrak{#2}}
}{
\cs_gset:cn{otfs_frak_#2:}{#2}
}
\cs_gset_eq:cc{#1}{otfs_frak_#2:}
}
\cs_gset:Nn \otfs_use_math_bb:cn {
\cs_if_exist:cTF {mathbb} {
\cs_gset:cn{otfs_bb_#2:}{\mathbb{#2}}
}{
\cs_gset:cn{otfs_bb_#2:}{#2}
}
\cs_gset_eq:cc{#1}{otfs_bb_#2:}
}
\cs_gset:Nn \otfs_use_math_bold:cn {
\cs_if_exist:cF {otfs_bf_#2:} {
\cs_gset:cn{otfs_bf_#2:}{\mathbf{#2}}
}
\cs_gset_eq:cc{#1}{otfs_bf_#2:}
}
\bool_set_true:N \otfs_loaded
}
\NewDocumentCommand\UseMathAlphaDef {o m m m} {
\IfNoValueTF{#1}{#4{#3#2}{#2}}{#4{\cs_to_str:N#1}{#2}}}
\NewDocumentCommand\UseMathAlpha {o m m m} {
\bool_if:NTF \otfs_loaded
{\UseMathAlphaDef[#1]{#2}{#3}{#4}}
{\AtEndPreamble{\UseMathAlphaDef[#1]{#2}{#3}{#4}}}}
\ProvideDocumentCommand\UseMathBB {o m}
{\UseMathAlpha[#1]{#2}{bb}{\otfs_use_math_bb:cn}}
\ProvideDocumentCommand\UseMathBold {o m}
{\UseMathAlpha[#1]{#2}{bf}{\otfs_use_math_bold:cn}}
\ProvideDocumentCommand\UseMathCal {o m}
{\UseMathAlpha[#1]{#2}{cal}{\otfs_use_math_cal:cn}}
\ProvideDocumentCommand\UseMathFrak {o m}
{\UseMathAlpha[#1]{#2}{frak}{\otfs_use_math_frak:cn}}
\ProvideDocumentCommand\UseMathScr {o m}
{\UseMathAlpha[#1]{#2}{scr}{\otfs_use_math_scr:cn}}
\bool_if:NT \otfs_predef {
\UseMathBB{T}
\UseMathBold{y}
\UseMathCal{G}
\UseMathCal{N}
}
% \end{macrocode}
Jump to Line
Something went wrong with that request. Please try again.