summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/arabicnumbers.sty
blob: c45aa22a6546f73c772963fc212a623c78d34c1b (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
\ProvidesPackage{arabicnumbers}
        [2010/03/18 v0.2 %
         Formatting of Arabic and Farsi digits and of Arabic abjad numerals]

\def\arabicdigits#1{\expandafter\@arabic@digits #1@}
\def\@arabic@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1٠\else\ifx1#1١\else\ifx2#1٢\else\ifx3#1٣\else\ifx4#1٤\else\ifx5#1٥\else\ifx6#1٦\else\ifx7#1٧\else\ifx8#1٨\else\ifx9#1٩\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@arabic@digits
  \fi
}

\def\farsidigits#1{\expandafter\@farsi@digits #1@}
\def\@farsi@digits#1{%
  \ifx @#1% then terminate
  \else
    \ifx0#1۰\else\ifx1#1۱\else\ifx2#1۲\else\ifx3#1۳\else\ifx4#1۴\else\ifx5#1۵\else\ifx6#1۶\else\ifx7#1۷\else\ifx8#1۸\else\ifx9#1۹\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\@farsi@digits
  \fi
}

\newif\ifabjad@jim@notail
\abjad@jim@notailfalse

\def\abjad#1{%
\ifnum#1>1999\xpg@ill@value{#1}{abjad numeral}%
\else
\ifnum#1<\z@\space\xpg@ill@value{#1}{abjad numeral}%
  \else
    \ifnum#1<10\expandafter\abj@num@i@iso\number#1%
    \else
      \ifnum#1<100\expandafter\abj@num@ii\number#1%
      \else
        \ifnum#1<\@m\expandafter\abj@num@iii\number#1%
        \else
          \ifnum#1<\@M\expandafter\abj@num@iv\number#1%since #1<2000, we must have 1000
          \fi
        \fi
      \fi
    \fi
  \fi
\fi
}
\def\abjad@zero{}
\def\abjad@three{ج\ifabjad@jim@notail\char"200D\fi}
\def\abj@num@i@iso#1{%
  \ifcase#1\or ا\or ب\or\abjad@three\or د%
           \or ه\char"200D\or و\or ز\or ح\or ط\fi%
  \ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@i#1{%
  \ifcase#1\or ا\or ب\or\abjad@three\or د%
           \or ه\or و\or ز\or ح\or ط\fi%
  \ifnum#1=\z@\abjad@zero\fi}
\def\abj@num@ii#1{%
  \ifcase#1\or ي\or ك\or ل\or م\or ن%
           \or س\or ع\or ف\or ص\fi% 
  \ifnum#1=\z@\fi\abj@num@i}
\def\abj@num@iii#1{%
  \ifcase#1\or ق\or ر\or ش\or ت\or ث%
            \or خ\or ذ\or ض\or ظ\fi%
  \ifnum#1=\z@\fi\abj@num@ii}
\def\abj@num@iv#1{%
  \ifcase#1\or غ\fi
  \ifnum#1=\z@\fi\abj@num@iii}
\endinput