3

Please see the MWE below.

\documentclass{article}

\usepackage{polyglossia}
\usepackage{fontspec}
% Bangla
\setmainlanguage[numerals=Devanagari]{bengali}
\newfontfamily\bengalifont[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{SolaimanLipi}
\newfontfamily\bengalifontbf[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{SolaimanLipi}
\newfontfamily\bengalifonttt[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{SolaimanLipi}
\newfontfamily\bengalifontsf[Script=Bengali,AutoFakeBold=4.0,AutoFakeSlant=0.4]{SolaimanLipi}

\setotherlanguage{english}
\defaultfontfeatures{Ligatures=TeX}

% Times New Roman used
\newfontfamily\englishfont[Mapping=tex-text, Ligatures=TeX]{Times New Roman}

\usepackage{csquotes}

\begin{document}

% LaTeX style quotes
``বাংলা ভাষা''

% Double quotes
"বাংলা ভাষা"

% Using package, produces incorrect results
\enquote{বাংলা ভাষা}

% English LaTeX style quotes
\textenglish{``Bengali Language''}

\end{document}

enter image description here

The double quotes in Bengali are either rendered incorrectly or not rendered at all.

The ones in English work fine.

How do I improve the scenario?

I am not particularly enthusiastic about the \enquote solution. This is going to be cumbersome for my large document. If possible, I would like to stick the LaTeX style double single quotes.

(The font used can be found here.)

EDIT 1 As suggested in a comment, I moved the \defaultfontfeatures{Ligatures=TeX} line before the \newfontfamily\bengalifont lines. Unfortunately, that produced an output like the following.

enter image description here

(I also removed the csquotes parts since these are not relevant.)

There was not any warning message regarding missing ligatures or some such.

11
  • Move \defaultfontfeatures{Ligatures=TeX} before loading the Bengali fonts. – egreg Nov 7 '19 at 14:13
  • @egreg That did not work, please see my edits. – Masroor Nov 7 '19 at 15:16
  • That means that the font SolaimanLipi doesn't have the quotes. – egreg Nov 7 '19 at 15:17
  • @egreg What is the best possible (please read painless) approach in that scenario? – Masroor Nov 7 '19 at 15:19
  • Using a better font? But does Bengali use English style quotes to begin with? – egreg Nov 7 '19 at 15:19
3

You should first of all move the \defaultfontfeatures declaration before loading fonts for which you want that Ligatures=TeX apply.

However, if the font hasn't the required glyphs, you can use newunicodechar. You can also define a Bengali quote style.

\documentclass{article}

\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{csquotes}
\usepackage{newunicodechar}

\defaultfontfeatures{Ligatures=TeX}

% Bangla
\setmainlanguage[numerals=Devanagari]{bengali}

\newfontfamily\bengalifont{SolaimanLipi}[
  Script=Bengali,
  AutoFakeBold=4.0,
  AutoFakeSlant=0.4,
]

\setotherlanguage{english}
% Times New Roman used
\newfontfamily\englishfont{Times New Roman}

\newcommand{\testchar}[1]{\iffontchar\font`#1\relax#1\else\textenglish{#1}\fi}
\newunicodechar{“}{\testchar{“}}
\newunicodechar{”}{\testchar{”}}
\newunicodechar{‘}{\testchar{‘}}
\newunicodechar{’}{\testchar{’}}

\DeclareQuoteAlias{english}{bengali} % share the English style

\begin{document}

“বাংলা ভাষা”

\enquote{বাংলা ভাষা}

% English LaTeX style quotes
\textenglish{``Bengali Language''}

\textenglish{“Bengali Language”}

\end{document}

You need to use and , though.

0

This is more a comment with a picture.

Looking at the Latin side of the font, you may need to add in other glyphs. newunicodechar is probably the best way to do that.

Depending on what you need to do, and what you are used to, and how much (if any) keyboard switching is involved, you can also define commands in Bangla, like \let\ৡ\section and \let\হ\tableofcontents, and then use them as normal, \হ and \ৡ{কাকীকৌ}.

Note that SolaimanLipi font has a bold version.

I tried an experiment, using random letters:

dashes quotes and bold

MWE

\documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}
\usepackage{fontspec}

\setmainfont[Script=Bengali]{SolaimanLipi}
\newfontfamily\fpunct{Noto Serif}
\newfontfamily\fdev{Noto Serif Devanagari}

\usepackage{polyglossia}
\setdefaultlanguage[numerals=Bengali,
changecounternumbering=true]{bengali}
\setotherlanguages{english}

\newcommand\bqql{{\fpunct “\thinspace}}
\newcommand\bqqr{{\fpunct\thinspace ”}}
\newcommand\bql{{\fpunct ‘\thinspace}}
\newcommand\bqr{{\fpunct\thinspace ’}}
\newcommand\bc{{\fpunct ,}}
\newcommand\bend{{\fpunct\textendash\ }}
\newcommand\bemd{{\fpunct\textemdash\  }}
\newcommand\bdanda{{\fdev ।\thinspace}}
\newcommand\bddanda{{\fdev ॥\thinspace}}

\let\ৡ\section
\let\হ\tableofcontents
\let\ন\bend
\let\ম\bemd
\let\ড\bdanda
\let\ডড\bddanda

\begin{document}
{\fpunct\small Just to try out the mechanics of the process:}

\হ
\vspace{1ex}
\hrule
\vspace{1ex}

\ৡ{রষেধৗস}
অকথষোধৈঘৄঙী \ন অকথষো \bqql ধৈঘৄঙী\bqqr\  অকথষো \ম\bql ধৈ\bqr\ \ম ঘৄঙী \ড

\noindent\textbf{অকথষোধৈঘৄঙী \ন অকথষো \bqql ধৈঘৄঙী\bqqr\  অকথষো \ম\bql ধৈ\bqr\ \ম ঘৄঙী \ড}
\ৡ{কাকীকৌ}
কাকীকৌ \ড \\
কাকীকৌ \ডড
\end{document}

Correction:

Package commands looking for \section and so on, for example like in titletoc, won't find \ৡ, so one way is to patch everything, or, alternatively, just keep using \section and swap keyboards as usual.

For example, when adding shading to section numbers in the table of contents:

tikz section numbers

MWE2:

\documentclass[12pt]{article}
\usepackage{xcolor}
\pagecolor{red!3}
\usepackage{fontspec}

\setmainfont[Script=Bengali]{SolaimanLipi}
\newfontfamily\fpunct{Noto Serif}
\newfontfamily\fdev{Noto Serif Devanagari}

\usepackage{polyglossia}
\setdefaultlanguage[numerals=Bengali,
changecounternumbering=true]{bengali}
\setotherlanguages{english}

\newcommand\bqql{{\fpunct “\thinspace}}
\newcommand\bqqr{{\fpunct\thinspace ”}}
\newcommand\bql{{\fpunct ‘\thinspace}}
\newcommand\bqr{{\fpunct\thinspace ’}}
\newcommand\bc{{\fpunct ,}}
\newcommand\bend{{\fpunct\textendash\ }}
\newcommand\bemd{{\fpunct\textemdash\  }}
\newcommand\bdanda{{\fdev ।\thinspace}}
\newcommand\bddanda{{\fdev ॥\thinspace}}

\let\ৡ\section
\let\হ\tableofcontents
\let\ন\bend
\let\ম\bemd
\let\ড\bdanda
\let\ডড\bddanda

\usepackage{tikz}
\usetikzlibrary{shadows.blur}

\newcommand\bframe[1]{%
\begin{tikzpicture}
\node [shade,
      top color=red!40,
      bottom color=violet!5,
      rounded corners=2pt,
      blur shadow={shadow blur steps=5,violet}
    ] {#1};
      \end{tikzpicture}%
}

\usepackage{titlesec}
\titleformat{\section}{\large}{\bframe{\thesection}}{0.75em}{}

\usepackage{titletoc}
\titlecontents{section}
[1em]%left
{}%abovecode
{\bframe{\thecontentslabel}\hspace{0.75em}}%numbered format
{\huge}%numberless format
{\titlerule*[1pc]{.}\contentspage} % page number
[]%belowcode

\begin{document}

\হ
\vspace{1ex}
\hrule
\vspace{1ex}

\section{রষেধৗস}
অকথষোধৈঘৄঙী \ন অকথষো \bqql ধৈঘৄঙী\bqqr\  অকথষো \ম\bql ধৈ\bqr\ \ম ঘৄঙী \ড

\noindent\textbf{অকথষোধৈঘৄঙী \ন অকথষো \bqql ধৈঘৄঙী\bqqr\  অকথষো \ম\bql 
\begin{tikzpicture}
\node [shade,
      top color=blue!40,
      bottom color=blue!5,
      rounded corners=2pt,
      blur shadow={shadow blur steps=5}
    ] {ধৈ};
      \end{tikzpicture}
\bqr\ \ম ঘৄঙী \ড}
\section{কাকীকৌ}
কাকীকৌ \ড \\
কাকীকৌ \ডড
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.