# xelatex compilation of devanagari documents looks BAD!

Here is the MWE:

\documentclass[b5paper]{memoir}

\usepackage{fontspec, polyglossia, devanagaridigits}

\setmainfont[Script=Devanagari, Scale=1.5]{DejaVu Sans}
\newcommand{\devanagarinumeral}[1]{%
\devanagaridigits{\number\csname c@#1\endcsname}}

\renewcommand{\chaptername}{}

\begin{document}

\chapterstyle{veelo}

\chapter{भाग १}

घड्याळात --- एवढ्यात

\end{document}


My editor (KATE) uses the same font (DejaVu Sans). And displays the text correctly. See attached image. When compiled, the document produces square boxes!

• I'm afraid I don't know anything, really, about Devanagari script and typesetting. Fixing the missing em-dash ligature issue is easy, though: Instead of \setmainfont[Script=Devanagari, Scale=1.5]{gargi}, write \setmainfont[Script=Devanagari, Scale=1.5, Ligatures={TeX}]{gargi}. – Mico Apr 8 '14 at 5:39
• @Mico thanks. Ligatures={TeX} did solve the em-dash problem. But the ligature problem remains. This is the first time when a document looks better in the plain simple text editor than after processing with xelatex! – deshmukh Apr 8 '14 at 7:05
• If it's that line we should look at, I wonder if most of the code in the example is needed. Have you tested if it's enough with \documentclass{article}, \usepackage{fontspec}, setmainfont and the line with the problem? In that case that should be the MWE. – pst Apr 8 '14 at 7:33
• @pst I agree, one can delete a lot of lines and still compile successfully. The reason I kept all those lines was to ensure that all package dependencies are clear. Anyway, I am making it an 'M'WE :) – deshmukh Apr 8 '14 at 12:53
• DejaVu Sans has no script Devanagari – user2478 Apr 8 '14 at 13:46

Those characters are not in DejaVu Sans. Earlier you used gargi and your question was why the ligatures you see in your editor were used. Then the answer was that gargi didn't have those ligatures. So this is really not about TeX. With this example:

% -*- TeX-engine: xetex; -*-%
\documentclass{article}
\usepackage{fontspec}

\setmainfont[Script=Devanagari, Ligatures=TeX]{Siddhanta}

\begin{document}

घड्याळात --- एवढ्यात

\end{document}


I showed that ligatures are used if they are in the font (this Siddhanta gotten from here). These are not the same ligatures as the font in your text editor but looks like this:

I don't know which ligatures are good or bad, right or wrong here. You have to find a font that has the ligatures you want. If you don't know how to ask your editor what fonts it is using you could try a shell command like fc-list :lang=hi to show installed fonts suitable for writing Hindi with.

I think the font your have in your text editor is "Lohit Devanagari". It has ligatures of that kind anyway.

• I have updated the question. The document displays perfectly in my editor (KATE on KDE) using DejaVu Sans as font. But when compiled, it just produces square boxes!! – deshmukh Apr 8 '14 at 13:36
• DejaVu Sans doesn't have those characters. Your editor uses some other font for those. Did you try my answer you are commenting on? – pst Apr 8 '14 at 14:01
• (I've added an image now.) – pst Apr 8 '14 at 14:24
• @pst: you should use Ligatures=TeX – user2478 Apr 8 '14 at 14:34
• Then I really don't know what you didn't like with my answer, since I think it answered everything in it that had to do with TeX. I understand that you also need to know how to ask your editor what fonts it is using, or in some other way find that font. I've never used that editor, but I've edited my answer again now, helping you with the second option. – pst Apr 9 '14 at 5:53

The problem might be that the output is different from xelatex (picture on left) and lualatex (picture on right).

Your code is working on my computer and it should be all right as gargi.ttf is a part of official ttf-indic-fonts-core package in Linux. You could try the other fonts from that package, the files are Kedage-b.ttf, Kedage-n.ttf, lohit_bn.ttf, lohit_gu.ttf, lohit_hi.ttf, lohit_ta.ttf, Malige-b.ttf, Malige-n.ttf, Meera_04.ttf, MuktiNarrowBold.ttf, MuktiNarrow.ttf, Pothana2000.ttf, Rachana_04.ttf, Rekha.ttf, utkal.ttf and Vemana.ttf.

I am enclosing an example typeset in Sanskrit2003.ttf, a font which I have found among other fonts at http://salrc.uchicago.edu/resources/fonts/available/hindi/

%! xelatex mal-devanagari.tex
% and
%! lualatex mal-devanagari.tex
\documentclass[b5paper]{memoir}
\usepackage{parskip, lastpage, tabu, booktabs, tfrupee, fontspec, polyglossia, devanagaridigits, setspace}
% http://salrc.uchicago.edu/resources/fonts/available/hindi/
\setmainfont[Script=Devanagari, Scale=1.5, Ligatures=TeX]{Sanskrit2003.ttf}
%CODE2000.TTF ARIALUNI.TTF Sanskrit2003.ttf gargi.ttf
% http://www.omkarananda-ashram.org/Sanskrit/itranslator2003.htm#dls
% http://www.svayambhava.org/
\newcommand{\devanagarinumeral}[1]{%
\devanagaridigits{\number\csname c@#1\endcsname}}
\renewcommand{\thesection}{\devanagarinumeral{section}}
\renewcommand{\thechapter}{\devanagarinumeral{chapter}}
\renewcommand{\thesubsection}{\thesection.\devanagarinumeral{subsection}}
\renewcommand{\thepage}{\devanagarinumeral{page}}
\renewcommand{\theenumi}{\devanagarinumeral{enumi}}
\renewcommand{\chaptername}{}
\usepackage{graphicx}
\graphicspath{{./images}}
\setcounter{secnumdepth}{1}
\begin{document}
\chapterstyle{veelo}
\chapter{भाग १}
घड्याळात --- एवढ्यात
\end{document}