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
|
% Language definition file (part of polyglossia v2.2 -- 2024/07/15)
%
\ProvidesFile{gloss-sanskrit.ldf}[polyglossia: module for Sanskrit]
\RequirePackage{devanagaridigits}
\PolyglossiaSetup{sanskrit}{
bcp47=sa-Deva,
bcp47-language=sa,
bcp47-script=Deva,
bcp47-casing=sa-Deva,
langtag=SAN,
hyphennames={sanskrit,prakrit},
hyphenmins={1,3},
frenchspacing=true,
fontsetup=false, % will be done below
localnumeral=sanskritnumerals
}
% BCP-47 compliant aliases
\setlanguagealias*{sanskrit}{sa}
\setlanguagealias*[script=devanagari]{sanskrit}{sa-Deva}
\setlanguagealias*[script=malayalam]{sanskrit}{sa-Mlym}
\setlanguagealias*[script=telugu]{sanskrit}{sa-Telu}
\setlanguagealias*[script=bengali]{sanskrit}{sa-Beng}
\setlanguagealias*[script=kannada]{sanskrit}{sa-Knda}
\setlanguagealias*[script=gujarati]{sanskrit}{sa-Gujr}
\setlanguagealias*[script=latin]{sanskrit}{sa-Latn}
\def\fontsetup@sanskrit@devanagari{%
\SetLanguageKeys{sanskrit}{scripttag=deva,script=Devanagari,bcp47=sa-Deva,bcp47-language=sa,bcp47-script=Deva,bcp47-casing=sa-Deva}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@gujarati{%
\SetLanguageKeys{sanskrit}{scripttag=gujr,script=Gujarati,bcp47=sa-Gujr,bcp47-language=sa,bcp47-script=Gujr,bcp47-casing=sa-Gujr}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@malayalam{%
\SetLanguageKeys{sanskrit}{scripttag=mlym,script=Malayalam,bcp47=sa-Mlym,bcp47-language=sa,bcp47-script=Mlym,bcp47-casing=sa-Mlym}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@bengali{%
\SetLanguageKeys{sanskrit}{scripttag=beng,script=Bengali,bcp47=sa-Beng,bcp47-language=sa,bcp47-script=Beng,bcp47-casing=sa-Beng}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@kannada{%
\SetLanguageKeys{sanskrit}{scripttag=knda,script=Kannada,bcp47=sa-Knda,bcp47-language=sa,bcp47-script=Knda,bcp47-casing=sa-Knda}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@telugu{%
\SetLanguageKeys{sanskrit}{scripttag=telu,script=Telugu,bcp47=sa-Relu,bcp47-language=sa,bcp47-script=Relu,bcp47-casing=sa-Relu}
\SetupNonLatinPolyglossiaFont{sanskrit}}
\def\fontsetup@sanskrit@latin{%
\SetLanguageKeys{sanskrit}{scripttag=latn,script=Latin,bcp47=sa-Latn,bcp47-language=sa,bcp47-script=Latn,bcp47-casing=sa-Latn}
\SetupLatinPolyglossiaFont{sanskrit}}
\newif\ifsanskrit@devanagari@numerals
\sanskrit@devanagari@numeralstrue
\DeclareKeys[polyglossia/gloss/sanskrit]
{
script.code = \@ifundefined{fontsetup@sanskrit@#1}%
{\xpg@error{`#1' is not a valid script for Sanskrit}}%
{\csname fontsetup@sanskrit@#1\endcsname},
script.default:n = devanagari,
numerals.choice:,
numerals / devanagari.code =
{%
\sanskrit@devanagari@numeralstrue
\SetLanguageKeys{sanskrit}{bcp47-extension-u=nu-deva}%
},
numerals / western.code =
{%
\sanskrit@devanagari@numeralsfalse
\SetLanguageKeys{sanskrit}{bcp47-extension-u=nu-latn}%
},
numerals.default:n = devanagari,
numerals/unknown.code = \xpg@warning{Unknown Sanskrit numeral `#1'}
}
% Register default options
\InitializeGlossOptions{sanskrit}{script=devanagari,numerals=devanagari}
% Use \providecommand here as the ldf file might
% be reloaded via BCP.
\providecommand{\sanskritnumerals}[2]{\sanskritnumber{#2}}
\def\sanskritnumber#1{%
\ifsanskrit@devanagari@numerals
\devanagaridigits{\number#1}%
\else
\number#1%
\fi%
}
\ifluatex
\directlua{require('polyglossia-sanskrit')}%
\else
\newXeTeXintercharclass\sanskrit@questionexclamation % ! ? ‼ ⁇ ⁈ ⁉ ‽
\newXeTeXintercharclass\sanskrit@punctthin % : ; danda double_danda
\fi
\def\sanskrit@punctthinspace{{\unskip\thinspace}}
\def\sanskrit@punctuation{%
\ifluatex
\directlua{polyglossia.activate_sanskrit_punct()}%
\else
\XeTeXinterchartokenstate=1%
\XeTeXcharclass `\! \sanskrit@questionexclamation
\XeTeXcharclass `\? \sanskrit@questionexclamation
\XeTeXcharclass `\‼ \sanskrit@questionexclamation
\XeTeXcharclass `\⁇ \sanskrit@questionexclamation
\XeTeXcharclass `\⁈ \sanskrit@questionexclamation
\XeTeXcharclass `\⁉ \sanskrit@questionexclamation
\XeTeXcharclass `\‽ \sanskrit@questionexclamation % interrobang, U+203D
\XeTeXcharclass `\: \sanskrit@punctthin
\XeTeXcharclass `\; \sanskrit@punctthin
\XeTeXcharclass `\। \sanskrit@punctthin % danda, U+0964
\XeTeXcharclass `\॥ \sanskrit@punctthin % double danda, U+0965
\XeTeXinterchartoks \z@ \sanskrit@questionexclamation = \sanskrit@punctthinspace
\XeTeXinterchartoks \z@ \sanskrit@punctthin = \sanskrit@punctthinspace
\XeTeXinterchartoks \sanskrit@questionexclamation \sanskrit@punctthin = \sanskrit@punctthinspace
\fi
}
\def\nosanskrit@punctuation{%
\ifluatex
\directlua{polyglossia.deactivate_sanskrit_punct()}%
\else
\XeTeXcharclass `\! \z@
\XeTeXcharclass `\? \z@
\XeTeXcharclass `\‼ \z@
\XeTeXcharclass `\⁇ \z@
\XeTeXcharclass `\⁈ \z@
\XeTeXcharclass `\⁉ \z@
\XeTeXcharclass `\‽ \z@
\XeTeXcharclass `\: \z@
\XeTeXcharclass `\; \z@
\XeTeXcharclass `\। \z@
\XeTeXcharclass `\॥ \z@
\XeTeXinterchartokenstate=0%
\fi
}
\def\noextras@sanskrit{%
\nosanskrit@punctuation%
}
\def\blockextras@sanskrit{%
\sanskrit@punctuation%
}
\endinput
|