summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/xelatex/xepersian/xepersian-mathsdigitspec.sty
blob: b2f5b4ec1b2f369ed42324fe6ca6cd30879e3ff5 (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
%% This file is xepersian-mathsdigitspec.sty
%%
%% Copyright 2009 by Vafa Khalighi
%%
%%%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{xepersian-mathsdigitspec}
  [2009/01/05 v0.2 Unicode Persian maths digits in XeLaTeX (Author: Vafa Khalighi)]
\@zf@mathfalse
\newif\if@um@fontspec@feature
\def\um@Loop#1\um@Pool{#1\um@Loop#1\um@Pool}
\def\um@Break#1\um@Pool{}
\long\def\um@FOR#1=[#2:#3]\do#4{%
   #1=#2\relax
   \um@Loop #4%
     \advance#1\@ne
     \ifnum#1>#3\relax
       \expandafter\um@Break
     \fi
   \um@Pool}
\newcommand\um@PackageInfo[1]{\PackageInfo{xepersian-mathsdigitspec}{#1}}
\def\um@usv@num{`\0}
\newcommand\SetMathCode[4]{%
  \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}
\newcommand\setdigitfont[2][]{%
  \csname S@\f@size\endcsname
  \def\um@ScriptFeatures{ScriptStyle}%
  \def\um@ScriptScriptFeatures{ScriptScriptStyle}%
  \def\um@ScriptFont{#2}%
  \def\um@ScriptScriptFont{#2}%
  \setkeys*[um]{options}{#1}%
  \edef\@tempa{\noexpand\zf@fontspec{%
   Mapping=parsidigits,SizeFeatures={%
      {Size=\tf@size-},%
      {Size=\sf@size-\tf@size,%
        Font=\um@ScriptFont,%
        \um@ScriptFeatures},%
      {Size=-\sf@size,%
        Font=\um@ScriptScriptFont,%
        \um@ScriptScriptFeatures}},%
    \XKV@rm}{#2}}\@tempa
    \def\um@digitfont{um@digitfont}%
    \um@PackageInfo{Defining the default Persian maths digits font as '#2'}%
    \DeclareSymbolFont{momayez}{EU1}{\zf@family}{m}{n}%
    \SetMathCharDef{\momayez}{\mathpunct}{momayez}{"066B}%
\DeclareSymbolFont{\um@digitfont}
  {\encodingdefault}{\zf@family}{\mddefault}{\updefault}%
\um@def@numbers
}
\newcommand\um@zf@feature[2]{%
  \define@key[zf]{options}{#1}[]{%
    \if@um@fontspec@feature
      #2
    \fi}}
\um@zf@feature{ScriptStyle}{%
  \zf@update@ff{+ssty=0}}
\um@zf@feature{ScriptScriptStyle}{%
  \zf@update@ff{+ssty=1}}
\newcommand\um@setmathcode[3][1]{%
  \@for\um@inp:=#2\do{%
    \um@FOR\@tempcnta=[1:#1]\do{%
      \SetMathCode{\numexpr\um@inp+\@tempcnta-1\relax}
        {\mathalpha}{\um@digitfont}{\numexpr#3+\@tempcnta-1\relax}}}}
\newcommand\um@def@numbers{%
  \um@setmathcode[10]{\um@usv@num}{\um@usv@num}}
\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\momayez\undefied .\else \momayez\fi}
\endinput