Combining mark over ligature (Devanagari)

I want to typeset the combination m̐llo in Devanagari with XeLaTeX. When I use the correct Unicode ल्ँलो, there is no ligature of the ls. When I place the candrabindu on the ligature the o is not connected with theligature: ल्लँो.

How can I get XeLaTeX to place the candrabindu on the ligature and get still the o in the correct position?

\documentclass{article}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{sanskrit}
\setmainfont{Siddhanta}

\begin{document}
ल्ँलो

ल्लँो
\end{document}

Here is an example from a textbook, how it should look like:

• Welcome to TeX.sx! – texenthusiast Apr 13 '13 at 9:08
• I’m not a student of Sanskrit, so my eye won’t be as sharp as yours, but the results look much better to me if I comment out \usepackage{polyglossia} and \setmainlanguage{sanskrit} and compile your example with either xetex or luatex. – Thérèse Jun 11 '13 at 1:33
• Have you tried to typeset llom̐? – Malipivo May 5 '14 at 19:50
• @Malipivo llom̐ looks nearly correct. But in my textbook the mark is above the ll-ligature and not above the o. I still think at least one of the examples should work. Probably it is a bug in the fonts I tried. The second example is at least rendered correctly in Opera browser (not in Firefox and Chrome), but I don't know which font it is using for Devanagari. – sanskrit_learner May 12 '14 at 20:29
• @sanskrit_learner Could you please add a snapshot (screenshot, scan or photo) of it from your textbook to the post? – Malipivo May 13 '14 at 6:05

1 Answer

Zdeněk Wagner, a Czech TeXist, who is not having enough points to post an answer at TeX.SX (or he is probably having different kind of problem), yet, is writing his observations:

1. The problem is not in polyglossia and Language, these commands are correct, the problem is in font loading. If you do not specify the script explicitly, the Latin script is assumed and thus the non-Latin characters cannot appear properly. What is missing is the script specification, you have to write

\setmainfont[Script=Devanagari]{Siddhanta}

2. Your example is wrong. All three characters, virama, candrabindu and o-matra, are dependent vowels, you cannot combine more than one of them with a consonant. If you type ल् (with a virama), you cannot add a candrabindu. If it is not an end of a word, you can only add another consonant. You can make a conjunct (ligature) with a candrabindu, i.e. ल्लँ but it must never be followed by any matra. In theory, you could add independent ओ but I cannot imagine how you would pronounce it. It looks really weird. You can, of course, nasalize a matra, e.g. ताँ, but if o-matra or ii-matra is to be nasalized, anusvara is used (merely due to graphical appearance).

3. There is an evident misprint in the textbook, the correct form is ताँल्लोकान्.

4. Try the following add-on to see which fonts are used by Firefox: https://addons.mozilla.org/en-us/firefox/addon/fontinfo/

I am adding an example. The ligature ll is not having its Unicode code in all three fonts, so the result is correct from xelatex (left picture; all three cases) and once from lualatex (right picture; the first line).

% run: xelatex mal-chandas.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{fontspec}
\begin{document}
\def\maltext{ताँल्लोकान्\par}
% http://svayambhava.blogspot.cz/p/siddhanta-devanagariunicode-open-type.html
\setmainfont[Script=Devanagari]{Siddhanta} \maltext
\setmainfont[Script=Devanagari]{Chandas} \maltext
\setmainfont[Script=Devanagari]{Sanskrit2003} \maltext
\end{document}

Update: We could use luaotfload package instead of fontspec package to get a correct form with lualatex; I used script=devanagari in document body then (I typed taaMMllokaan or tAMMllokAn at Lexilogos):

% run: lualatex mal-siddhanta.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{luaotfload}
\begin{document}
% http://svayambhava.blogspot.cz/p/siddhanta-devanagariunicode-open-type.html
% taaMMllokaan at Lexilogos
\font\malfont=Siddhanta:script=devanagari \malfont ताँल्लोकान्
\end{document}
• Everybody can post answers. – egreg May 17 '14 at 17:56
• He indeed did at least once. That's strange. – Malipivo May 17 '14 at 18:02
• Thank you very much! Zdeněk Wagner's explanations seem very reasonable, why I didn't get the expected results. So the problem is in the textbook. On all occurences of the candrabindu in the book it is positioned on the ll. – sanskrit_learner May 17 '14 at 19:54