blob: 63e5b5f64394a666f78fe44d96fbd90090f432be (
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
% Copyright at Nahid Hossain , Asst. Professor, UIU
% nahid@cse.uiu.ac.bd / mailbox.nahid@gmail.com
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{bangla}[2021/08/04]
\RequirePackage{fontspec}
\RequirePackage{etoolbox}
\RequirePackage{polyglossia}
\RequirePackage{CharisSIL}
\setmainlanguage{english}
\setotherlanguage{bengali}
\newfontface\bdnhtranslitfont{CharisSIL-R.ttf}
\DeclareTextFontCommand{\translitfont}{\bdnhtranslitfont}
\newfontface\banglaipafont{CharisSIL-R.ttf}
\makeatletter
\def\zztable#1{#1}
\def\zzrow#1#2{\expandafter\gdef\csname B-#2\endcsname{#1}}
\def\banglaipa#1{{\banglaipafont\xgenerateTransliteration#1@}}
\def\xgenerateTransliteration{\futurelet\tmp\xxgenerateTransliteration}
\def\xxgenerateTransliteration{%
\ifx\tmp\@sptoken\space\fi
\xxxgenerateTransliteration
}
\def\xxxgenerateTransliteration#1{%
\expandafter\ifx\csname B-#1\endcsname\relax?%
\expandafter\show\csname B-#1\endcsname
\fi
\csname B-#1\endcsname
\xgenerateTransliteration}
\expandafter\def\csname B-@\endcsname#1{}
\input{banglamap}
\makeatother
\makeatletter
\long\def\@gobbletorelax#1\relax{}
\newcommand\bengalinum[1]{\expandafter\@bengalinum\csname c@#1\endcsname}
\newcommand\@bengalinum[1]{\expandafter\@bengalinum@\the#1\relax}
\newcommand\@bengalinum@[1]
{%
\@gobbletorelax#1\@bengalinum@end\relax
\@bengalinum@digit{#1}%
}
\newcommand\@bengalinum@digit[1]
{%
\ifcase#1
\banglatext{০}\or % 0
\banglatext{১}\or % 1
\banglatext{২}\or % 2
\banglatext{৩}\or % 3
\banglatext{৪}\or % 4
\banglatext{৫}\or % 5
\banglatext{৬}\or % 6
\banglatext{৭}\or % 7
\banglatext{৮}\or % 8
\banglatext{৯}\fi % 9
\@bengalinum@
}
\def\@bengalinum@end#1\@bengalinum@digit#2{}
\makeatother
\newcommand{\banglapage}{\renewcommand\thepage{\bengalinum{page}}}
\newcommand{\banglasection}{\renewcommand\thesection{\bengalinum{section}}
\renewcommand\thesubsection{\thesection.\bengalinum{subsection}}
\renewcommand\thesubsubsection{\thesubsection.\bengalinum{subsubsection}}}
\newcommand{\banglaequation}{\renewcommand\theequation{\bengalinum{equation}}}
\newcommand{\banglatable}{\renewcommand\thetable{\bengalinum{table}}}
\newcommand{\banglafigure}{\renewcommand\thefigure{\bengalinum{figure}}}
\makeatletter
\long\def\@gobbletorelax#1\relax{}
\newcommand\bengalialpha[1]{\expandafter\@bengalialpha\csname c@#1\endcsname}
\newcommand\@bengalialpha[1]{\expandafter\@bengalialpha@\the#1\relax}
\newcommand\@bengalialpha@[1]
{%
\@gobbletorelax#1\@bengalialpha@end\relax
\@bengalialpha@digit{#1}%
}
\newcommand\@bengalialpha@digit[1]
{%
\ifcase#1
\banglatext{ক}\or % 0
\banglatext{ক}\or % 0
\banglatext{খ}\or % 1
\banglatext{গ}\or % 2
\banglatext{ঘ}\or % 3
\banglatext{ঙ}\or % 4
\banglatext{চ}\or % 5
\banglatext{ছ}\or % 6
\banglatext{জ}\or % 7
\banglatext{ঝ}\or % 8
\banglatext{ঞ}\fi % 9
\@bengalialpha@
}
\def\@bengalialpha@end#1\@bengalialpha@digit#2{}
\makeatother
\newcommand{\banglaenumerate}{\renewcommand\theenumi{\bengalinum{enumi}}\renewcommand\theenumii{\bengalialpha{enumii}}}
\ExplSyntaxOn
\tl_new:N \l_mytrans_tl
% transliteration
\NewDocumentCommand{\indictrans}{ m }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
{ \translitfont
\tl_use:N \l_mytrans_tl
}
}
% text (transliteration)
\NewDocumentCommand{\banglatranslit}{ m }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
{ \translitfont
\tl_use:N \l_mytrans_tl
}
}
% multi-line environment
\NewDocumentEnvironment{isoindictranse}{ +b }
{
\tl_set:Nn \l_mytrans_tl { #1 }
\doindictrans
%\bengalifont
{ \translitfont
\tl_use:N \l_mytrans_tl
}
}
{ }
% the mapping
\newcommand\doindictrans{
\tl_replace_all:Nnn \l_mytrans_tl { ড় } { r^^^^0323a }
\tl_replace_all:Nnn \l_mytrans_tl { ড় } { r^^^^0323a }
\tl_replace_all:Nnn \l_mytrans_tl { ঢ় } { r^^^^0323ha }
\tl_replace_all:Nnn \l_mytrans_tl { ঢ় } { r^^^^0323ha }
\tl_replace_all:Nnn \l_mytrans_tl { য় } { y^^^^0307a}
\tl_replace_all:Nnn \l_mytrans_tl { য় } { y^^^^0307a}
\tl_replace_all:Nnn \l_mytrans_tl { ক় } { qa }
\tl_replace_all:Nnn \l_mytrans_tl { খ় } { k͟ha }
\tl_replace_all:Nnn \l_mytrans_tl { গ় } { g^^^^0307a }
\tl_replace_all:Nnn \l_mytrans_tl { জ় } { za }
\tl_replace_all:Nnn \l_mytrans_tl { ফ় } { fa }
\tl_replace_all:Nnn \l_mytrans_tl { অ } { a }
\tl_replace_all:Nnn \l_mytrans_tl { আ } { ā }
\tl_replace_all:Nnn \l_mytrans_tl { ই } { i }
\tl_replace_all:Nnn \l_mytrans_tl { ঈ } { ī }
\tl_replace_all:Nnn \l_mytrans_tl { উ } { u }
\tl_replace_all:Nnn \l_mytrans_tl { ঊ } { ū }
\tl_replace_all:Nnn \l_mytrans_tl { ঋ } { r̥ }
\tl_replace_all:Nnn \l_mytrans_tl { ৠ } { r̥̄ }
\tl_replace_all:Nnn \l_mytrans_tl { ঌ } { l̥ }
\tl_replace_all:Nnn \l_mytrans_tl { ৡ } { l̥̄ }
\tl_replace_all:Nnn \l_mytrans_tl { এ } { ē }
\tl_replace_all:Nnn \l_mytrans_tl { ঐ } { ai }
\tl_replace_all:Nnn \l_mytrans_tl { ও } { ō }
\tl_replace_all:Nnn \l_mytrans_tl { ঔ } { au }
\tl_replace_all:Nnn \l_mytrans_tl { ং } { ṁ }
\tl_replace_all:Nnn \l_mytrans_tl { ঁ } { m̐ }
\tl_replace_all:Nnn \l_mytrans_tl { ঃ } { ḥ }
\tl_replace_all:Nnn \l_mytrans_tl { ক } { ka }
\tl_replace_all:Nnn \l_mytrans_tl { খ } { kha }
\tl_replace_all:Nnn \l_mytrans_tl { গ } { ga }
\tl_replace_all:Nnn \l_mytrans_tl { ঘ } { gha }
\tl_replace_all:Nnn \l_mytrans_tl { ঙ } { ṅa }
\tl_replace_all:Nnn \l_mytrans_tl { চ } { ca }
\tl_replace_all:Nnn \l_mytrans_tl { ছ } { cha }
\tl_replace_all:Nnn \l_mytrans_tl { জ } { ja }
\tl_replace_all:Nnn \l_mytrans_tl { ঝ } { jha }
\tl_replace_all:Nnn \l_mytrans_tl { ঞ } { ña }
\tl_replace_all:Nnn \l_mytrans_tl { ট } { ṭa }
\tl_replace_all:Nnn \l_mytrans_tl { ঠ } { ṭha }
\tl_replace_all:Nnn \l_mytrans_tl { ড } { ḍa }
\tl_replace_all:Nnn \l_mytrans_tl { ঢ } { ḍha }
\tl_replace_all:Nnn \l_mytrans_tl { ণ } { ṇa }
\tl_replace_all:Nnn \l_mytrans_tl { ত } { ta }
\tl_replace_all:Nnn \l_mytrans_tl { থ } { tha }
\tl_replace_all:Nnn \l_mytrans_tl { দ } { da }
\tl_replace_all:Nnn \l_mytrans_tl { ধ } { dha }
\tl_replace_all:Nnn \l_mytrans_tl { ন } { na }
\tl_replace_all:Nnn \l_mytrans_tl { প } { pa }
\tl_replace_all:Nnn \l_mytrans_tl { ফ } { pha }
\tl_replace_all:Nnn \l_mytrans_tl { ব } { ba }
\tl_replace_all:Nnn \l_mytrans_tl { ভ } { bha }
\tl_replace_all:Nnn \l_mytrans_tl { ম } { ma }
\tl_replace_all:Nnn \l_mytrans_tl { য } { ya }
\tl_replace_all:Nnn \l_mytrans_tl { র } { ra }
\tl_replace_all:Nnn \l_mytrans_tl { ৰ } { ra }
\tl_replace_all:Nnn \l_mytrans_tl { ল } { la }
\tl_replace_all:Nnn \l_mytrans_tl { ৱ } { va }
\tl_replace_all:Nnn \l_mytrans_tl { শ } { śa }
\tl_replace_all:Nnn \l_mytrans_tl { ষ } { ṣa }
\tl_replace_all:Nnn \l_mytrans_tl { স } { sa }
\tl_replace_all:Nnn \l_mytrans_tl { হ } { ha }
\tl_replace_all:Nnn \l_mytrans_tl { ঽ } { ’ }
\tl_replace_all:Nnn \l_mytrans_tl { । } { . }
\tl_replace_all:Nnn \l_mytrans_tl { া } { -ā }
\tl_replace_all:Nnn \l_mytrans_tl { ি } { -i }
\tl_replace_all:Nnn \l_mytrans_tl { ী } { -ī }
\tl_replace_all:Nnn \l_mytrans_tl { ু } { -u }
\tl_replace_all:Nnn \l_mytrans_tl { ূ } { -ū }
\tl_replace_all:Nnn \l_mytrans_tl { ৃ } { -r }
\tl_replace_all:Nnn \l_mytrans_tl { ৄ } { -rr }
\tl_replace_all:Nnn \l_mytrans_tl { ে } { -e }
\tl_replace_all:Nnn \l_mytrans_tl { ৈ } { -ai }
\tl_replace_all:Nnn \l_mytrans_tl { ো } { -o }
\tl_replace_all:Nnn \l_mytrans_tl { ৌ } { -au }
\tl_replace_all:Nnn \l_mytrans_tl { ্ } { virama }
\tl_replace_all:Nnn \l_mytrans_tl { ৎ } { t }
\tl_replace_all:Nnn \l_mytrans_tl { ৗ } { - }
\tl_replace_all:Nnn \l_mytrans_tl { ০ } { 0 }
\tl_replace_all:Nnn \l_mytrans_tl { ১ } { 1 }
\tl_replace_all:Nnn \l_mytrans_tl { ২ } { 2 }
\tl_replace_all:Nnn \l_mytrans_tl { ৩ } { 3 }
\tl_replace_all:Nnn \l_mytrans_tl { ৪ } { 4 }
\tl_replace_all:Nnn \l_mytrans_tl { ৫ } { 5 }
\tl_replace_all:Nnn \l_mytrans_tl { ৬ } { 6 }
\tl_replace_all:Nnn \l_mytrans_tl { ৭ } { 7 }
\tl_replace_all:Nnn \l_mytrans_tl { ৮ } { 8 }
\tl_replace_all:Nnn \l_mytrans_tl { ৯ } { 9 }
% tidy-up: inherent a, etc
\regex_replace_all:nnN { a\-(ai) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(au) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-([āiueoīū]{1}) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(rr) } { \1 } \l_mytrans_tl
\regex_replace_all:nnN { a\-(r) } { \1 } \l_mytrans_tl
\tl_replace_all:Nnn \l_mytrans_tl { avirama } { }
\tl_replace_all:Nnn \l_mytrans_tl { ṁ } { ng }
\regex_replace_all:nnN { \-([āiueoīū]{1}) } { \1 } \l_mytrans_tl
%...
}
\ExplSyntaxOff
\newtoggle{langen}
\DeclareOption{shimanto}{\newcommand{\fooA}{font1}}
\DeclareOption{notosansbengali}{\newcommand{\fooA}{font2}}
\DeclareOption{notoserifbengali}{\newcommand{\fooA}{font3}}
\DeclareOption{kalpurush}{\newcommand{\fooA}{font4}}
\ProcessOptions
\ifdefstring{\fooA}{font1}{
\newfontface{\bdnhtext}{fontshimanto.ttf}
\DeclareTextFontCommand{\banglatext}{\bdnhtext}
\newfontfamily{\bdnhbold}{fontshimanto.ttf}[FakeBold=4.0]
\DeclareTextFontCommand{\banglabold}{\bdnhbold}
\newfontfamily{\bdnhitalic}{fontshimanto.ttf}[FakeSlant=0.2]
\DeclareTextFontCommand{\banglaitalic}{\bdnhitalic}
}
{
\ifdefstring{\fooA}{font2}{
\newfontface{\bdnhtext}{Noto Sans Bengali}
\DeclareTextFontCommand{\banglatext}{\bdnhtext}
\newfontfamily{\bdnhbold}{Noto Sans Bengali}[FakeBold=4.0]
\DeclareTextFontCommand{\banglabold}{\bdnhbold}
\newfontfamily{\bdnhitalic}{Noto Sans Bengali}[FakeSlant=0.2]
\DeclareTextFontCommand{\banglaitalic}{\bdnhitalic}
}
{
\ifdefstring{\fooA}{font3}{
\newfontface{\bdnhtext}{Noto Serif Bengali}
\DeclareTextFontCommand{\banglatext}{\bdnhtext}
\newfontfamily{\bdnhbold}{Noto Serif Bengali}[FakeBold=4.0]
\DeclareTextFontCommand{\banglabold}{\bdnhbold}
\newfontfamily{\bdnhitalic}{Noto Serif Bengali}[FakeSlant=0.2]
\DeclareTextFontCommand{\banglaitalic}{\bdnhitalic}
}
{
\ifdefstring{\fooA}{font4}{
\newfontface{\bdnhtext}{fontkalpurush.ttf}
\DeclareTextFontCommand{\banglatext}{\bdnhtext}
\newfontfamily{\bdnhbold}{fontkalpurush.ttf}[FakeBold=4.0]
\DeclareTextFontCommand{\banglabold}{\bdnhbold}
\newfontfamily{\bdnhitalic}{fontkalpurush.ttf}[FakeSlant=0.2]
\DeclareTextFontCommand{\banglaitalic}{\bdnhitalic}
}
{
\newfontface{\bdnhtext}{fontkalpurush.ttf}
\DeclareTextFontCommand{\banglatext}{\bdnhtext}
\newfontfamily{\bdnhbold}{fontkalpurush.ttf}[FakeBold=4.0]
\DeclareTextFontCommand{\banglabold}{\bdnhbold}
\newfontfamily{\bdnhitalic}{fontkalpurush.ttf}[FakeSlant=0.2]
\DeclareTextFontCommand{\banglaitalic}{\bdnhitalic}
}
}
}
}
\newcommand{\banglaallcounters}{\banglapage \banglasection \banglaenumerate \banglaequation \banglatable \banglafigure}
|