summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty')
-rw-r--r--Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty177
1 files changed, 177 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty b/Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty
new file mode 100644
index 00000000000..7b6f50a4af3
--- /dev/null
+++ b/Master/texmf-dist/tex/lualatex/luapersian/luapersian-mathsdigitspec.sty
@@ -0,0 +1,177 @@
+%%
+%% This is file `luapersian-mathsdigitspec.sty',
+%% generated with the docstrip utility.
+%%
+%% ______________________________________
+%% Copyright © 2011 Vafa Khalighi
+%%
+%% License information appended.
+%%
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{luapersian-mathsdigitspec}
+ [2011/03/01 v0.1 Unicode Persian maths digits in LuaLaTeX]
+\directlua { tex.enableprimitives('',{'Umathcode','Umathchardef'}) }
+\ExplSyntaxOn
+\bool_set_false:N \g_fontspec_math_bool
+\ExplSyntaxOff
+\def\@preamblecmds{}
+\newcommand\not@onlypreamble[1]{{%
+ \def\do##1{\ifx#1##1\else\noexpand\do\noexpand##1\fi}%
+ \xdef\@preamblecmds{\@preamblecmds}}}
+\def\gm@notprerr{ can be used only in preamble (\on@line)}
+\AtBeginDocument{%
+ \def\do#1{\noexpand\do\noexpand#1}%
+ \edef\@preamblecmds{%
+ \def\noexpand\do##1{%
+ \def##1{\noexpand\PackageError{gmutils/LaTeX}%
+ {\noexpand\string##1 \noexpand\gm@notprerr}\noexpand\@eha}}%
+ \@preamblecmds}}
+\def\nocite#1{%
+ \@bsphack{\setbox0=\hbox{\cite{#1}}}\@esphack}
+\newcommand\luapersian@PackageInfo[1]{\PackageInfo{luapersian-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 {
+ \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*[luapersian-mathsdigitspec]{options}{#1}%
+ \edef\@tempa{\noexpand\zf@fontspec{%
+ \XKV@rm}{#2}}\@tempa
+ \luapersian@PackageInfo{Defining the default Persian maths digits font as '#2'}
+ \DeclareSymbolFont{OPERATORS} {EU2}{\zf@family} {m}{n}
+ \DeclareSymbolFont{new@mathbf@font@digits}{EU2}{\zf@family}{bx}{n}
+ \DeclareSymbolFont{new@mathit@font@digits}{EU2}{\zf@family}{m}{it}
+ \DeclareSymbolFont{new@mathrm@font@digits}{EU2}{\zf@family}{m}{n}
+ \def\persianmathsdigits{%
+ \SetMathCode{`0}{\mathalpha}{OPERATORS}{`۰}
+ \SetMathCode{`1}{\mathalpha}{OPERATORS}{`۱}
+ \SetMathCode{`2}{\mathalpha}{OPERATORS}{`۲}
+ \SetMathCode{`3}{\mathalpha}{OPERATORS}{`۳}
+ \SetMathCode{`4}{\mathalpha}{OPERATORS}{`۴}
+ \SetMathCode{`5}{\mathalpha}{OPERATORS}{`۵}
+ \SetMathCode{`6}{\mathalpha}{OPERATORS}{`۶}
+ \SetMathCode{`7}{\mathalpha}{OPERATORS}{`۷}
+ \SetMathCode{`8}{\mathalpha}{OPERATORS}{`۸}
+ \SetMathCode{`9}{\mathalpha}{OPERATORS}{`۹}
+ \SetMathCode{`\%}{\mathbin}{OPERATORS}{`٪}
+ \SetMathCharDef{\decimalseparator}{\mathpunct}{OPERATORS}{"066B}
+ \let\mathbf\new@mathbf
+ \let\mathit\new@mathit
+ \let\mathrm\new@mathrm}
+}
+\newcommand*\setmathsfdigitfont[2][]{%
+\zf@fontspec{Numbers=Parsi,Language=Parsi,#1}{#2}%
+\let\zf@sfmaths\zf@family
+\DeclareSymbolFont{new@mathsf@font@digits}{EU2}{\zf@family}{m}{n}
+\def\persianmathsfdigits{\let\mathsf\new@mathsf}}
+\newcommand*\setmathttdigitfont[2][]{%
+\zf@fontspec{Numbers=Parsi,Language=Parsi,#1}{#2}%
+\let\zf@ttmaths\zf@family
+\DeclareSymbolFont{new@mathtt@font@digits}{EU2}{\zf@family}{m}{n}
+\def\persianmathttdigits{\let\mathtt\new@mathtt}}
+\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
+ \endgroup#2%
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi
+ \fi}
+\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%
+\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\expandafter{\the\everymath\SetMathsDigits}
+\g@addto@macro\document{\everydisplay\expandafter{\the\everydisplay\SetMathsDigits}}
+%%
+%% Copyright © 2011 Vafa Khalighi <vafa018@gmail.com>
+%%
+%% 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.
+%%
+%%
+%%
+%%
+%% End of file `luapersian-mathsdigitspec.sty'.