summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf
blob: 287620615c4be23d3fe7706def737b2c2c5b6572 (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
\ProvidesFile{gloss-sanskrit.ldf}[polyglossia: module for sanskrit]
\RequirePackage{devanagaridigits}

\PolyglossiaSetup{sanskrit}{
  langtag=SAN,
  hyphennames={sanskrit,prakrit},
  hyphenmins={1,3},
  frenchspacing=true,
  fontsetup=false, % will be done below
  %TODO localnumber=sanskritnumber
}

\define@key{sanskrit}{Script}[Devanagari]{%
  \setkeys[xpg@setup]{sanskrit}{script=#1}%
  \ifcsdef{fontsetup@sanskrit@#1}%
    {\csname fontsetup@sanskrit@#1\endcsname}%
    {\xpg@error{`#1' is not a valid script for Sanskrit}%
  }%
}

\def\fontsetup@sanskrit@Devanagari{%
  \def\xpg@scripttag@sanskrit{deva}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Gujarati{%
  \def\xpg@scripttag@sanskrit{gujr}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Malayalam{%
  \def\xpg@scripttag@sanskrit{mlym}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Bengali{%
  \def\xpg@scripttag@sanskrit{beng}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Kannada{%
  \def\xpg@scripttag@sanskrit{knda}%
  \xpg@fontsetup@nonlatin{sanskrit}}
\def\fontsetup@sanskrit@Telugu{%
  \def\xpg@scripttag@sanskrit{telu}%
  \xpg@fontsetup@nonlatin{sanskrit}}

\setkeys{sanskrit}{Script} %sets the default for Devanagari

%% TODO option for numerals (Devanagari or Western)
%\def\tmp@western{Western}
%\newif\ifsanskrit@devanagari@numerals
%\sanskrit@devanagari@numeralstrue
%
%\define@key{sanskrit}{numerals}[Devanagari]{%
%  \def\@tmpa{#1}%
%  \ifx\@tmpa\tmp@western
%    \sanskrit@devanagari@numeralsfalse
%  \fi}

\newXeTeXintercharclass\sanskrit@punctthin % ! ? ; : danda double_danda

\def\sanskrit@punctthinspace{{\unskip\thinspace}}

\def\sanskrit@punctuation{%
  \XeTeXinterchartokenstate=1%
  \XeTeXcharclass `\! \sanskrit@punctthin
  \XeTeXcharclass `\? \sanskrit@punctthin
  \XeTeXcharclass `\; \sanskrit@punctthin
  \XeTeXcharclass `\: \sanskrit@punctthin
  \XeTeXcharclass `\। \sanskrit@punctthin
  \XeTeXcharclass `\॥ \sanskrit@punctthin
  \XeTeXinterchartoks \z@ \sanskrit@punctthin = \sanskrit@punctthinspace
}

\def\nosanskrit@punctuation{%
  \XeTeXcharclass `\! \z@
  \XeTeXcharclass `\? \z@
  \XeTeXcharclass `\; \z@
  \XeTeXcharclass `\: \z@
  \XeTeXcharclass `\। \z@
  \XeTeXcharclass `\॥ \z@
  \XeTeXinterchartokenstate=0%
}

\def\noextras@sanskrit{%
  \nosanskrit@punctuation%
}

\def\blockextras@sanskrit{%
  \sanskrit@punctuation%
}

\endinput