2

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}
\setmainfont[Script=Kannada]{Lohit Kannada}
\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.

egreg
  • 1,121,712
  • Hi! Are you sure that all of the character in your MWE are typeset right? – Alessandro Cuttin Nov 21 '16 at 10:58
  • 1
    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 07 '16 at 09:31

4 Answers4

6

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

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\kannadafont{Noto Sans Kannada}
\usepackage{polyglossia}
\setmainlanguage{kannada}
\setotherlanguages{english}

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

It produces the following output:

screenshot of generated pdf

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


The warning

Font 'Lohit Kannada' does not contain script 'Kannada'

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

\setmainfont[Script=Kannada]{Lohit Kannada}

to just

\setmainfont{Lohit Kannada}

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
(Font)              using `EU1/NotoSansKannada(0)/m/n' instead on input line 12

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}
\newfontfamily\kannadafont[HyphenChar={+}]{Kedage}
\usepackage{polyglossia}
\setmainlanguage{kannada}
\setotherlanguages{english}

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

which produces:

screenshot with kedage used instead

which may be preferable.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
1

Noto Serif Kannada (google fonts better, bold do not work properly in xelatex). For bold/italics I am using Kedage (Mallige also available). Bold-Italics we have Mallige.

Noto Serif Kannada ಬಳಸುವವರು ಮೊದಲು ಆನ್‌ಲೈನ್‌ನಲ್ಲಿ ಈ ಫಾಂಟ್‌ಗಳ .tfm, .pfb extension (Online conversion available) ಪಡೆಯಬೇಕು. ಇವನ್ನು texlive ಆದರೆ ಅದರ ಸಂಬಂಧಿತ ಫೈಲುಗಳಲ್ಲಿ texmf-dist font folder ಸೇರಿಸಿ ನಂತರ texmflsr run ಮಾಡಿದರೆ ಮಾತ್ರ ಕೆಲಸ ಮಾಡುತ್ತವೆ.

  • 2
    Pradeep could you expand on your answer to make it more comprehensive, as to why you think Noto fonts are better? I do think the same by the way, the latest versions also support english, so one does not need to keep switching between the languages. Also provide links for the Mallige font and online conversions and a full minimal. Are you a native speaker of Kannada? How about linebreaks? Do you use Babel, polyglossia or just break lines manually? – yannisl Jan 05 '24 at 04:31
  • Also personally I recommend the use of LuaLaTeX for compiling as the harfbuzz shaping engine is getting better and the way to long term shaping of Indic fonts is promising. – yannisl Jan 05 '24 at 04:35
0

At present I am using this in xelatex:

\usepackage{polyglossia}
\setdefaultlanguage{kannada}
\setotherlanguages{english}
\usepackage{fontspec}
\setmainfont{NotoSerifKannada-Regular.ttf}[Script=Kannada, 
   BoldFont=NotoSerifKannada-Regular.ttf,
   BoldFeatures={FakeBold=2},
   SlantedFont={NotoSerifKannada-Light.ttf},
   SlantedFeatures={Fake`Slant=0.4},
   BoldItalicFont=NotoSerifKannada-Regular.ttf,
   BoldItalicFeatures={FakeBold=3,FakeSlant=0.3},
]
\newfontfamily\englishfont[Script=Latin]{EBGaramond-Medium.ttf}

Sorry I found not much difference between Noto Sans Kannada and Noto Serif Kannada. Later fonts are slightly smaller.

ShreevatsaR
  • 45,428
  • 10
  • 117
  • 149
0

Using fonts I found the following procedure that works for me in Windows (texlive 2023)

Get your .ttf converted into .pfb & .tfm fonts (available online)

place .ttf fonts in texmf-dist/fonts/trutype folder

place .tfm fonts in texmf-dist/fonts/tfm folder

place .pfb fonts in texmf-dist/fonts/type1 folder

Then I had run at texlive mktexlsr (but not sure it is required)

  • Something like this is only needed when using pdfTeX (pdflatex), not XeTeX (xelatex). – ShreevatsaR Mar 24 '24 at 15:01
  • BTW thanks for coming back and sharing what's working for you, but do note that it's possible (and preferred) to edit your existing answer instead of adding a new answer each time. – ShreevatsaR Mar 24 '24 at 16:59