summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/polyglossia/gloss-syriac.ldf
blob: dcbaf105503c51b3c06ec6f7e0deaa652874b862 (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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
% Language definition file (part of polyglossia v2.0 -- 2024/02/17)
%
\ProvidesFile{gloss-syriac.ldf}[polyglossia: module for Syriac]

\RequireBidi
\RequirePackage{arabicnumbers}

\PolyglossiaSetup{syriac}{
  bcp47=syr,
  bcp47-language=syr,
  bcp47-script=Syrc,
  script=Syriac,
  scripttag=syrc,
  langtag=SYR,
  direction=RL,
  hyphennames={syriac,nohyphenation},
  fontsetup=true,
  localnumeral=syriacnumerals
  %TODO localalph
}

% BCP-47 compliant aliases
\setlanguagealias*{syriac}{syr}

\def\syriacnumber#1{\@syriacnumber{#1}}%

\newif\if@eastern@numerals
\define@choicekey*+{syriac}{numerals}[\xpg@val\xpg@nr]{eastern,western,abjad}[eastern]{%
   \ifcase\xpg@nr\relax
      % eastern:
      \@eastern@numeralstrue
      \SetLanguageKeys{syriac}{bcp47-extension-u=nu-syrc}%
   \or
      % western:
      \@eastern@numeralsfalse
      \SetLanguageKeys{syriac}{bcp47-extension-u=nu-latn}%
   \or
      % abjad:
      \let\syriacnumber\abjadsyriac%
   \fi
   \xpg@info{Option: Syriac, numerals=\xpg@val}%
}{\xpg@warning{Unknown Syriac numerals option `#1'}}

\newif\ifsyriac@customsep\syriac@customsepfalse
\def\xpg@sepmark{}
\define@key{syriac}{sectionsep}[.]{%
   \syriac@customseptrue%
   \gdef\xpg@sepmark{#1}%
}

% Register default options
\xpg@initialize@gloss@options{syriac}{numerals=western}
	
%\define@key{polyglossia}{syriaclocale}[default]{%
%	\def\@syriac@locale{#1}}
%
%\def\captionssyriac{%
%\def\prefacename{\@ensure@RTL{}}% 
%\def\refname{\@ensure@RTL{}}
%\def\abstractname{\@ensure@RTL{}}%
%\def\bibname{\@ensure@RTL{}}%
%\def\chaptername{\@ensure@RTL{}}%
%\def\appendixname{\@ensure@RTL{}}%
%\def\contentsname{\@ensure@RTL{}}
%\def\listfigurename{\@ensure@RTL{}}%
%\def\listtablename{\@ensure@RTL{}}%
%\def\indexname{\@ensure@RTL{}}%
%\def\figurename{\@ensure@RTL{}}%
%\def\tablename{\@ensure@RTL{}}%
%\def\partname{\@ensure@RTL{}}%
%\def\enclname{\@ensure@RTL{}}%
%\def\ccname{\@ensure@RTL{}}%
%\def\headtoname{\@ensure@RTL{}}%
%\def\pagename{\@ensure@RTL{}}%
%\def\seename{\@ensure@RTL{}}%
%\def\alsoname{\@ensure@RTL{}}%
%\def\proofname{\@ensure@RTL{}}%
%\def\glossaryname{\@ensure@RTL{}}%
%}

\def\datesyriac{%
  \def\syriac@month##1{\ifcase##1%
  \or ܟܢܘܢ ܐܚܪܝ\or ܫܒܛ\or ܐܕܪ\or ܢܝܣܢ\or ܐܝܪ\or ܚܙܝܪܢ\or ܬܡܘܙ\or ܐܒ\or ܐܝܠܘܠ% ܐܠܘܠ
   \or ܬܫܪܝܢ ܩܕܡ% ܬܫܪܝܢ ܩܕܝܡ
   \or ܬܫܪܝܢ ܐܚܪܝ\or ܟܢܘܢ ܩܕܡ% ܟܢܘܢ ܩܕܝܡ
   \fi}%
   \def\today{\@ensure@RTL{\syriacnumber\day{\space}%
    \syriac@month{\month}{\space}\syriacnumber\year}}%
}

\def\syriac@zero{}

\def\abjadsyriac#1{%
\ifnum#1>9999\xpg@ill@value{#1}{abjadsyriac}%
\else%
  \ifnum#1<\z@\space\xpg@ill@value{#1}{abjadsyriac}%
  \else%
    \ifnum#1<10\expandafter\abj@syr@num@i\number#1%
    \else%
      \ifnum#1<100\expandafter\abj@syr@num@ii\number#1%
      \else%
        \ifnum#1<1000\expandafter\abj@syr@num@iii\number#1%
	\else%
          \expandafter\abj@syr@num@iv\number#1%
	\fi%
      \fi%
    \fi%
  \fi%
\fi%
}
\def\abj@syr@num@i#1{%
  \ifcase#1\or\char"0710\or\char"0712\or\char"0713\or\char"0715%
 \or\char"0717\or\char"0718\or\char"0719\or\char"071A\or\char"071B\fi
  \ifnum#1=\z@\syriac@zero\fi}
\def\abj@syr@num@ii#1{%
  \ifcase#1\or\char"071D\or\char"071F\or\char"0720\or\char"0721\or\char"0722%
          \or\char"0723\or\char"0725\or\char"0726\or\char"0728\fi
  \ifnum#1=\z@\fi\abj@syr@num@i}
\def\abj@syr@num@iii#1{%
  \ifcase#1\or\char"0729\or\char"072A\or\char"072B\or\char"072C%
  \or\char"0722\char"0307\or\char"0723\char"0307\or\char"0725\char"0307%
  \or\char"0726\char"0307\or\char"0728\char"0307\fi
  \ifnum#1=\z@\fi\abj@syr@num@ii}
\def\abj@syr@num@iv#1{%
  \ifcase#1\or\char"0710\char"0748\or\char"0712\char"0748%
  \or\char"0713\char"0748\or\char"0715\char"0748%
  \or\char"0717\char"0748\or\char"0718\char"0748%
  \or\char"0719\char"0748\or\char"071A\char"0748\or\char"071B\char"0748\fi
  \ifnum#1=\z@\fi\abj@syr@num@iii}

\def\@syriacnumber#1{%
   \if@eastern@numerals
      %%% we test for the presence of one of ١٢٣٤٥٦٧٨٩٠ in the Syriac font, 
      %%% else we try \arabicfont if defined (and give a warning), 
      %%% else we fall back to the Western numerals.
      \IfCharIsAvailableTF{0661}%
          {\@ensure@LTR{\protect\arabicdigits{\number#1}}}%
          {\@ensure@LTR{\arabicdigits{\number#1}}
           \ifcsdef{arabicfont}%
	     {\@ensure@LTR{\protect\arabicdigits{\number#1}}%
	      \xpg@warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
                           I am using \string\arabicfont instead}}%
	     {\number#1%%% <---changed from \RL{\protect\reset@font\protect\number#1}%
	      \xpg@warning{You have specified the option numerals=eastern for Syriac, but the Syriac font does not contain the appropriate glyphs:
                           since \string\arabicfont is not defined, we'll use Western numerals instead}}%
          }%
   \else
     %%\RL{\protect\reset@font\number#1}%
     \number#1%
   \fi%
}

\def\syriac@numbers{%
   \let\@alph\abjadsyriac%
   \let\@Alph\abjadsyriac%
}

\def\nosyriac@numbers{%
  \let\@alph\latin@alph%
  \let\@Alph\latin@Alph%
}

\newcommand{\syriacnumerals}[2]{\syriacnumber{#2}}

% Store original definition
\let\xpg@save@arabic\@arabic

\def\syriac@globalnumbers{%
  \let\@arabic\syriacnumber%
  \renewcommand\thefootnote{\localnumeral*{footnote}}%
}

\def\nosyriac@globalnumbers{%
  \let\@arabic\xpg@save@arabic%
}

\def\syriac@xetex@capsformat{%
  \let\xpg@save@sepmark\@SepMark%
  \SepMark{\xpg@sepmark}
}

\def\nosyriac@xetex@capsformat{%
   \ifcsdef{xpg@save@sepmark}{%
     \SepMark{\xpg@save@sepmark}
   }{}%
}

\def\syriac@luatex@capsformat{%
  %
  % change chapter and part headings
  \ifsyriac@customsep
     \ifcsdef{chapter}{%
        \let\xpg@save@thesection\thesection%
        \renewcommand*\thesection{\thechapter\xpg@sepmark\@arabic\c@section}
        \let\xpg@save@theequation\theequation%
        \renewcommand*\theequation{%
	    \ifnum \c@chapter>\z@ \thechapter\xpg@sepmark\fi\@arabic\c@equation}
        \let\xpg@save@thefigure\thefigure%
	\renewcommand*\thefigure{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@figure}
        \let\xpg@save@thetable\thetable%
	\renewcommand*\thetable{%
	    \ifnum\c@chapter>\z@\thechapter\xpg@sepmark\fi\@arabic\c@table}
     }{}
     \let\xpg@save@thesubsection\thesubsection%
     \renewcommand\thesubsection
	{\thesection\xpg@sepmark\@arabic\c@subsection}
     \let\xpg@save@thesubsubsection\thesubsubsection%
     \renewcommand\thesubsubsection{\thesubsection\xpg@sepmark\@arabic\c@subsubsection}
     \let\xpg@save@theparagraph\theparagraph%
     \renewcommand\theparagraph
         {\thesubsubsection\xpg@sepmark\@arabic\c@paragraph}
     \let\xpg@save@thesubparagraph\thesubparagraph%
     \renewcommand\thesubparagraph{\theparagraph\xpg@sepmark\@arabic\c@subparagraph}
  \fi% (end \ifsyriac@customsep)
}

\def\nosyriac@luatex@capsformat{%
   \ifcsdef{xpg@save@thesection}{%
        \let\thesection\xpg@save@thesection%
   }{}%
   \ifcsdef{xpg@save@theequation}{%
        \let\theequation\xpg@save@theequation%
   }{}%
   \ifcsdef{xpg@save@thefigure}{%
        \let\thefigure\xpg@save@thefigure%
   }{}%
   \ifcsdef{xpg@save@thetable}{%
        \let\thetable\xpg@save@thetable%
   }{}%
   \ifcsdef{xpg@save@thesubsection}{%
        \let\thesubsection\xpg@save@thesubsection%
   \ifcsdef{xpg@save@thesubsubsection}{%
        \let\thesubsubsection\xpg@save@thesubsubsection%
   }{}%
   }{}%
   \ifcsdef{xpg@save@theparagraph}{%
        \let\theparagraph\xpg@save@theparagraph%
   }{}%
   \ifcsdef{xpg@save@thesubparagraph}{%
        \let\thesubparagraph\xpg@save@thesubparagraph%
   }{}%
}

\def\blockextras@syriac{%
   \ifsyriac@customsep
      \ifxetex
        \syriac@xetex@capsformat
      \else
        \syriac@luatex@capsformat
      \fi   
   \fi
}
%
\def\noextras@syriac{%
    \ifsyriac@customsep
      \ifxetex
        \nosyriac@xetex@capsformat
      \else
        \nosyriac@luatex@capsformat
      \fi   
   \fi
}

\endinput