16

As I gather from the mailing lists, LuaTeX is currently unable to render devanagari properly because it doesn't understand the complex ligature rules involved. This is my experience with test documents, as well.

Is there anything I can do about this?

  • Can I somehow add proper devanagari rendering myself without digging deep into the guts of LuaTeX? I'm handy enough with code but suspect the core processes here go way above my paygrade.
  • Since the answer to the first question is probably "very no", can anyone suggest a kludge that will get small chunks of accurate devanagari into a predominantly English document?

Right now, I use a perl script to convert a minimally marked up document into (Xe)LaTeX. Eventually, I'd like to convert my process over to ConTeXt-mkiv, but devanagari support is a hard requirement.

UPDATE:
phg's comment has me hopeful that I'm just doing something wrong. I'm still trying to wrap my head around typescripts, in particular.

The following example:

\definefontfeature[dev][devanagari-two][script=dev2]

\starttypescript [serif] [devanagarimt]
 \definefontsynonym [DevanagariMT-Light]       [name:DevanagariMT]        [features=dev]
\stoptypescript

\starttypescript [serif] [devanagarimt]
 \usetypescript[serif][fallback]
 \definefontsynonym [Serif]                    [DevanagariMT-Light]       [features=dev]
\stoptypescript

\starttypescript [DevanagariMT]
  \definetypeface [DevanagariMT] [rm] [serif] [devanagarimt] [default] 
\stoptypescript

\usetypescript[DevanagariMT]
\setupbodyfont[DevanagariMT,11pt]


\starttext
श्रेयो हि ज्ञानमभ्यासाज्ज्ञानाद्ध्यानं विशिष्यते ।

ध्यानात्कर्मफलत्यागस्त्यागाच्छन्तिरनन्तरम् ॥
\stoptext

Produces this:
Broken sample (from LuaTeX)

But it should produce this (from XeTeX):
Working sample (from XeTeX)

I suspect that some devanagari-specific processing is happening here, because some things do indeed work:

the second word: ह + ि produces हि (like it should), but
the first glyph of the first word: श + ् + र + े should produce श्रे but doesn't.

This might just be an incomplete implementation as yet, but I hope there's a mistake in my code. Is there anything obviously wrong here? I've tried a few different fonts with similar results.

4
  • 6
    The Context implementation actually progressed a good deal this year. It might be worth checking out. Also I’d encourage you and everybody who is interested in improving typesetting of Indic scripts to test the current implementation and report problems on the Context mailing list. Sep 8, 2013 at 15:08
  • @phg That's wonderful to hear. After reading your links I've tried a few more things, but I'm still not able to get it to work. I've posted a simple example in hopes that someone can spot something wrong with my setup.
    – MalFet
    Sep 8, 2013 at 17:17
  • 1
    I don’t have access to Devanagari MT. Here is a test file that renders your test string with Chandas and Uttara fonts. With Context as of two days ago the result looks like this: i.imgur.com/hIIrE8v.png -- in my untrained eyes it looks pretty similar to the Xetex output. Sep 8, 2013 at 22:04
  • This is great. I really appreciate your help. DevaOne is almost there. The key seems to be using devanagari-one as the open type feature set, and from there most of my fonts work. Two glyphs are still wrong, but I suspect that's a problem with the implementation. (They're very "human" errors, likely misinterpretations of the specification rather than a code problem per se.) If you want to post this as an answer, I'll gladly accept it. In the meantime, I'll run some more elaborate tests and then send my findings over to the ConTeXt mailing list.
    – MalFet
    Sep 9, 2013 at 1:12

2 Answers 2

7

Just to update, devanagari now works beautifully in recent betas. There was a bug in how the opentype features were handled, but it has been squashed.

To use devanagari, simply define a font with the devanagari-one feature set:

\definefont [Deva][file:chandas.ttf*devanagari-one]
\starttext
    \Deva श्रेयो हि ज्ञानमभ्यासाज्ज्ञानाद्ध्यानं विशिष्यते । \crlf ध्यानात्कर्मफलत्यागस्त्यागाच्छन्तिरनन्तरम् ॥
\stoptext

Or, to avoid font switching, it's possible to define a devanagari-capable fallback font for the appropriate unicode range:

\definefontfallback
    [deva_fallback][file:chandas.ttf*devanagari-one]
    [0x0900:0x097F][force=yes]
\definefontsynonym[Baskerville]
    [file:Baskerville120Pro-Regular][fallbacks=deva_fallback]
\definefont[GeneralPurposeFont][Baskerville]
\starttext
    \GeneralPurposeFont Switch scripts श्रेयो हि ज्ञानमभ्यासाज्ज्ञानाद्ध्यानं विशिष्यते with total impunity.
\stoptext
1

For those without proper support for CTL (either in the Tex distro or OS), you can still use the devanagari package by Velthuis. But you'll have to convert all UTF-8/Unicode encoded Devanagari to velthuis transliteration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .