%% %% This is file `xepersian-mathsdigitspec.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% xepersian.dtx (with options: `table,xepersian-mathsdigitspec.sty') %% %% __________________________________________________ %% %% Copyright (c) Vafa Khalighi 2007-2019 %% bidi-tex GitHub Organisation 2018-2020 %% %% %% %% It may be distributed and/or modified under the LaTeX Project Public License, %% version 1.3c or higher (your choice). The latest version of %% this license is at: http://www.latex-project.org/lppl.txt %% %% This work is “author-maintained” (as per LPPL maintenance status) %% by bidi-tex GitHub Organisation. %% %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{xepersian-mathsdigitspec} [2018/12/16 v1.1.7 Unicode Persian maths digits in XeLaTeX] \def\new@mathgroup{\alloc@8\mathgroup\chardef\@cclvi} \let\newfam\new@mathgroup \def\select@group#1#2#3#4{% \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi {% \ifmmode \ifnum\csname c@mv@\math@version\endcsname<\@cclvi \begingroup \escapechar\m@ne \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3% \globaldefs\@ne \math@fonts \endgroup \init@restore@version \xdef#1{\noexpand\use@mathgroup\noexpand#2% {\number\csname c@mv@\math@version\endcsname}}% \global\advance\csname c@mv@\math@version\endcsname\@ne \else \let#1\relax \@latex@error{Too many math alphabets used in version \math@version}% \@eha \fi \else \expandafter\non@alpherr\fi #1{#4}% }% } \def\document@select@group#1#2#3#4{% \ifx\math@bgroup\bgroup\else\relax\expandafter\@firstofone\fi {% \ifmmode \ifnum\csname c@mv@\math@version\endcsname<\@cclvi \begingroup \escapechar\m@ne \getanddefine@fonts{\csname c@mv@\math@version\endcsname}#3% \globaldefs\@ne \math@fonts \endgroup \expandafter\extract@alph@from@version \csname mv@\math@version\expandafter\endcsname \expandafter{\number\csname c@mv@\math@version\endcsname}% #1% \global\advance\csname c@mv@\math@version\endcsname\@ne \else \let#1\relax \@latex@error{Too many math alphabets used in version \math@version}% \@eha \fi \else \expandafter\non@alpherr\fi #1{#4}% }% } \ExplSyntaxOn \bool_set_false:N \g__fontspec_math_bool \tl_map_inline:nn { \new@mathgroup\cdp@list\cdp@elt\DeclareMathSizes \@DeclareMathSizes\newmathalphabet\newmathalphabet@@\newmathalphabet@@@ \DeclareMathVersion\define@mathalphabet\define@mathgroup\addtoversion \version@list\version@elt\alpha@list\alpha@elt \restore@mathversion\init@restore@version\dorestore@version\process@table \new@mathversion\DeclareSymbolFont\group@list\group@elt \new@symbolfont\SetSymbolFont\SetSymbolFont@\get@cdp \DeclareMathAlphabet\new@mathalphabet\SetMathAlphabet\SetMathAlphabet@ \DeclareMathAccent\set@mathaccent\DeclareMathSymbol\set@mathchar \set@mathsymbol\DeclareMathDelimiter\@xxDeclareMathDelimiter \@DeclareMathDelimiter\@xDeclareMathDelimiter\set@mathdelimiter \set@@mathdelimiter\DeclareMathRadical\mathchar@type \DeclareSymbolFontAlphabet\DeclareSymbolFontAlphabet@ } { \tl_remove_once:Nn \@preamblecmds {\do#1} } \ExplSyntaxOff \newcommand\xepersian@PackageInfo[1]{\PackageInfo{xepersian-mathsdigitspec}{#1}} \newcommand\SetMathCode[4]{% \Umathcode#1="\mathchar@type#2 \csname sym#3\endcsname #4\relax} \newcommand\SetMathCharDef[4]{% \Umathchardef#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 { \int_step_inline:nnnn { `0 } { \c_one } { `9 } { \mathcode ##1 = \numexpr "100 * \symnew@mathbf@font@digits + ##1 \relax } #1 } } \NewDocumentCommand \new@mathit { m } { \orig_mathit:n { \int_step_inline:nnnn { `0 } { \c_one } { `9 } { \mathcode ##1 = \numexpr "100 * \symnew@mathit@font@digits + ##1 \relax } #1 } } \NewDocumentCommand \new@mathrm { m } { \orig_mathrm:n { \int_step_inline:nnnn { `0 } { \c_one } { `9 } { \mathcode ##1 = \numexpr "100 * \symnew@mathrm@font@digits + ##1 \relax } #1 } } \NewDocumentCommand \new@mathsf{ m } { \orig_mathsf:n { \int_step_inline:nnnn { `0 } { \c_one } { `9 } { \mathcode ##1 = \numexpr "100 * \symnew@mathsf@font@digits + ##1 \relax } #1 } } \NewDocumentCommand \new@mathtt{ m } { \orig_mathtt:n { \int_step_inline:nnnn { `0 } { \c_one } { `9 } { \mathcode ##1 = \numexpr "100 * \symnew@mathtt@font@digits + ##1 \relax } #1 } } \cs_new:Npn \__xepersian_mathsdigitspec_error:nxx { \msg_error:nnxx {xepersian-mathsdigitspec} } \cs_new:Nn \__xepersian_mathsdigitspec_msg_new:nnnn { \msg_new:nnxx {#1} {#2} { \tl_trim_spaces:n {#3} } { \tl_trim_spaces:n {#4} } } \char_set_catcode_space:n {32} \__xepersian_mathsdigitspec_msg_new:nnnn {xepersian-mathsdigitspec} {char-not-exist} { The font "#1" does not contain U+#2. } { Select another font and rerun xelatex. } \char_set_catcode_ignore:n {32} \prg_new_conditional:Nnn \__xepersian_mathsdigitspec_primitive_font_char_if_exist:n {p,TF,T,F} { \etex_iffontchar:D \l_fontspec_font "#1 \scan_stop: \prg_return_true: \else: \prg_return_false: \fi: } \clist_new:N \l_xepersian_mathsdigitspec_char_clist \cs_new:Nn \__xepersian_mathsdigitspec_char_set_not_exist_error:nn { \clist_set:Nn \l_xepersian_mathsdigitspec_char_clist { #1 } \clist_map_inline:Nn \l_xepersian_mathsdigitspec_char_clist { \__xepersian_mathsdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathsdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } } } \cs_new:Nn \__xepersian_mathsdigitspec_char_prepend_not_exist_error:nn { \clist_put_left:Nn \l_xepersian_mathsdigitspec_char_clist { #1 } \clist_map_inline:Nn \l_xepersian_mathsdigitspec_char_clist { \__xepersian_mathsdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathsdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } } } \cs_new:Nn \__xepersian_mathsdigitspec_char_append_not_exist_error:nn { \clist_put_right:Nn \l_xepersian_mathsdigitspec_char_clist { #1 } \clist_map_inline:Nn \l_xepersian_mathsdigitspec_char_clist { \__xepersian_mathsdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathsdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } } } \cs_new:Nn \__xepersian_mathsdigitspec_char_not_exist_error:n { \__xepersian_mathsdigitspec_char_set_not_exist_error:nn { 06F0 , 06F1 , 06F2 , 06F3 , 06F4 , 06F5 , 06F6 , 06F7 , 06F8 , 06F9 , 066A , 066B } { #1 } } \DeclareDocumentCommand \setmathdigitfont { O{} m O{} } { \__xepersian_main_setmathdigitfont:nn {#1,#3} {#2} } \cs_new:Nn \__xepersian_main_setmathdigitfont:nn { \let\glb@currsize\relax \fontspec_set_family:Nnn \g__xepersian_mathdigitsfamily_tl {Ligatures=PersianTeX,#1} {#2} \__xepersian_setmathdigitfont_hook:nn {#1} {#2} \xepersian@PackageInfo{Defining the default Persian maths digits font as '#2'} \DeclareSymbolFont{OPERATORS} {\g_fontspec_encoding_tl}{\g__xepersian_mathdigitsfamily_tl} {m}{n} \DeclareSymbolFont{new@mathbf@font@digits}{\g_fontspec_encoding_tl}{\g__xepersian_mathdigitsfamily_tl}{bx}{n} \DeclareSymbolFont{new@mathit@font@digits}{\g_fontspec_encoding_tl}{\g__xepersian_mathdigitsfamily_tl}{m}{it} \DeclareSymbolFont{new@mathrm@font@digits}{\g_fontspec_encoding_tl}{\g__xepersian_mathdigitsfamily_tl}{m}{n} \__xepersian_mathsdigitspec_char_not_exist_error:n { #2 } \def\persianmathsdigits{% \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}{\mathord}{OPERATORS}{"066B} \tl_set_eq:NN \mathbf \new@mathbf \tl_set_eq:NN \mathit \new@mathit \tl_set_eq:NN \mathrm \new@mathrm} } \cs_set_eq:NN \__xepersian_setmathdigitfont_hook:nn \use_none:nn \DeclareDocumentCommand \setmathsfdigitfont { O{} m O{} } { \__xepersian_main_setmathsfdigitfont:nn {#1,#3} {#2} } \cs_new:Nn \__xepersian_main_setmathsfdigitfont:nn { \fontspec_set_family:Nnn \g__xepersian_mathsfdigitfamily_tl {Ligatures=PersianTeX,#1} {#2} \__xepersian_setmathsfdigitfont_hook:nn {#1} {#2} \DeclareSymbolFont{new@mathsf@font@digits}{\g_fontspec_encoding_tl}{\g__xepersian_mathsfdigitfamily_tl}{m}{n} \__xepersian_mathsdigitspec_char_not_exist_error:n { #2 } \def\persianmathsfdigits{\tl_set_eq:NN \mathsf \new@mathsf} } \cs_set_eq:NN \__xepersian_setmathsfdigitfont_hook:nn \use_none:nn \DeclareDocumentCommand \setmathttdigitfont { O{} m O{} } { \__xepersian_main_setmathttdigitfont:nn {#1,#3} {#2} } \cs_new:Nn \__xepersian_main_setmathttdigitfont:nn { \fontspec_set_family:Nnn \g__xepersian_mathttdigitfamily_tl {Ligatures=PersianTeX,#1} {#2} \__xepersian_setmathttdigitfont_hook:nn {#1} {#2} \DeclareSymbolFont{new@mathtt@font@digits}{\g_fontspec_encoding_tl}{\g__xepersian_mathttdigitfamily_tl}{m}{n} \__xepersian_mathsdigitspec_char_not_exist_error:n { #2 } \def\persianmathttdigits{\tl_set_eq:NN \mathtt \new@mathtt} } \cs_set_eq:NN \__xepersian_setmathttdigitfont_hook:nn \use_none:nn \ExplSyntaxOff \ifx\newcommand\undefined\else \newcommand{\ZifferAn}{} \fi \mathchardef\ziffer@DotOri="013A {\ZifferAn \catcode`\.=\active\gdef.{\begingroup\obeyspaces\futurelet\n\ziffer@dcheck}} \def\ziffer@dcheck{\ziffer@check\ZifferLeer\ziffer@DotOri} \def\ziffer@check#1#2{% \ifx\n1\endgroup#1\else \ifx\n2\endgroup#1\else \ifx\n3\endgroup#1\else \ifx\n4\endgroup#1\else \ifx\n5\endgroup#1\else \ifx\n6\endgroup#1\else \ifx\n7\endgroup#1\else \ifx\n8\endgroup#1\else \ifx\n9\endgroup#1\else \ifx\n0\endgroup#1\else \ifx\n\overline\endgroup#1\else \endgroup#2% \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi} \mathcode`.="8000\relax \def\ZifferLeer{\ifx\decimalseparator\undefined .\else \decimalseparator\fi} \def\DefaultInlineMathsDigits{\def\SetInlineMathsDigits{}} \def\DefaultDisplayMathsDigits{\def\SetDisplayMathsDigits{}} \def\DefaultMathsDigits{% \DefaultInlineMathsDigits% \DefaultDisplayMathsDigits% } \def\PersianInlineMathsDigits{\def\SetInlineMathsDigits{% \ifx\persianmathsdigits\undefined\else\persianmathsdigits\fi% \ifx\persianmathsfdigits\undefined\else\persianmathsfdigits\fi% \ifx\persianmathttdigits\undefined\else\persianmathttdigits\fi}} \def\PersianDisplayMathsDigits{\def\SetDisplayMathsDigits{% \ifx\persianmathsdigits\undefined\else\persianmathsdigits\fi% \ifx\persianmathsfdigits\undefined\else\persianmathsfdigits\fi% \ifx\persianmathttdigits\undefined\else\persianmathttdigits\fi}} \def\PersianMathsDigits{% \PersianInlineMathsDigits% \PersianDisplayMathsDigits% } \def\AutoInlineMathsDigits{\def\SetInlineMathsDigits{% \ifx\persianmathsdigits\undefined\else\if@nonlatin\persianmathsdigits\fi\fi% \ifx\persianmathsfdigits\undefined\else\if@nonlatin\persianmathsfdigits\fi\fi% \ifx\persianmathttdigits\undefined\else\if@nonlatin\persianmathttdigits\fi\fi}} \def\AutoDisplayMathsDigits{\def\SetDisplayMathsDigits{% \ifx\persianmathsdigits\undefined\else\if@nonlatin\persianmathsdigits\fi\fi% \ifx\persianmathsfdigits\undefined\else\if@nonlatin\persianmathsfdigits\fi\fi% \ifx\persianmathttdigits\undefined\else\if@nonlatin\persianmathttdigits\fi\fi}} \def\AutoMathsDigits{% \AutoInlineMathsDigits% \AutoDisplayMathsDigits% } \AutoMathsDigits \everymath\expandafter{\the\everymath\SetInlineMathsDigits% \let\SetDisplayMathsDigits\relax% } \everydisplay\expandafter{% \the\everydisplay\SetDisplayMathsDigits% \let\SetInlineMathsDigits\relax% } \endinput %% %% End of file `xepersian-mathsdigitspec.sty'.