blob: 44aef51a8749181e44bcdee492e686a82161bad9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{simurgh-mathdigitspec}[2013/12/01 v0.01a unicode parsi math digits]
\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
\ExplSyntaxOff
\def\@preamblecmds{}
\newcommand\simurgh@not@onlypreamble[1]{{%
\def\do##1{\ifx#1##1\else\noexpand\do\noexpand##1\fi}%
\xdef\@preamblecmds{\@preamblecmds}}}
\simurgh@not@onlypreamble\@preamblecmds
\def\simurgh@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\simurgh@NotprerrMessage##1}\noexpand\@eha}}%
\@preamblecmds}
\def\simurgh@NotprerrMessage#1{%
\simurgh@error%
{\noexpand\string#1 \noexpand\simurgh@notprerr}{}%
}
\def\nocite#1{%
\@bsphack{\setbox0=\hbox{\cite{#1}}}\@esphack}
\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
}
}
\newcommand\setmathparsidigitfont[2][]{%
\let\glb@currsize\relax
\fontspec_set_family:Nnn \simurgh@digits@family {#1}{#2}
\simurgh@info{defining the default parsi math digits font as '#2'}
\DeclareSymbolFont{OPERATORS} {EU2}{\simurgh@digits@family} {m}{n}
\DeclareSymbolFont{new@mathbf@font@digits}{EU2}{\simurgh@digits@family}{bx}{n}
\DeclareSymbolFont{new@mathit@font@digits}{EU2}{\simurgh@digits@family}{m}{it}
\DeclareSymbolFont{new@mathrm@font@digits}{EU2}{\simurgh@digits@family}{m}{n}
\def\parsimathdigits{%
\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}{`۹}
\SetMathCharDef{\%}{\mathbin}{OPERATORS}{`٪}
\SetMathCharDef{\decimalseparator}{\mathpunct}{OPERATORS}{"066B}
\cs_set_eq:NN \mathbf \new@mathbf
\cs_set_eq:NN \mathit \new@mathit
\cs_set_eq:NN \mathrm \new@mathrm}
}
\DeclareDocumentCommand \setmathsfparsidigitfont { O{} m } {
\fontspec_set_family:Nnn \g_fontspec_mathsf_tl {#1}{#2}
\DeclareSymbolFont{new@mathsf@font@digits}{EU2}{\g_fontspec_mathsf_tl}{m}{n}
\def\parsimathsfdigits{\cs_set_eq:NN \mathsf \new@mathsf}
}
\DeclareDocumentCommand \setmathttparsidigitfont { O{} m } {
\fontspec_set_family:Nnn \g_fontspec_mathtt_tl {#1}{#2}
\DeclareSymbolFont{new@mathtt@font@digits}{EU2}{\g_fontspec_mathtt_tl}{m}{n}
\def\parsimathttdigits{\cs_set_eq:NN \mathtt \new@mathtt}
}
\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
\endgroup#2%
\fi
\fi
\fi
\fi
\fi
\fi
\fi
\fi
\fi
\fi}
\mathcode`.="8000\relax
\def\ZifferLeer{\ifx\decimalseparator\undefied .\else \decimalseparator\fi}
\def\DefaultMathDigits{\def\SetMathDigits{}}
\def\ParsiMathDigits{\def\SetMathDigits{%
\ifx\parsimathdigits\undefied\else\parsimathdigits\fi%
\ifx\parsimathsfdigits\undefied\else\parsimathsfdigits\fi%
\ifx\parsimathttdigits\undefied\else\parsimathttdigits\fi}}
\def\AutoMathDigits{\def\SetMathDigits{%
\ifx\parsimathdigits\undefied\else\if@Latin\else\parsimathdigits\fi\fi%
\ifx\parsimathsfdigits\undefied\else\if@Latin\else\parsimathsfdigits\fi\fi%
\ifx\parsimathttdigits\undefied\else\if@Latin\else\parsimathttdigits\fi\fi}}
\everymath\expandafter{\the\everymath\SetMathDigits}
\g@addto@macro\document{\everydisplay\expandafter{\the\everydisplay\SetMathDigits}}
\endinput
|