% Copyright at Nahid Hossain , Asst. Professor, UIU % nahid@cse.uiu.ac.bd / mailbox.nahid@gmail.com \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{bangla}[2023/02/02] \RequirePackage{fontspec} \RequirePackage{etoolbox} \RequirePackage{polyglossia} \RequirePackage{CharisSIL} \setmainlanguage{english} \setotherlanguage{bengali} \newfontface\bdnhtranslitfont{CharisSIL-Regular.ttf} \DeclareTextFontCommand{\translitfont}{\bdnhtranslitfont} \newfontface\banglaipafont{CharisSIL-Regular.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}