Indic Scripts

From Wiki
Jump to navigation Jump to search

TODO: this page needs to be reviewed (See: To-Do List)


Fonts

Devanagari

Malayalam

Tamil

Kannada

Telugu

Bengali

Oriya

Basic Sample

A very basic sample with Indic scripts is the following:

%\definefontfamily [kannada] [rm] [Kedage] [features=kannada-one]
\definefontfamily [kannada] [ss] [Tunga] [features=kannada-one]

\definetypeface [kannada] [mm] [math] [modern]

\setupbodyfont [kannada]

\starttext
ಇದು ಹೇಗಿದೆ? ನಾನು ಹೀಗೆ ತುಂಬ ಬರೆಯಬೇಕೆಂದು ಯೋಚಿಸುತ್ತಿದ್ದೇನೆ.
\stoptext


Supported Scripts

The list of Indic scripts supported by ConTeXt MkIV and LMTX are:

  • Devanagari
  • Bengali
  • Gujarati
  • Gurmukhi
  • Kannada
  • Malayalam
  • Oriya
  • Tamil
  • Telugu

In order to get the proper OpenType features, you need to select the proper feature from the following list:

  • devanagari-one
  • bengali-one
  • gujarati-one
  • gurmukhi-one
  • kannada-one
  • malayalam-one
  • oriya-one
  • tamil-one
  • telugu-one

Depending on your font, you might need instead:

  • devanagari-two
  • bengali-two
  • gujarati-two
  • gurmukhi-two
  • kannada-two
  • malayalam-two
  • oriya-two
  • tamil-two
  • telugu-two

Script Versions

Script tags from the OpenType specification contains second versions for what might be some (or all [I’m afraid I don’t know]) Indic scripts.

Why are those second versions available? From their own explanation:

The OpenType script tags can also correlate with a particular OpenType Layout implementation, with the result that more than one script tag may be registered for a given Unicode script (e.g. 'deva' and 'dev2').

Features ending in -one use the older OpenType implementation, while the ones ending in -two deploy the newer implementation.

Hyphenation

The hyphenation patterns for the following languages are included in ConTeXt:

  • Sanskrit sa
  • Hindi hi
  • Kannada kn
  • Telugu te
  • Tamil ta
  • Malayalam ml
  • Bengali bn
  • Gujarati gr

A pattern is activated with \language. The Sanskrit hyphenation patterns support hyphenation of Sanskrit written using the Malayalam, Telugu, Kannada, Bengali and Latin with IAST.

Numbers and Conversion sets

The following number conversion sets are available:

  • Devanagari devanagarinumerals
  • Malayalam malayalamnumerals
  • Tamil tamilnumerals
  • Kannada kannadanumerals
  • Telugu telugunumerals
  • Bengali bengalinumerals

for use as values of the keys numberconversion, conversion and with \convertnumber

Sanskrit Transliteration

Transliteration of Sanskrit from IAST to Devanagari and vice-versa as well as from and to other Indic languages is available in ConTeXt. The following transliteration schemes are supported with more planned:

Transliteration Scheme Vector
Devanagari to IAST deva to iast
IAST to Devanagari iast to deva
Devanagari to Malayalam deva to mlym
Devanagari to Kannada deva to knda
Devanagari to Telugu deva to tlgu

The main macro to set up a transliteration is \definetransliteration.

A simple example

A transliteration instance is defined using \definetransliteration:

\definetransliteration
    [TrDevaToIAST]
    [vector={deva to iast}]

This defines macros for both inline and block transliteration:

\starttext

% display mode
\starttransliteration[TrDevaToIAST]
महाजनस्य संसर्गः कस्य नोन्नतिकारकः।
पद्मपत्रस्थितं तोयं धत्ते मुक्ताफलश्रियम्॥
\stoptransliteration

% or inline
The company of great people (\transliteration[TrDevaToIAST] महाजनस्य संसर्गः} is there one for whom it is not beneficial {\transliteration[TrDevaToIAST] कस्य नोन्नतिकारकः}? (No!) Situated on the leaf of the lotus, (the mere) droplet of water {\transliteration[TrDevaToIAST] पद्मपत्रस्थितं तोयं} shines forth like a pearl {\transliteration[TrDevaToIAST] धत्ते मुक्ताफलश्रियम्}.

\stoptext

Or, more conveniently:

\starttext

% display mode
\startTrDevaToIAST
दानं प्रियवाक्सहितं 
ज्ञानमगर्वं क्षमान्वितं शौर्यम्। 
रूपं शीलसुयुक्तं
दुर्लभमेतच्चतुर्भद्रम्॥
\stopTrDevaToIAST

% or inline
Charity accompanied by sweet words {\TrDevaToIAST दानं प्रियवाक्सहितं}, knowledge devoid of arrogance, valour accompanied by forgiveness (pity) {\TrDevaToIAST ज्ञानमगर्वं क्षमान्वितं शौर्यम्}, beauty accompanied by virtue (grace) {\TrDevaToIAST रूपं शीलसुयुक्तं} – these four are scarce {\TrDevaToIAST दुर्लभमेतच्चतुर्भद्रम्}.

\stoptext

Exceptions

Sometimes, one might want to leave retain words or phrases in the original script and avoid transliteration. To this end, \transliterationexception may be used to define such exceptions

  • at the level of a transliteration scheme, i.e., per vector as in:
\transliterationexception[deva to iast]{शरीरं}{देहं}
\transliterationexception[TrDevaToIAST]{शरीरं}{देहं}

When both are defined, the latter overrides the former. Moreover, any derived transliteration instances also inherit the exceptions defined for the parent. So, if any exceptions are to be avoided/changed, they must be redefined for the derived instances.

Source with transliterated version

Very often, one wants to typeset paragraphs in the original script accompanied by a transliterated version. This can be achieved using the before key of \definetransliteration. A simple example is as follows:

\usetransliteration[indic]
\setuplines[indenting={yes,small,even}]
\definebuffer
    [padya]
\definetransliteration
    [padyaPair]
    [color=blue,
     vector={deva to iast},
     before={\startlines\getbuffer[padya]\par},
     after=\stoplines]

\starttext
\startbuffer[padya]
कोऽतिभारः समर्थानां किं दूरं व्यवसायिनाम्।
को विदेशस्तु विदुषां कः परः प्रियवादिनाम्॥
\stopbuffer

\startpadyaPair
\getbuffer[padya]
\stoppadyaPair
\stoptext

In summary: one defines a buffer which contains the paragraph, a verse in this example, in the original script. Then, using the before and after keys of \definetransliteration, a pair of verses may be easily typeset into lines.