# Typesetting Kannada text using XeTeX

I have been typesetting a Kannada for a while using kanlel. In the last couple of days I am trying to switch to xetex, but compiling even a simple text has been far from smooth. Since I couldn't find much help on the web I decided to post a question here.

Here is what I am trying to complile.

\documentclass[11pt]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\begin{document}
namUmxru maYsUru.\\
ನಮ್ಮೂರು ಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರು
\textbf{ನಮ್ಮೂರು ಮೈಸೂರು.}
\emph{ನಮ್ಮೂರು ಮೈಸೂರು.}
\end{document}


The following are the problems are I am facing.

1. It gets compiled, but there are a lot of errors. Error kernel/command-already-defined appears at various places.

2. There are a few warnings on the font. Examples include Font 'Lohit Kannada' does not contain script 'Kannada' and Could not resolve font Lohit Kannada/I (it probably doesn't exist). I am sure I have the font.

3. In the output file, namUmxru maYsUru appear as boxes. The text given in Kannada language is rendered, but there is no hyphenation. textbf and emph are not giving the expected results.

Would appreciate any help in resolving these issues.

• Hi! Are you sure that all of the character in your MWE are typeset right? – Alessandro Cuttin Nov 21 '16 at 10:58
• Thanks for asking. There is a typo in the MWE: 'maYsuru' should have been 'meYsuru'. But that should not affect compilation. – user2122377 Nov 21 '16 at 11:19
• I managed to solve the first of the three issues I mentioned. The problem was this: I had some of the style files in two places - one at the standard tex location, and the other at texmf. The issue disappeared after I removed the files from texmf folder. – user2122377 Dec 7 '16 at 9:31

Seeing this 4.5-month old question only now. Here is some input that may get you started:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setotherlanguages{english}

\begin{document}
\textenglish{namUmxru maYsUru.}
ನಮ್ಮೂರು ಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರುನಮ್ಮೂರುಮೈಸೂರು
\textbf{ನಮ್ಮೂರು ಮೈಸೂರು.}
\emph{ನಮ್ಮೂರು ಮೈಸೂರು.}
\end{document}


It produces the following output:

Not everything is perfect. An explanation of some of the problems mentioned in the question:

The warning

means that in the font 'Lohit Kannada', there are no OpenType features specific to script tag 'knda' (or perhaps 'knd2'). (I touched upon this in this answer.) The fix is to change the line

to just

because there are no script-specific features you wish to load. (The Script= is meant mainly for multilingual fonts that contain different font features for different scripts.)

The warning

Could not resolve font Lohit Kannada/I (it probably doesn't exist)

is specifically about the italic variant (/I) of Lohit Kannada. It indeed probably doesn't exist. At least, fontspec was not able to find the font. (A possible reason is that Lohit Kannada is not in the now-standard OpenType format: see this post Improving Kannada Fonts from 2013 and follow the links from there for more details.)

When compiling my above input with Noto Sans Kannada (which doesn't have an italic style), I get the warning:

LaTeX Font Warning: Font shape EU1/NotoSansKannada(0)/m/it' undefined


which is slightly more clear.

The reason the Latin-script text namUmxru maYsUru appears in boxes is because of the \setmainfont: the Lohit Kannada font does not contain glyphs for Latin characters, so for those characters you need to switch to an "English" font. (With polyglossia you can use \textenglish around such sections.)

To get hyphenation, you can use polyglossia and declare the language as Kannada with \setmainlanguage{Kannada}, which will load some hyphenation patterns specific to Kannada script. (Sort of. These aren't very smart, but seem to know not to break in the middle of a visual letter.)

For \textbf and \emph to work, your font needs to have bold and italic variants, and XeTeX (fontspec) needs to be able to find them.

The example output above with Noto Sans Kannada was still not perfect (as it doesn't have italics, plus I don't understand why the line lengths are different), so I tried switching to a different font, Kedage. Unfortunately this font seems to have an "empty" glyph for the hyphen character, so (short of editing the font to fix its hyphen), this is a hack, using a different character instead:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}