0

I have scoured the web and Stack Overflow, but haven't been able to resolve this problem while typesetting in Devanagari on Debian Linux. I am able to typeset without any problem; it is just the apparent difficulty choosing a specific Devanagari font (that I have definitely installed on the Linux system) that is bothering me. See the setup below, followed by my question:

  1. Installed TexLive and used a first.dn file that uses the devanagari package and the devnag preprocessor.
  2. This generates first.tex which is then processed by xelatex to generate first.pdf. The examples below should work out of the box on a TexLive system. See first.pdf.

Now my question:

Look at the command \newfontfamily\devanagarifont[Script=Devanagari]{Mukta} in first.dn that is carried over by the devnag preprocessor verbatim to first.tex. My understanding is that this line lets me choose the devanagari font of my choice. I have made sure that the fonts are indeed installed and (presumably) available because if I made a typo in its name or provided a nonexistent font, I get an error like this:

kpathsea: Running mktextfm Nakula/OT
/usr/share/texlive/texmf-dist/web2c/mktexnam: Could not map source abbreviation O for OT.
/usr/share/texlive/texmf-dist/web2c/mktexnam: Need to update /usr/share/texlive/texmf-dist/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input OT
This is METAFONT, Version 2.7182818 (TeX Live 2019/dev/Debian) (preloaded base=mf)

...
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input OT' failed to make OT.tfm.
kpathsea: Appending font creation commands to missfont.log.
! Package fontspec Error: The font "Nakula" cannot be found.

With the available devangari fonts like Mukta, Sanskrit2003, or Yashomudra, however, I do not get any error and the compilation is clean. But I get the exact same font on the generated PDF, as if the font specification is ignored (and a default font seems to be used regardless). None of the available fonts I specify here by name is paid heed to.

What might be wrong? If you can suggest the changes to my first.dn file, that would be great.

Here's the xetex compiler output:

This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2019/dev/Debian) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./first.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/velthuis/devanagari.sty)
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/polyglossia.sty
(/usr/share/texlive/texmf-dist/tex/latex/etoolbox/etoolbox.sty)
(/usr/share/texlive/texmf-dist/tex/latex/makecmds/makecmds.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex)))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/tuenc.def))
(/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/gloss-marathi.ldf
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/devanagaridigits.sty))
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/gloss-english.ldf)
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/gloss-sanskrit.ldf)
(/usr/share/texlive/texmf-dist/tex/latex/polyglossia/gloss-hindi.ldf)

LaTeX Warning: Unused global option(s):
    [a6paper].

(./first.aux) (/usr/share/texlive/texmf-dist/tex/latex/velthuis/udn.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
[1] (./first.aux) )
Output written on first.pdf (1 page).
Transcript written on first.log.
% first.dn
\documentclass[a6paper]{article}
\usepackage[margin=10mm]{geometry}

\usepackage{devanagari}
\usepackage{polyglossia}
\setdefaultlanguage{marathi}
\setotherlanguages{english, sanskrit, hindi}
\newfontfamily\devanagarifont[Script=Devanagari]{Mukta}
\begin{document}
{\dn dharmak.setre kuruk.setre samavetaa yuyutsava.h | \\
maamakaa.h paa.n.davaa"scaiva kimakurvata sa~njaya? ||}
\end{document}

first.pdf looks like this: enter image description here

7
  • 1
    Welcome! To help answer your question, could you clarify this: If you're willing (and in fact seem to prefer) to use a modern font, why are you using the devanagari package and the devnag preprocessor? Why not simply type directly into a .tex file and use xelatex on it? (Did you read somewhere that the only, or recommended, way to use Devanagari is to use devnag? Where?) Commented Oct 3, 2020 at 7:01
  • It looks like the devanagari package does not use Unicode fonts. It uses 8bit fonts and so your \newfontfamily commands are completely ignored. Commented Oct 3, 2020 at 7:13
  • Theoretically you can change the font with a package option. But I admit that they all look the same to me… Except the pen* ones are slanted. Commented Oct 3, 2020 at 7:27
  • @ShreevatsaR Thanks! In spite of your and Rohit Dilip Holkar's efforts (ctan.org/pkg/latex-mr), I believe LaTeX Devanagari typesetting requires more standardization, especially on Linux. In my case, I resorted to using devanagari package mainly because I like the 7-bit transliteration facility that it provides. I can use pure ASCII to encode almost everything that I am interested in. My workflow is set alright: 1) Open vim 2) Use preamble and start typing in {\dn <ascii code>} 3) Run a script that calls devnag and xelatex or pdflatex to generate PDF. Commented Oct 3, 2020 at 8:08
  • 1
    For posterity, here is the template that seems to work for me: gist.github.com/kedarmhaswade/456762116a1a3a970e06d77c2fb21faa Commented Oct 3, 2020 at 23:50

1 Answer 1

6

The devanagari package uses 8bit fonts. It's not using \newfontfamily\devanagari line at all.

It looks like the devanagari package supports a number of fonts, which can be selected by passing an option to the package, but to be honest they all look the same to me.

If you want to use the OpenType fonts on your system, you'll need to abandon the devanagari package and use fontspec directly.

You can still use the same input method by specifying an appropriate Mapping option (or you can input Unicode characters directly). The extra pre-processing step is no longer needed.

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{marathi}
\setotherlanguages{english, sanskrit, hindi}
\setmainfont[Mapping=velthuis-sanskrit,Script=Devanagari,Language=Marathi]{Noto Serif Devanagari}
\newfontfamily\englishfont{Noto Serif}
\newfontfamily\sanskritfont[Mapping=velthuis-sanskrit,Script=Devanagari,Language=Sanskrit]{Noto Serif Devanagari}
\newfontfamily\hindifont[Mapping=velthuis-sanskrit,Script=Devanagari]{Noto Serif Devanagari}
% make sure ~ as non-breaking space doesn't interfere with velthuis-sanskrit mapping
\edef~{\string~}
\begin{document}
dharmak.setre kuruk.setre samavetaa yuyutsava.h | \\
maamakaa.h paa.n.davaa"scaiva kimakurvata sa~njaya? ||
\end{document}

output

13
  • 1
    @KedarMhaswade As for 2., the warning message is harmless, but you can get rid of it by changing Language=Sanskrit to Language=Default.
    – Davislor
    Commented Oct 3, 2020 at 8:05
  • 4
    @KedarMhaswade For the last word: The problem is that LaTeX's default definition of ~ as a non-breakable space is intruding over the velthuis-sanskrit mapping's definition as ञ्. To fix this, add \edef~{\string~} before or after \begin{document}. If you want also to use ~ in some places as a non-breakable space, you need some more work to turn this on and off; see here for an explanation (though you still shouldn't use catcode changes; then it won't work in footnotes etc; see the comments there). Commented Oct 3, 2020 at 8:17
  • 1
    Thanks, @ShreevatsaR! Your suggestion (\edef~{\string~}) worked like a charm. Commented Oct 3, 2020 at 8:23
  • 1
    @KedarMhadwade, fontspec gets loaded by polyglossia anyway. fontspec is responsible for the font handling. Commented Oct 3, 2020 at 10:08
  • 1
    @David The output shown in the answer looks fine now -- the difference between what you see in the question and here is just a matter of the font being different (i.e. it's within the range of acceptable font variation, how this conjunct / ligature is rendered). Commented Oct 3, 2020 at 14:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .