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

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
  • 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?) – ShreevatsaR Oct 03 '20 at 07:01
  • It looks like the devanagari package does not use Unicode fonts. It uses 8bit fonts and so your \newfontfamily commands are completely ignored. – David Purton Oct 03 '20 at 07: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. – David Purton Oct 03 '20 at 07:27
  • @ShreevatsaR Thanks! In spite of your and Rohit Dilip Holkar's efforts (https://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. – Kedar Mhaswade Oct 03 '20 at 08:08
  • @KedarMhaswade Thanks for explaining that transliterated input is the main reason; yes I agree someone needs to write a proper guide accounting for all possible different preferences. Though if you pursue the answer below I think you'll find you don't need the preprocessor (devnag) anymore, and can satisfactorily get by with just typing into a .tex file. But I'd be curious to know how it turns out eventually… – ShreevatsaR Oct 03 '20 at 08:20
  • 1
    For posterity, here is the template that seems to work for me: https://gist.github.com/kedarmhaswade/456762116a1a3a970e06d77c2fb21faa – Kedar Mhaswade Oct 03 '20 at 23:50
  • @ShreevatsaR I have another related question: https://tex.stackexchange.com/q/606292/64425 – Kedar Mhaswade Jul 25 '21 at 03:28

1 Answers1

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

David Purton
  • 25,884
  • Thanks, David! This seems to work. There are two problems, however: 1) See the last word in the verse? The font is different, but also the rendering! Why would the rendering change just because the font is different (after all, Unicode generated by devnag must be identical in either case)? The rendering in the changed font is, quite frankly, wrong. 2) I seem to get Package fontspec Warning: Language 'Sanskrit' not available for font 'Mukta' (fontspec) with script 'Devanagari'. with this change, although I am able to render the new font. How can I get rid of this warning for my font? – Kedar Mhaswade Oct 03 '20 at 08:03
  • 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 Oct 03 '20 at 08: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). – ShreevatsaR Oct 03 '20 at 08:17
  • 1
    Thanks, @ShreevatsaR! Your suggestion (\edef~{\string~}) worked like a charm. – Kedar Mhaswade Oct 03 '20 at 08:23
  • @David, did you, by any chance, mean to say "use polyglossia directly" (and not fontspec? This is because even if I remove the use of fontspec (remove/comment out that line), I get the desired output anyway (but the removal of polyglossia expectedly fails the compilation). This makes me wonder if fontspec is needed at all. – Kedar Mhaswade Oct 03 '20 at 09:17
  • 1
    @KedarMhadwade, fontspec gets loaded by polyglossia anyway. fontspec is responsible for the font handling. – David Purton Oct 03 '20 at 10:08
  • @ShreevatsaR, I'll update my answer to deal with the ~. I don't read or speak these languages :). – David Purton Oct 03 '20 at 10:10
  • @ShreevatsaR, my output still looks different. Am I missing something in the font set up? – David Purton Oct 03 '20 at 11:54
  • 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). – ShreevatsaR Oct 03 '20 at 14:21
  • @ShreevatsaR the rendering of devanaagari character ञ (velthuis mapping "~n") has been fixed by the above, but the so-called "eyelash repha" (velthuis mapping "~r") is not fixed by this. I couldn't find any way to contact the devanagari package maintainers. Any idea how to fix eylash repha, for example for ~rhasva? – Kedar Mhaswade Nov 04 '20 at 03:46
  • 1
    @KedarMhaswade Although some email addresses of the devanagari package maintainers are listed on the top of page 3 of its documentation, note that with the solution in this answer you're not using the devanagari package; you're just using a mapping called “ velthuis-sanskrit”, simply an alternative way to enter Unicode characters. According to this page & this, there… – ShreevatsaR Nov 04 '20 at 06:14
  • 1
    @KedarMhaswade …are a couple of ways of producing the eyelash forms in Unicode (if the font supports them!), and the velthuis-sanskritmapping seems to be able to do it out-of-the-box via r+ (to get U+0930 DEVANAGARI LETTER RA followed by U+094D DEVANAGARI SIGN VIRAMA followed by U+200D ZERO WIDTH JOINER). Try it, just replace “kimakurvata” in the above answer with “kimakur+vata” — I think this gives what you want? – ShreevatsaR Nov 04 '20 at 06:15
  • Thank you @ShreevatsaR! r+hasva (meaning short, as in short vowel) worked correctly! Thank you for the other references as well. – Kedar Mhaswade Nov 04 '20 at 06:37