diff options
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty | 104 |
1 files changed, 86 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty b/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty index eb6978c849a..9206e637651 100644 --- a/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty +++ b/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty @@ -14,7 +14,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{xepersian-mathsdigitspec} - [2011/01/01 v0.6b Unicode Persian maths digits in XeLaTeX] + [2011/03/01 v0.9 Unicode Persian maths digits in XeLaTeX] \ExplSyntaxOn \bool_set_false:N \g_fontspec_math_bool \ExplSyntaxOff @@ -37,27 +37,90 @@ \XeTeXmathcode#1="\mathchar@type#2 \csname sym#3\endcsname #4\relax} \newcommand\SetMathCharDef[4]{% \XeTeXmathchardef#1="\mathchar@type#2 \csname sym#3\endcsname #4\relax} +\ExplSyntaxOn +\cs_new_eq:NN \orig_mathbf:n \mathbf +\cs_new_eq:NN \orig_mathit:n \mathit +\cs_new_eq:NN \orig_mathrm:n \mathrm +\cs_new_eq:NN \orig_mathsf:n \mathsf +\cs_new_eq:NN \orig_mathtt:n \mathtt +\NewDocumentCommand \new@mathbf { m } { + \orig_mathbf:n { + \prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathbf@font@digits + ##1 \relax + } + #1 + } +} +\NewDocumentCommand \new@mathit { m } { + \orig_mathit:n { + \prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathit@font@digits + ##1 \relax + } + #1 + } +} +\NewDocumentCommand \new@mathrm { m } { + \orig_mathrm:n { + \prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathrm@font@digits + ##1 \relax + } + #1 + } +} +\NewDocumentCommand \new@mathsf{ m } { + \orig_mathsf:n { + \prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathsf@font@digits + ##1 \relax + } + #1 + } +} +\NewDocumentCommand \new@mathtt{ m } { + \orig_mathtt:n { + \prg_stepwise_inline:nnnn { `0 } { \c_one } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathtt@font@digits + ##1 \relax + } + #1 + } +} +\ExplSyntaxOff \newcommand\setdigitfont[2][]{% \let\glb@currsize\relax \setkeys*[xepersian-mathsdigitspec]{options}{#1}% - \edef\@tempa{\noexpand\zf@fontspec{% + \edef\@tempa{\noexpand\zf@fontspec{Mapping=parsidigits,% \XKV@rm}{#2}}\@tempa \xepersian@PackageInfo{Defining the default Persian maths digits font as '#2'} \DeclareSymbolFont{OPERATORS} {EU1}{\zf@family} {m}{n} + \DeclareSymbolFont{new@mathbf@font@digits}{EU1}{\zf@family}{bx}{n} + \DeclareSymbolFont{new@mathit@font@digits}{EU1}{\zf@family}{m}{it} + \DeclareSymbolFont{new@mathrm@font@digits}{EU1}{\zf@family}{m}{n} \def\persianmathsdigits{% - \SetMathCode{`0}{\mathord}{OPERATORS}{"06F0} - \SetMathCode{`1}{\mathord}{OPERATORS}{"06F1} - \SetMathCode{`2}{\mathord}{OPERATORS}{"06F2} - \SetMathCode{`3}{\mathord}{OPERATORS}{"06F3} - \SetMathCode{`4}{\mathord}{OPERATORS}{"06F4} - \SetMathCode{`5}{\mathord}{OPERATORS}{"06F5} - \SetMathCode{`6}{\mathord}{OPERATORS}{"06F6} - \SetMathCode{`7}{\mathord}{OPERATORS}{"06F7} - \SetMathCode{`8}{\mathord}{OPERATORS}{"06F8} - \SetMathCode{`9}{\mathord}{OPERATORS}{"06F9} + \SetMathCode{`0}{\mathalpha}{OPERATORS}{`0} + \SetMathCode{`1}{\mathalpha}{OPERATORS}{`1} + \SetMathCode{`2}{\mathalpha}{OPERATORS}{`2} + \SetMathCode{`3}{\mathalpha}{OPERATORS}{`3} + \SetMathCode{`4}{\mathalpha}{OPERATORS}{`4} + \SetMathCode{`5}{\mathalpha}{OPERATORS}{`5} + \SetMathCode{`6}{\mathalpha}{OPERATORS}{`6} + \SetMathCode{`7}{\mathalpha}{OPERATORS}{`7} + \SetMathCode{`8}{\mathalpha}{OPERATORS}{`8} + \SetMathCode{`9}{\mathalpha}{OPERATORS}{`9} \SetMathCode{`\%}{\mathbin}{OPERATORS}{`٪} - \SetMathCharDef{\decimalseparator}{\mathpunct}{OPERATORS}{"066B}} + \SetMathCharDef{\decimalseparator}{\mathpunct}{OPERATORS}{"066B} + \let\mathbf\new@mathbf + \let\mathit\new@mathit + \let\mathrm\new@mathrm} } +\newcommand*\setmathsfdigitfont[2][]{% +\zf@fontspec{Mapping=parsidigits,#1}{#2}% +\let\zf@sfmaths\zf@family +\DeclareSymbolFont{new@mathsf@font@digits}{EU1}{\zf@family}{m}{n} +\def\persianmathsfdigits{\let\mathsf\new@mathsf}} +\newcommand*\setmathttdigitfont[2][]{% +\zf@fontspec{Mapping=parsidigits,#1}{#2}% +\let\zf@ttmaths\zf@family +\DeclareSymbolFont{new@mathtt@font@digits}{EU1}{\zf@family}{m}{n} +\def\persianmathttdigits{\let\mathtt\new@mathtt}} \ifx\newcommand\undefined\else \newcommand{\ZifferAn}{} \fi @@ -90,12 +153,17 @@ \mathcode`.="8000\relax \def\ZifferLeer{\ifx\decimalseparator\undefied .\else \decimalseparator\fi} \def\DefaultMathsDigits{\def\SetMathsDigits{}} -\def\PersianMathsDigits{\def\SetMathsDigits{\ifx\persianmathsdigits\undefied\else\persianmathsdigits\fi}} -\def\AutoMathsDigits{\def\SetMathsDigits{\ifx\persianmathsdigits\undefied\else\if@Latin\else\persianmathsdigits\fi\fi}} +\def\PersianMathsDigits{\def\SetMathsDigits{% +\ifx\persianmathsdigits\undefied\else\persianmathsdigits\fi% +\ifx\persianmathsfdigits\undefied\else\persianmathsfdigits\fi% +\ifx\persianmathttdigits\undefied\else\persianmathttdigits\fi}} +\def\AutoMathsDigits{\def\SetMathsDigits{% +\ifx\persianmathsdigits\undefied\else\if@Latin\else\persianmathsdigits\fi\fi% +\ifx\persianmathsfdigits\undefied\else\if@Latin\else\persianmathsfdigits\fi\fi% +\ifx\persianmathttdigits\undefied\else\if@Latin\else\persianmathttdigits\fi\fi}} \AutoMathsDigits -\everymath{\SetMathsDigits} -\g@addto@macro\document{\everydisplay{\predisplaydirection=0 \SetMathsDigits} -\@ifpackageloaded{amsmath}{\everydisplay\@xp{\the\everydisplay \@displaytrue}}{}} +\everymath\expandafter{\the\everymath\SetMathsDigits} +\g@addto@macro\document{\everydisplay\expandafter{\the\everydisplay\SetMathsDigits}} %% %% Copyright © 2008–2011 Vafa Khalighi <vafakhlgh@gmail.com> %% |