Using expl3 regex and replace functions, for xelatex or lualatex, as a sort of manual way of doing the ucharclasses
functionality mentioned in @Davislor 's comment.
The colours are just for testing, to show that the glyphs are coming in from different fonts.
MWE
\documentclass[12pt,a4paper]{article}
\usepackage{xcolor}
% For a bilingual document
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\defaultfontfeatures{Ligatures=TeX}
% Times New Roman used for English
\setmainfont[Mapping=tex-text, Ligatures=TeX]{Times New Roman}
\setmainlanguage[numerals=Bengali,
changecounternumbering=true]{bengali}
\setotherlanguage{english}
%Punctuation (quotes) source:
\newfontfamily\ftpunct{Times New Roman}[Colour=red]%for testing
%Digits
\newfontfamily\ftdigits{Noto Sans Devanagari}[Colour=blue]%for testing
% Bengali
\newfontfamily\bengalifont[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{Kalpurush}%SolaimanLipi}
\newfontfamily\bengalifontbf[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{Kalpurush}%SolaimanLipi}
\newfontfamily\bengalifontsf[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{Kalpurush}%SolaimanLipi}SolaimanLipi}
\title{LaTeX ইংলিশ ডকুমেন্টে বাংলা বোল্ড এবং ইটালিক ফন্ট লেখাটি কীভাবে লিখবেন?}
\author{MKS}
%========================
\ExplSyntaxOn
\tl_new:N \l_myxuchar_tl
\tl_new:N \l_myxucharb_tl
\NewDocumentEnvironment{xuchare}{ +b }
{
\tl_set:Nn \l_myxuchar_tl { #1 }
\doxuchar
\tl_use:N \l_myxuchar_tl
}{}
\NewDocumentCommand{\xuchar}{ m }
{
\tl_set:Nn \l_myxucharb_tl { #1 }
\doxucharb
\tl_use:N \l_myxucharb_tl
}{}
\newcommand\doxuchar{
\regex_replace_all:nnN %opening quote
{
([\`]+)
([ঀ-]{1}) % Bengali glyphs: 0980 to 09FF
}
{
\cB\{
\c{formatquotes}
\1
\cE\}
\2
}
\l_myxuchar_tl
\regex_replace_all:nnN %closing quote
{
([ঀ-]{1}) % Bengali glyphs: 0980 to 09FF
([\']+)
}
{
\1
\cB\{
\c{formatquotes}
\2
\cE\}
}
\l_myxuchar_tl
%Bengali digits to Devanagari
\tl_replace_all:Nnn \l_myxuchar_tl { ০ } { {\formatdigits ०} }
\tl_replace_all:Nnn \l_myxuchar_tl { ১ } { {\formatdigits १} }
\tl_replace_all:Nnn \l_myxuchar_tl { ২ } { {\formatdigits २} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৩ } { {\formatdigits ३} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৪ } { {\formatdigits ४} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৫ } { {\formatdigits ५} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৬ } { {\formatdigits ६} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৭ } { {\formatdigits ७} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৮ } { {\formatdigits ८} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৯ } { {\formatdigits ९} }
}
\newcommand\doxucharb{
%Bengali digits to Devanagari
\tl_replace_all:Nnn \l_myxucharb_tl { ০ } { {\formatdigits ०} }
\tl_replace_all:Nnn \l_myxucharb_tl { ১ } { {\formatdigits १} }
\tl_replace_all:Nnn \l_myxucharb_tl { ২ } { {\formatdigits २} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৩ } { {\formatdigits ३} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৪ } { {\formatdigits ४} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৫ } { {\formatdigits ५} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৬ } { {\formatdigits ६} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৭ } { {\formatdigits ७} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৮ } { {\formatdigits ८} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৯ } { {\formatdigits ९} }
}
\date{\exp_args:Ne \xuchar { \today } }
\ExplSyntaxOff
\newcommand\formatquotes{\ftpunct}%switch
\newcommand\formatdigits{\ftdigits}%switch
\AtBeginEnvironment{document}{\begin{xuchare}}
\AfterEndEnvironment{document}{\end{xuchare}}
\begin{document}
\maketitle
`সাধারন স্টাইল', ``সাধারন স্টাইল'', \textbf{বোল্ড ফন্ট স্টাইল }, \textit{ইটালিক ফন্ট স্টাইল । }
০১২৩৪৫৬৭৮৯
\end{document}
More detail:
SolaimanLipi font does not have left and right quotes.
Changing to a more up-to-date font, or one with more coverage, is the most optimal solution.
FreeSerif font, for example, has Bengali letters, left and right quotes, and Devanagari digits.
Keeping the original font, and adding in glyphs from other fonts, can be done in several ways.
The ucharclasses
package for xelatex was designed for this.
A package-less xelatex/lualatex solution is also possible, in several ways.
(A) Use expl3 regex commands to replace the grave accent `` and single quote '
with left and right quotes in the appropriate font.
The implementation in the MWE uses a document-wide environment for the regex, so is somewhat breakable when new combinations of characters are introduced into the document which then happen to unintentionally match the regular expression.
The regex which searches for a grave accent directly followed by any Bengali character looks like this:
\regex_replace_all:nnN %opening quote
{
([\`]+) ([ঀ-]{1}) % Bengali glyphs: 0980 to 09FF
}
{
\cB\{ \c{formatquotes} \1 \cE\} \2 } \l_myxuchar_tl
(B) Use expl3 replace_all functionality to replace custom unique markup code (qmnl
and qmnr
in the example) with the formatted quotes.
The user must type the markup code in the correct position.
The equivalent replace function, producing the left quote (U+2018), looks like this:
% Replace shortcut
\tl_replace_all:Nnn \l_myxuchar_tl { qmnl } { {\formatquotes ^^^^2018 } }
(C) Create custom commands (\qmol
and \qmor
in the example) which expand to the formatted quotes.
\newcommand\qmol{{\formatquotes ^^^^2018}}
(D) Create a convenient command (\qenquote{}
) which applies the two commands from (C) to an argument passed in as a parameter, namely the text to be quoted.
\newcommand\qenquote[1]{{\formatquotes ^^^^2018}#1{\formatquotes ^^^^2019}}
But much more practical, if a suitable font is available, direct input is possible (E, ‘অ’१ ), and if the quotes are not directly accessible, the \text...
commands can be used (F) -- this latter either in the base font or formatted with the imported font.
With mixing of fonts, much time can be spent searching for fonts that go together well enough to be usable outside of a designer's context.
MWE
\documentclass[12pt,a4paper]{article}
\usepackage[table]{xcolor}
\usepackage{fontspec}
\usepackage{polyglossia}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont[Renderer=HarfBuzz]{Kalpurush}%Times New Roman}
\setmainlanguage[numerals=Bengali,
changecounternumbering=true]{bengali}
\setotherlanguage{english}
%Punctuation (quotes) source:
\newfontfamily\ftpunct{Times New Roman}[Colour=red]%for testing
%Digits: Devanagari
\newfontfamily\ftdigits{Noto Sans Devanagari}[Colour=blue]%for testing
% Bengali
\newfontfamily\bengalifont[Renderer=HarfBuzz,Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{Kalpurush}
\newfontface\bfont{\detokenize{Charu_Chandan_3D_Unicode-Regular}}[Extension=.ttf,
Path=C:/Windows/Fonts/,
Renderer=HarfBuzz,
Script=Bengali,
UprightFont=*,]
\newfontfamily\fall{FreeSerif}[Colour=violet]
%========================
\ExplSyntaxOn
\tl_new:N \l_myxuchar_tl
\tl_new:N \l_myxucharb_tl
\NewDocumentEnvironment{xuchare}{ +b }
{
\tl_set:Nn \l_myxuchar_tl { #1 }
\doxuchar
\tl_use:N \l_myxuchar_tl
}{}
\NewDocumentCommand{\xuchar}{ m }
{
\tl_set:Nn \l_myxucharb_tl { #1 }
\doxucharb
\tl_use:N \l_myxucharb_tl
}{}
%------------------------------- print and run #1
\tl_new:N \l_my_tl
\NewDocumentCommand{\cdr}{ m }{%
\tl_set:Nn \l_my_tl { #1 }
{ \ttfamily\color{blue}
% \token_to_str:N #1
\detokenize{#1}
}
\enspace $\mapsto$ \enspace
\colorbox{ blue!20 }{ \tl_use:N \l_my_tl }
}%
\newcommand\doxuchar{
\regex_replace_all:nnN %opening quote
{
([\`]+)
([ঀ-]{1}) % Bengali glyphs: 0980 to 09FF
}
{
\cB\{
\c{formatquotes}
\1
\cE\}
\2
}
\l_myxuchar_tl
\regex_replace_all:nnN %closing quote
{
([ঀ-]{1}) % Bengali glyphs: 0980 to 09FF
([\']+)
}
{
\1
\cB\{
\c{formatquotes}
\2
\cE\}
}
\l_myxuchar_tl
% Replace shortcut
\tl_replace_all:Nnn \l_myxuchar_tl { qmnl } { {\formatquotes ^^^^2018 } }
\tl_replace_all:Nnn \l_myxuchar_tl { qmnr } { {\formatquotes ^^^^2019 } }
%Bengali digits to Devanagari
\tl_replace_all:Nnn \l_myxuchar_tl { ০ } { {\formatdigits ०} }
\tl_replace_all:Nnn \l_myxuchar_tl { ১ } { {\formatdigits १} }
\tl_replace_all:Nnn \l_myxuchar_tl { ২ } { {\formatdigits २} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৩ } { {\formatdigits ३} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৪ } { {\formatdigits ४} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৫ } { {\formatdigits ५} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৬ } { {\formatdigits ६} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৭ } { {\formatdigits ७} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৮ } { {\formatdigits ८} }
\tl_replace_all:Nnn \l_myxuchar_tl { ৯ } { {\formatdigits ९} }
}
\newcommand\doxucharb{
%Bengali digits to Devanagari
\tl_replace_all:Nnn \l_myxucharb_tl { ০ } { {\formatdigits ०} }
\tl_replace_all:Nnn \l_myxucharb_tl { ১ } { {\formatdigits १} }
\tl_replace_all:Nnn \l_myxucharb_tl { ২ } { {\formatdigits २} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৩ } { {\formatdigits ३} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৪ } { {\formatdigits ४} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৫ } { {\formatdigits ५} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৬ } { {\formatdigits ६} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৭ } { {\formatdigits ७} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৮ } { {\formatdigits ८} }
\tl_replace_all:Nnn \l_myxucharb_tl { ৯ } { {\formatdigits ९} }
}
\date{\exp_args:Ne \xuchar { \today } }
\ExplSyntaxOff
\newcommand\formatquotes{\ftpunct}%switch
\newcommand\formatdigits{\ftdigits}%switch
\newcommand\qmol{{\formatquotes ^^^^2018}}
\newcommand\qmor{{\formatquotes ^^^^2019}}
\newcommand\qenquote[1]{{\formatquotes ^^^^2018}#1{\formatquotes ^^^^2019}}
\AtBeginEnvironment{document}{\begin{xuchare}}
\AfterEndEnvironment{document}{\end{xuchare}}
\newcommand\testtext{সাধারন স্টাইল}
\newcommand\eng[1]{\begin{english}#1\end{english}}
\begin{document}
\eng{Digits:}
০১২৩৪৫৬৭৮৯
\bigskip
\begin{tabular}{lllll}
\rowcolor{blue!5}
Method & Command & How & Input & Output \\
\hline
A & expl3 regex & find-replace & \textasciigrave অ\textquotesingle & `অ' \\
B & expl3 replace & find-replace & qmn{}lঅqmn{}r & qmnlঅqmnr \\
C & macros & expand & \textbackslash qmol অ\textbackslash qmor & \qmol অ\qmor \\
D & command & argument & \textbackslash qenquote\{অ\} & \qenquote{অ} \\
E & in font &FreeSerif & direct input: \colorbox{yellow!40}{\fall{^^^^2018অ^^^^2019१}} & \colorbox{yellow!40}{\fall{^^^^2018অ^^^^2019१}} \\
F & commands & kernel & \textbackslash textquoteleft অ\textbackslash textquoteright & \textquoteleft অ\textquoteright \\
\hline
\end{tabular}
\bigskip
\begin{english}
\cdr{\symbol{39}} \quad quotesingle, {\textquotesingle\small becomes quoteright}
\cdr{\symbol{96}} \quad grave accent, {\textasciigrave\small becomes quoteleft}
\cdr{\symbol{8216}} \quad quoteleft
\cdr{\symbol{8217}} \quad quoteright
\cdr{\symbol{8220}} \quad quotedblleft
\cdr{\symbol{8221}} \quad quotedblright
\cdr{\textquotedblleft}
\cdr{\textquotedblright}
\cdr{\textquotedbl}
\cdr{\textquotesingle}
\cdr{\textasciigrave}
\end{english}
\section{কূল্বনন}
কূল্বনন {\bfont `\testtext' \eng{versus} `সাধারন স্টাইল'} \eng{versus} {\bfont `}সাধারন স্টাইল{\bfont '}
\end{document}