4

Following up this answer, I have added this code:

\documentclass{memoir}

\usepackage{babel}
\babelprovide[import, onchar = fonts ids]{bengali}
\babelfont[bengali]{rm}[Renderer=Harfbuzz,AutoFakeBold,AutoFakeSlant=0.3]{Kalpurush}
\babelcharproperty{`।}{locale}{bengali}

\babelprovide[maparabic,alph=alphabetic]{bengali}

%\usepackage{amsmath}
\usepackage{unicode-math}

%--------------- Problematic code starts
\setmathfont{latinmodern-math.otf}
\setmathfont{fontkalpurush.ttf}[range={"0980-"09FF}]
\newcount\tmpcount
% re-do range No idea why this is needed
\AtBeginDocument{
\tmpcount="0980
\loop
\Umathcode\tmpcount 0 4 \tmpcount
\ifnum\tmpcount<"09FF
\advance\tmpcount 1
\repeat
}
%--------------- Problematic code ends

\begin{document} 
text
    ৩৪২

math
    $৩৪^২$ %34^2
\begin{align*}
    ৩৪২ &= (৩৪+৪)(৩৪-৪) + ৪২\\
    &= ৩৮৩০ + ৪২
\end{align*}
    \[ \sqrt[৩]{\frac{১}{২}} \] 
\end{document}

It works fine for that question, but while I write cubic root equation, it doesn't show actual shape. The Problematic code is shown here using comment area %--------------- Problematic code. How I can get the right shape of cubic root keeping other settings OK?

Output:

enter image description here

6

You need

\setmathfont{latinmodern-math.otf}
\setmathfont{fontkalpurush.ttf}[range={"0980-"09FF}]
\setmathfont{latinmodern-math.otf}[range=]

That's a known problem with unicode-math and ranges.

However, instead of “magic” code that's not guaranteed to work because it relies on some number that's not predetermined, I'd assign a math symbol font and forget of the rest.

\documentclass{memoir}

\usepackage{babel}
\babelprovide[import, onchar = fonts ids]{bengali}
\babelfont[bengali]{rm}[
  Renderer=Harfbuzz,
  AutoFakeBold,
  AutoFakeSlant=0.3,
  NFSSFamily=kalpurush,
]{fontkalpurush.ttf}
\babelcharproperty{`।}{locale}{bengali}

\babelprovide[maparabic,alph=alphabetic]{bengali}

\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{latinmodern-math.otf}

\DeclareSymbolFont{bangla}{\encodingdefault}{kalpurush}{m}{n}
\Umathcode"09E6 = "0 \symbangla "09E6 % 0
\Umathcode"09E7 = "0 \symbangla "09E7 % 1
\Umathcode"09E8 = "0 \symbangla "09E8 % 2
\Umathcode"09E9 = "0 \symbangla "09E9 % 3
\Umathcode"09EA = "0 \symbangla "09EA % 4
\Umathcode"09EB = "0 \symbangla "09EB % 5
\Umathcode"09EC = "0 \symbangla "09EC % 6
\Umathcode"09ED = "0 \symbangla "09ED % 7
\Umathcode"09EE = "0 \symbangla "09EE % 8
\Umathcode"09EF = "0 \symbangla "09EF % 9

\begin{document} 

text
    ৩৪২

math
    $৩৪^২$ %34^2
\begin{align*}
    ৩৪২ &= (৩৪+৪)(৩৪-৪) + ৪২\\
    &= ৩৮৩০ + ৪২
\end{align*}
    \[ \sqrt[৩]{\frac{১}{২}} \] 
\end{document}

enter image description here

If you don't want to repeat the ten declarations, the code below suffices.

\DeclareSymbolFont{bangla}{\encodingdefault}{kalpurush}{m}{n}
\ExplSyntaxOn
\int_step_inline:nnn { "09E6 } { "09EF } { \Umathcode #1 = "0 \symbangla #1 }
\ExplSyntaxOff
1
  • Thanks for your great help.
    – topu
    Nov 28 '21 at 9:59

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.