diff options
author | Karl Berry <karl@freefriends.org> | 2022-02-04 22:28:13 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-02-04 22:28:13 +0000 |
commit | a530e59860a2d4cb348c5c8f8d51542b1a8f55e3 (patch) | |
tree | 9918f43faf9361484bf6de38c0fe7354f400ef0a /Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty | |
parent | dfc672770996aaf796e6af361c04a80d0e7efcca (diff) |
xepersian (4feb22)
git-svn-id: svn://tug.org/texlive/trunk@61882 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty | 396 |
1 files changed, 396 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty b/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty new file mode 100644 index 00000000000..be4938f6864 --- /dev/null +++ b/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathdigitspec.sty @@ -0,0 +1,396 @@ +%% +%% This is file `xepersian-mathdigitspec.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% xepersian.dtx (with options: `table,xepersian-mathdigitspec.sty') +%% +%% __________________________________________________ +%% Vafa Khalighi +%% tex-persian@vafa.ac +%% +%% Copyright (c) 2008--2022 Vafa Khalighi +%% Copyright (c) 2018--2020 bidi-tex GitHub Organization +%% +%% 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 Vafa Khalighi. +%% +%% +%% \CheckSum{10959} +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{xepersian-mathdigitspec} + [2022/02/04 v1.1.9 Unicode Persian math 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-mathdigitspec}{#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_int } { `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_int } { `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_int } { `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_int } { `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_int } { `9 } { + \mathcode ##1 = \numexpr "100 * \symnew@mathtt@font@digits + ##1 \relax + } + #1 + } +} + +\cs_new:Npn \__xepersian_mathdigitspec_error:nxx { \msg_error:nnxx {xepersian-mathdigitspec} } +\cs_new:Nn \__xepersian_mathdigitspec_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_mathdigitspec_msg_new:nnnn {xepersian-mathdigitspec} {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_mathdigitspec_primitive_font_char_if_exist:n {p,TF,T,F} + { + \tex_iffontchar:D \l_fontspec_font "#1 \scan_stop: + \prg_return_true: + \else: + \prg_return_false: + \fi: + } + +\clist_new:N \l_xepersian_mathdigitspec_char_clist + +\cs_new:Nn \__xepersian_mathdigitspec_char_set_not_exist_error:nn + { + \clist_set:Nn \l_xepersian_mathdigitspec_char_clist { #1 } + \clist_map_inline:Nn \l_xepersian_mathdigitspec_char_clist { + \__xepersian_mathdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } + } + } + +\cs_new:Nn \__xepersian_mathdigitspec_char_prepend_not_exist_error:nn + { + \clist_put_left:Nn \l_xepersian_mathdigitspec_char_clist { #1 } + \clist_map_inline:Nn \l_xepersian_mathdigitspec_char_clist { + \__xepersian_mathdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } + } + } + +\cs_new:Nn \__xepersian_mathdigitspec_char_append_not_exist_error:nn + { + \clist_put_right:Nn \l_xepersian_mathdigitspec_char_clist { #1 } + \clist_map_inline:Nn \l_xepersian_mathdigitspec_char_clist { + \__xepersian_mathdigitspec_primitive_font_char_if_exist:nF { ##1 }{ \__xepersian_mathdigitspec_error:nxx {char-not-exist} { #2 } { ##1 } } + } + } + +\cs_new:Nn \__xepersian_mathdigitspec_char_not_exist_error:n + { + \__xepersian_mathdigitspec_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 math 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_mathdigitspec_char_not_exist_error:n { #2 } + \def\persianmathdigits{% + \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_mathdigitspec_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_mathdigitspec_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\DefaultZifferLeer{.} +\def\DefaultInlineMathDigits{\def\SetInlineMathDigits{}} +\def\DefaultDisplayMathDigits{\def\SetDisplayMathDigits{}} +\def\DefaultMathDigits{% + \DefaultInlineMathDigits% + \DefaultDisplayMathDigits% +} +\def\PersianInlineMathDigits{\def\SetInlineMathDigits{% +\ifx\persianmathdigits\undefined\else\persianmathdigits\fi% +\ifx\persianmathsfdigits\undefined\else\persianmathsfdigits\fi% +\ifx\persianmathttdigits\undefined\else\persianmathttdigits\fi}} +\def\PersianDisplayMathDigits{\def\SetDisplayMathDigits{% +\ifx\persianmathdigits\undefined\else\persianmathdigits\fi% +\ifx\persianmathsfdigits\undefined\else\persianmathsfdigits\fi% +\ifx\persianmathttdigits\undefined\else\persianmathttdigits\fi}} +\def\PersianMathDigits{% + \PersianInlineMathDigits% + \PersianDisplayMathDigits% +} +\def\AutoInlineMathDigits{\def\SetInlineMathDigits{% +\ifx\persianmathdigits\undefined\else\if@nonlatin\persianmathdigits\fi\fi% +\ifx\persianmathsfdigits\undefined\else\if@nonlatin\persianmathsfdigits\fi\fi% +\ifx\persianmathttdigits\undefined\else\if@nonlatin\persianmathttdigits\fi\fi}} +\def\AutoDisplayMathDigits{\def\SetDisplayMathDigits{% +\ifx\persianmathdigits\undefined\else\if@nonlatin\persianmathdigits\fi\fi% +\ifx\persianmathsfdigits\undefined\else\if@nonlatin\persianmathsfdigits\fi\fi% +\ifx\persianmathttdigits\undefined\else\if@nonlatin\persianmathttdigits\fi\fi}} +\def\AutoMathDigits{% + \AutoInlineMathDigits% + \AutoDisplayMathDigits% +} +\AutoMathDigits +\everymath\expandafter{\the\everymath\SetInlineMathDigits% + \let\SetDisplayMathDigits\relax% +} +\everydisplay\expandafter{% + \the\everydisplay\SetDisplayMathDigits% + \let\SetInlineMathDigits\relax% +} + +\ExplSyntaxOn +\cs_new_eq:NN \orig_ZifferLeer \ZifferLeer + +\NewDocumentCommand \SwitchToDefaultMathDigits { } { + \int_step_inline:nnnn { `0 } { \c_one_int } { `9 } { + \SetMathCode{##1}{\mathalpha}{operators}{##1} + } + \SetMathCode{`\%}{\mathbin}{operators}{`\%} + \tl_set_eq:NN \ZifferLeer \DefaultZifferLeer + \tl_set_eq:NN \mathbf \orig_mathbf:n + \tl_set_eq:NN \mathit \orig_mathit:n + \tl_set_eq:NN \mathrm \orig_mathrm:n + \tl_set_eq:NN \mathsf \orig_mathsf:n + \tl_set_eq:NN \mathtt \orig_mathtt:n +} + +\NewDocumentCommand \SwitchToPersianMathDigits { } { + \int_step_inline:nnnn { `0 } { \c_one_int } { `9 } { + \SetMathCode{##1}{\mathalpha}{OPERATORS}{##1} + } + \SetMathCode{`\%}{\mathbin}{OPERATORS}{`٪} + \tl_set_eq:NN \ZifferLeer \orig_ZifferLeer + \tl_set_eq:NN \mathbf \new@mathbf + \tl_set_eq:NN \mathit \new@mathit + \tl_set_eq:NN \mathrm \new@mathrm + \tl_set_eq:NN \mathsf \new@mathsf + \tl_set_eq:NN \mathtt \new@mathtt +} +\ExplSyntaxOff +\endinput +%% +%% End of file `xepersian-mathdigitspec.sty'. |