diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/bangla/bangla.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/bangla/bangla.sty | 281 |
1 files changed, 281 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/bangla/bangla.sty b/Master/texmf-dist/tex/latex/bangla/bangla.sty new file mode 100644 index 00000000000..2ad61d1bce9 --- /dev/null +++ b/Master/texmf-dist/tex/latex/bangla/bangla.sty @@ -0,0 +1,281 @@ +% Copyright at Nahid Hossain +% nahid@cse.uiu.ac.bd / mailbox.nahid@gmail.com +\NeedsTeXFormat{LaTeX2e}[1994/06/01] +\ProvidesPackage{bangla}[2021/05/13] +\RequirePackage{fontspec} +\RequirePackage{etoolbox} +\RequirePackage{polyglossia} + +\setmainlanguage{english} +\setotherlanguage{bengali} +\newfontface\translitfont{Noto Serif} +\newfontface\banglaipafont{Doulos SIL} + +\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}}} + +\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}}} + + +%\newcommand{\banglasubsectionnum}{\renewcommand\thesection{\bengalinumeral{section}}} + + +\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^^^^0323ha } +\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{\banglatext}{fontshimanto.ttf} +\newfontfamily{\banglabold}{fontshimanto.ttf}[FakeBold=4.0] +\newfontfamily{\banglaitalic}{fontshimanto.ttf}[FakeSlant=0.2] +} +{ + \ifdefstring{\fooA}{font2}{ + \newfontface\banglatext{Noto Sans Bengali} + \newfontfamily{\banglabold}{Noto Sans Bengali}[FakeBold=4.0] + \newfontfamily{\banglaitalic}{Noto Sans Bengali}[FakeSlant=0.2] + } + { + \ifdefstring{\fooA}{font3}{ + \newfontface\banglatext{Noto Serif Bengali} + \newfontfamily{\banglabold}{Noto Serif Bengali}[FakeBold=4.0] + \newfontfamily{\banglaitalic}{Noto Serif Bengali}[FakeSlant=0.2] + } + { + \ifdefstring{\fooA}{font4}{ + \newfontface{\banglatext}{fontkalpurush.ttf} + \newfontfamily{\banglabold}{fontkalpurush.ttf}[FakeBold=4.0] + \newfontfamily{\banglaitalic}{fontkalpurush.ttf}[FakeSlant=0.2] + } + { + \newfontface{\banglatext}{fontkalpurush.ttf} + \newfontfamily{\banglabold}{fontkalpurush.ttf}[FakeBold=4.0] + \newfontfamily{\banglaitalic}{fontkalpurush.ttf}[FakeSlant=0.2] + } + + } + } + +} + + + |