Open main menu

Changes

14,144 bytes added ,  03:47, 8 February 2022
{{todo|this page needs to be reviewedis under construction}}
= Basic Sample Fonts =
A very basic sample with Indic scripts is Fonts are complicated. Moreover, those for indic languages have to provide for rules for the following:formation of several complicated conjuncts. Each of these conjuncts can consist of several forms occurring simultaneously, which have to be positioned correctly relative to the base glyph. OTF documentation notwithstanding, font designers have their own interpretations of the specifications leading to a variety of implementations of the font features. Most of the available fonts are tested against Harfbuzz and/or ICU (sometimes only the former). Since ConTeXt uses its own OTF loading system, many indic fonts do not just work right away.
In early 2022, Hans made some nice improvements to the indic font system in ConTeXt. This was accompanied by some testing with various available fonts for some indic languages. As a result, there is an improved support for Indic fonts in ConTeXt. Various typescripts were then bundled into the ConTeXt distribution for easy use in documents.
 
The following table lists fonts that have been tested for use with ConTeXt. The list is by no means extensive: most of the fonts are relatively new and some (ubiquitous) old fonts are absent. If you find a font missing in this list and that works well in ConTeXt, please add it to the list. To use indic fonts place
<texcode>
\usetypescriptfile[indic]</texcode>in the document head and use {{cmd|definetypeface}} and/or {{cmd|setupbodyfont}} with the following typescripts: {|cellpadding="5"|-style="background-color:#e1effa;"! style="width:17.5%;" | Sans ! style="width:17.5%;" | Serif! style="width:35%\definefontfamily ;" | Notes! Typescript(s)|-style="background-color:#fef6e7;"! colspan="4" | Devanagari|-| | [https://adishila.com/fonts/ Adishila]| 4 different designs; many weights and styles; good conjunct coverage; IAST support| <code>adishila</code></br><code>adishila-semibold</code></br><code>adishila-heavy</code></br><code>adishila-dev</code></br><code>adishila-dev-guru</code></br><code>adishila-san</code></br><code>adishila-san-letterpress</code></br>|-| | [kannadahttps://github.com/Sandhi-IITBombay/Shobhika Shobhika] | two weights; good conjunct coverage; IAST support; some maths support| <code>shobhika</code>|-| [rmhttps://github.com/EkType/Baloo2 Baloo] | | five weights| <code>baloo</code></br><code>baloo-semibold</code></br><code>baloo-extrabold</code></br>|-|| [Kedagehttps://github.com/etunni/Amita Amita] | calligraphic style | <code>amita</code>|-|| [featureshttps://github.com/EkType/Jaini Jaini, Jaini Purva]| fonts with calligraphic style commonly found in Jaina kalpasūtra manuscripts| <code>jaini</code></br><code>jaini-purva</code></br>|-style=kannada"background-color:#fef6e7;"! colspan="4" | Malayalam|-| | [https://rachana.org.in/ RIT Rachana] | an elegant font good conjunct coverage; two weights; italic style; oneof the most complete fonts available| <code>rit-rachana</code>|-|| [https://rachana.org.in/ Panmana]| good conjunct coverage; single weight; body-text font| <code>panmana</code>|-| [https://rachana.org.in/ Ezhuthu]| | handwriting font; single weight| <code>ezhuthu</code>|-|| [https://rachana.org.in/ RIT Sundar]| Single weight| <code>rit-sundar<code>|-| [https://rachana.org.in/ TN Joy]| | three weights| <code>tn-joy</code>|-| [https://smc.org.in/fonts/manjari/ Manjari]| | curvy handwriting font; suitable for body and titles; three weights| <code>manjari</code>|-| [https://smc.org.in/fonts/gayathri/ Gayathri]| | three weights| <code>gayathri</code>|-| [https://smc.org.in/fonts/anjalioldlipi Anjali Old Lipi]|| legible font intended for body text; glyphs for common Malayalam ligatures & Latin charset| <code>anjali-old-lipi</code>|-| [https://smc.org.in/fonts/chilanka Chilanka]\definefontfamily | | handwriting style font with most of the unique Malayalam conjuncts; uniform width glyph strikes with round ends| <code>chilanka</code>|-| [kannadahttps://smc.org.in/fonts/dyuthi Dyuthi] | | an ornamental typeface; Latin and Malayalam; Malayalam glyphs are based on popular 'bulged ended' type designs; single size – thicker than usual Malayalam fonts; suited for titles| <code>dyuthi</code>|-| [sshttps://smc.org.in/fonts/karumbi Karumbi] || handwriting traditional script font; casual style| <code>karumbi</code>|-| [Tungahttps://github.com/EkType/Baloo2 Baloo Chettan 2] || five weights| <code>baloo-chettan</code><code>baloo-chettan-semibold</code></br><code>baloo-chettan-extrabold</code>|-style="background-color:#fef6e7;"! colspan="4" | Telugu|-| [https://github.com/EkType/Baloo2 Baloo Tammudu 2]| | five weights| <code>baloo-tammudu</code><code>baloo-tammudu-semibold</code></br><code>baloo-tammudu-extrabold</code>|-| | [featureshttps://www.murtylibrary.com/mcli-fonts.php Murty Telugu]| good conjunct coverage; single-weight; consult license for terms of use | <code>murty-telugu</code>|-style="background-color:#fef6e7;"! colspan="4" | Kannada|-| | [https://www.murtylibrary.com/mcli-fonts.php Murty Kannada]| good conjunct coverage; single-weight; consult license for terms of use | <code>murty-kannada</code>|-style="background-color:#fef6e7;"! colspan="4" | Tamil|-| [https://github.com/EkType/Baloo2 Baloo Thambi 2]|| five weights| <code>baloo-thambi</code>|-style="background-color:#fef6e7;"! colspan="4" | Bengali|-| [https://github.com/EkType/Baloo2 Baloo Da 2]|| five weights| <code>baloo-da</code><code>baloo-da-semibold</code></br><code>baloo-da-oneextrabold</code>|-| | [https://www.murtylibrary.com/mcli-fonts.php Murty Bangla]| good conjunct coverage; single-weight; consult license for terms of use | <code>murty-bangla</code>|-style="background-color:#fef6e7;"! colspan="4" | Gujarati|-| [https://github.com/EkType/Baloo2 Baloo Bhai]|| five weights| <code>baloo-bhai</code></br><code>baloo-bhai-semibold</code></br><code>baloo-bhai-extrabold</code>|-|| [https://fonts.google.com/noto Noto Serif Gujarati]| font from Google| <code>noto-serif-gujarati</code>|}
\definetypeface [kannada] [mm] [math] [modern]= Supported Scripts and Font Features =
\setupbodyfont [kannada]One can of course use fonts not listed above. This section provides some details to this end.
\starttextಇದು ಹೇಗಿದೆ? ನಾನು ಹೀಗೆ ತುಂಬ ಬರೆಯಬೇಕೆಂದು ಯೋಚಿಸುತ್ತಿದ್ದೇನೆ.\stoptext</texcode>== Font feaures ==
= Supported Scripts =The OTF specification has two shaping implementations for the indic scripts: the 'older' v1 and the 'newer' v2. [https://docs.microsoft.com/en-us/typography/script-development/devanagari See here] for further details.
The list of [https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags Script tags from the OpenType specification] contains second versions for some Indic scripts supported by ConTeXt MkIV and LMTX are:.
* Devanagari* Bengali* Gujarati* Gurmukhi* Kannada* Malayalam* Oriya* Tamil* TeluguWhy are those second versions available? From their own explanation:
In order to get the proper <blockquote>The OpenType script tags can also correlate with a particular OpenType featuresLayout implementation, you need to select the proper feature from with the following list:result that more than one script tag may be registered for a given Unicode script (e.g. 'deva' and 'dev2').</blockquote>
* Features ending in <code>devanagari-one</code>* use the older OpenType implementation, while the ones ending in <code>bengali-one</code>* <code>gujarati-one</code>* <code>gurmukhi-one</code>* <code>kannada-one</code>* <code>malayalam-one</code>* <code>oriya-one</code>* <code>tamil-one</code>* <code>telugu-onetwo</code>deploy the newer implementation.
Depending on your These are specified in ConTeXt by the following font, you might need insteadfeatures:
* {| cellpadding="5"! style="text-align:left;" | Script! style="text-align:left;" | OTF v1 script tag! style="text-align:left;" | OTF v2 script tag|-| Devanagari| <code>devanagari-twoone</code>* | <code>bengalidevanagari-two</code>* |-| Malayalam| <code>gujaratimalayalam-one</code>| <code>malayalam-two</code>* |-| Telugu| <code>gurmukhitelugu-twoone</code>* | <code>kannadatelugu-two</code>* |-| Kannada| <code>malayalamkannada-twoone</code>* | <code>oriyakannada-two</code>* |-| Bengali| <code>tamilbengali-twoone</code>* | <code>telugubengali-two</code>|-|}
== Script Versions ==Please note that these font features also activate other font features as mandated in the OTF specification. These features can then be used to write typescripts for a font or to use the font directly in documents {{cmd|definefontfamily}} and/or {{cmd|definedfont}}.
[https://docsOne of the common problems one might encounter with indic fonts is that of incorrect rendering of conjuncts involving the rakaar.microsoft.comIn case any problems are encountered, one can try setting the <code>indic</encode> feature (in addition to relevant <code>-usone</typographycode> or <code>-two</opentype/spec/scripttags Script tags from the OpenType specificationcode> features above) appropriately as follows:<texcode>\definefontfeature […] […] contains second versions for what might be some (or all [I’m afraid I don’t knowindic={matra=auto,conjuncts=quit}]) Indic scripts.</texcode>
Why are those second versions available? From their own explanation== Sanitizer ==Sometimes, some fonts might still have issues with certain conjuncts. To overcome this a <code>sanitizer</code> option may be used in defining font features. A goodies file accompanies this option. An example is illustrated below:
<blockquotetexcode>The OpenType script tags can also correlate with a particular OpenType Layout implementationreturn { name = "myfont", version = "1.00", with the result comment = "Goodies that more than one script tag may be registered for a given Unicode script (e.g. 'deva' and 'dev2')complement myfont.", sanitizers = { dev2rkrf = { mapping = { ["के्र"] = "क्रे", ["कै्र"] = "क्रै", ["खे्र"] = "ख्रे", ["खै्र"] = "ख्रै", ["गे्र"] = "ग्रे", ["गै्र"] = "ग्रै", ["घे्र"] = "घ्रे", ["घै्र"] = "घ्रै", ["चे्र"] = "च्रे", ["चै्र"] = "च्रै", ["छे्र"] = "छ्रे", ["छै्र"] = "छ्रै", ["जे्र"] = "ज्रे", ["जै्र"] = "ज्रै", ["झे्र"] = "झ्रे", ["झै्र"] = "झ्रै", ["ञे्र"] = "ञ्रे", ["ञै्र"] = "ञ्रै", ["णे्र"] = "ण्रे", ["णै्र"] = "ण्रै", ["ते्र"] = "त्रे", ["तै्र"] = "त्रै", ["थे्र"] = "थ्रे", ["थै्र"] = "थ्रै", ["दे्र"] = "द्रे", ["दै्र"] = "द्रै", ["धे्र"] = "ध्रे", ["धै्र"] = "ध्रै", ["ने्र"] = "न्रे", ["नै्र"] = "न्रै", ["पे्र"] = "प्रे", ["पै्र"] = "प्रै", ["फे्र"] = "फ्रे", ["फै्र"] = "फ्रै", ["बे्र"] = "ब्रे", ["बै्र"] = "ब्रै", ["भे्र"] = "भ्रे", ["भै्र"] = "भ्रै", ["मे्र"] = "म्रे", ["मै्र"] = "म्रै", ["ये्र"] = "य्रे", ["यै्र"] = "य्रै", ["वे्र"] = "व्रे", ["वै्र"] = "व्रै", ["से्र"] = "स्रे", ["सै्र"] = "स्रै", ["शे्र"] = "श्रे", ["शै्र"] = "श्रै", ["षे्र"] = "ष्रे", ["षै्र"] = "ष्रै", ["हे्र"] = "ह्रे", ["है्र"] = "ह्रै", } } }}</blockquotetexcode>
Features ending in Suppose that for a certain font (say <code>myfont</code>), using <code>devanagari-onetwo</code> use features, the older OpenType implementation, above listed ra + consonant + vowel forms are not rendered properly. The above goodies file is then saved as <code>myfont.lfg</code> and used while defining the ones ending in features thus:<codetexcode>\definefontfeature [myfontfeatures] [devanagari-two] [goodies=myfont.lfg, sanitizer=dev2rkrf, indic={movematra=auto,conjuncts=quit}]</texcode>Now, <code> deploy myfontfeatures</code> can be used with {{cmd|definedfont}} and/or while writing typescripts for the newer implementationfont.
= Hyphenation Script and language features =
The hyphenation patterns for the following languages are included in ConTeXt:
* Sanskrit {|cellpadding="5"! style="text-align:left;" | Script/Language! style="text-align:left;" | Conversion set! style="text-align:left;" | Hyphenation|-| Devanagari| <code>devanagarinumerals</code>| |-| Malayalam| <code>samalayalamnumerals</code>* Hindi | <code>hi\language[ml]</code>* |-| Kannada | <code>kannadanumerals</code>| <code>\language[kn]</code>* |-| Telugu | <code>telugunumerals</code>| <code>\language[te]</code>|-| Bengali| <code>bengalinumerals</code>* | <code>\language[bn]</code>|-| Tamil | <code>tamilnumerals</code>| <code>\language[ta]</code>|-| Gujarati| <code>gujaratinumerals</code>* Malayalam | <code>\language[gu]</code>|-| Gurmukhi| <code>mlgurmukhinumerals</code>* Bengali ||-| Hindi| <code>bndevanagarinumerals</code>* Gujarati | <code>gr\language[hi]</code>|-| Sanskrit| <code>devanagarinumerals</code>A pattern is activated with {{cmd|<code>\language[sa]</code>|}}. The Sanskrit hyphenation patterns support hyphenation of Sanskrit written using the Malayalam, Telugu, Kannada, Bengali and Latin with IAST.
= Numbers and Conversion sets =A pattern is activated with {{cmd|language}}. The following number conversion sets are available:* Devanagari Sanskrit hyphenation patterns <code>devanagarinumeralssa</code>* support hyphenation of Sanskrit written using the Malayalam <code>malayalamnumerals</code>* Tamil <code>tamilnumerals</code>* , Telugu, Kannada <code>kannadanumerals</code>* Telugu <code>telugunumerals</code>* , Bengali <code>bengalinumerals</code>for use and Latin with IAST. Conversion sets are used as values of the keys <code>numberconversion</code>, <code>conversion</code> (wherever applicable) and with {{cmd|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:
{|cellpadding="4"!style="width: 65%; text-align: left;" | Transliteration Scheme!style="text-align: left;" | Vector
|-
|Devanagari to IAST
|IAST to Devanagari
|<code>iast to deva</code>
|-
|ITrans to Devanagari
|<code>itrans to deva</code>
|-
|Devanagari to Malayalam
|<code>deva to mlym</code>
|-
|Malayalam to Devanagari
|<code>mlym to deva</code>
|-
|Devanagari to Kannada
|<code>deva to knda</code>
|-
|Kannada to Devanagari
|<code>knda to deva</code>
|-
|Devanagari to Telugu
|<code>deva to tlgu</code>
|-
|Telugu Devanagari to DevanagariGujarati|<code>tlgu deva to devagujr</code>
|-
|Devanagari to Bengali
|<code>deva to bngl</code>
|-
|Bengali to Devanagari
|<code>bngl to deva</code>
|}
The main macro to set up a transliteration is {{cmd|definetransliteration}}.
 
== A simple example ==
 
A transliteration instance is defined using {{cmd|definetransliteration}}:
<texcode>
\definetransliteration
[TrDevaToIAST]
[vector={deva to iast}, define=yes]
</texcode>
The above This defines a slew of macros for both inline and block transliteration:
<texcode>
\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
</texcode>
 
Or, more conveniently:
 
<texcode>
\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
</texcode>
 
Please note that there is also {{cmd|resettransliteration}} which can be used in stream to (temporarily) prevent any transliteration.
 
== Exceptions ==
 
Sometimes, one might want to leave retain words or phrases in the original script and avoid transliteration. To this end, {{cmd|transliterationexception}} may be used to define such exceptions
* at the level of a transliteration scheme, i.e., per <code>vector</code> as in:
<texcode>
\transliterationexception[deva to iast]{शरीरं}{देहं}
</texcode>
* and/or at the instance level, i.e., per transliteration block define with {{cmd|definetransliteration}} as in:
<texcode>
\transliterationexception[TrDevaToIAST]{शरीरं}{देहं}
</texcode>
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 <code>before</code> key of {{cmd|definetransliteration}}. A simple example is as follows:
 
<texcode>
\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
 
What is a burden for the abled, and what is faraway (beyond reach) to the
perservering? What is a foreign land to the learned and who are strangers to
the sweet-spoken? (None!)
 
\stoptext
</texcode>
 
In summary: one defines a buffer which contains the paragraph (a verse in this example) in the original script. Then, using the <code>before</code> and <code>after</code> keys of {{cmd|definetransliteration}}, a pair of verses may be easily typeset into lines.
107

edits