I have defined a command (mapcommand) to convert a given text into another form. However, in article after using the command it changes the font below of it. I mean, the font remains Times New Roman until I use the command, after using the command it changes font to CharisSil to all the text below of it. I want to use CharisSil font only the text inside the command. I tried \DeclareTextFontCommand but not working properly. Please see the MWE below. Thank you. Compiler: XeLatex




\def\zzrow#1#2{\expandafter\gdef\csname B-#2\endcsname{#1}}
\expandafter\ifx\csname B-#1\endcsname\relax?%
\expandafter\show\csname B-#1\endcsname
\csname B-#1\endcsname
\expandafter\def\csname B-@\endcsname#1{}

\setmainfont{Times New Roman}


The font of this line Times new roman as expected. \mapcommand{০১২৩৪}  However, from here font changes after the use of the command.




You have to localize the font change:

\def\mapcommand#1{{\mapfnt\xxconvert#1@}}% <-- add braces!

enter image description here

You can also consider this simpler implementation:


\setmainfont{Times New Roman}
\newfontface\mapfnt{Charis SIL}


  \tl_set:Nn \l_israt_convert_table_tl { #1 }
  \tl_reverse:N \l_israt_convert_table_tl

  \str_map_function:nN { #1 } \israt_convert_token:n

\tl_new:N \l_israt_convert_table_tl

\cs_new:Nn \israt_convert_token:n
  { \mapfnt \str_case:nV { #1 } \l_israt_convert_table_tl }




The font of this line is Times New Roman as expected. \mapcommand{০১২৩৪}  
The font is again Times.

  • Thank you. It works. Jul 26 at 16:50
  • The conversiontable works fine for all alphabets except 3. These 3 alphabets has two different case, for example, this ড় and this ড় are different though both looks exactly same. First, ড় is U+09dc and second ড় is a combination of U+09a1 and U+09bc. Your conversion table shows different results for these two characters. However, I want the same output for both ড় which is {ɽ}. Whichever ড় it is I want ɽ as output. Like {ড়}{ɽ} {ড়}{ɽ} Jul 27 at 5:27
  • Egreg you can test this here mathml-refresh.github.io/xml-entities/unicode-names.html Jul 27 at 5:29

Although you don’t say what you’re trying to do, you might have an XY-problem. That is, if your actual goal here is to be able to display Assamese numerals that show as ASCII digits in your source, there are simpler ways to do it. This works in LuaLaTeX:

\tracinglostchars=3 % Halt if a font cannot display a glyph.
\usepackage[english, bidi=basic]{babel}
\usepackage[paperwidth=10cm]{geometry} % To format the MWE for TeX.SX.

\babelprovide[import, mapdigits]{bengali}

\defaultfontfeatures{ Scale=MatchUppercase, Ligatures=TeX }

          [Scale=1.0]{TeX Gyre Termes}
% Noto Serif Bengali is available at:
% https://www.google.com/get/noto/#sans-beng
          {Noto Serif Bengali}

This text is in Termes. \foreignlanguage{bengali}{01234}
Now back to Termes.

Termes / Bangla font sample

If you really do want to perform the conversion the other way around, @egreg has provided a great answer. (But consider changing your input method.)

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.