2

I have referred to Cicada's solution to get vedic swara markings working on my osx. To test my MWE on your system, you will have to install fonts Shobhika and Sanskrit 2003 - sorry about that!

The MWE I used is the same as what Cicada posted:

\documentclass[12pt,varwidth,border=6pt]{standalone}
\usepackage{fontspec}
\newcommand\mysktfont{Shobhika Regular}
\newfontface\fplain{\mysktfont}% no mapping
\newcommand\devtext{
\fontspec[Script=Devanagari,Mapping=itrans-dvn2]{\mysktfont}}%mapping transliteration to Devanagari
\newcommand\iast{
           \fontspec[Mapping=itrans-iast2]{\mysktfont}} %mapping transliteration to IAST transliteration scheme

 \newcommand{\Paragraph}[1]{\devtext{#1}
\par\medskip
{\iast{#1}}}

\begin{document}
\fplain
नम॑ः 

\Paragraph{
nama!ste^^^^1cda rudra ma-nyava! u-tota- iSha!ve- namaH. \\
 nama!ste^^^^1cda astu- dhanva!ne bA-hubhyA!mu-ta te- nama!H
}

\end{document}

I prepared my system thus:

$ git clone https://github.com/Shreeshrii/xetex-itrans.git
$ cp itrans-iast.map itrans-iast2.map
$ # Edit itrans-iast2.map
$ Teckit_compile itrans-iast2
$ diff -du itrans-iast.map itrans-iast2.map 
--- itrans-iast.map 2020-02-02 05:58:51.000000000 -0800
+++ itrans-iast2.map    2020-02-02 06:00:15.000000000 -0800
@@ -153,6 +153,9 @@

 pass(Unicode)

+svarita > U+0951
+anudatta > U+0952
+
 a > asvara
 a a > Asvara
 A > Asvara


$ cp *.tec *.map /usr/local/texlive/texmf-local/fonts/misc/xetex/fontmapping/xetex-itrans/
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvXc] source_file ... target_directory

$ sudo mkdir -p !$ 

$ sudo mkdir -p /usr/local/texlive/texmf-local/fonts/misc/xetex/fontmapping/xetex-itrans/ 
Password:

$ sudo cp *.tec *.map /usr/local/texlive/texmf-local/fonts/misc/xetex/fontmapping/xetex-itrans/


$ sudo mktexlsr 
mktexlsr: Updating /usr/local/texlive/2016/texmf-config/ls-R... 
mktexlsr: Updating /usr/local/texlive/2016/texmf-dist/ls-R... 
mktexlsr: Updating /usr/local/texlive/2016/texmf-var/ls-R... 
mktexlsr: Updating /usr/local/texlive/texmf-local/ls-R... 
mktexlsr: Done.

The pdf file resulting from running xelatex swara.tex shows that the itrans text is not converted to devanagari:

image of swara.pdf

I found a few errors in the log file (swara.log) generated from xelatex. The entire log file is uploaded here

.................................................
Font mapping `itrans-dvn2.tec' for font `Shobhika Regular' not found.
.................................................
. fontspec info: "no-font-shape"
. 
. Could not resolve font Shobhika Regular/I (it probably doesn't exist).
.................................................
.................................................
. fontspec info: "defining-font"
. 
. Font family 'ShobhikaRegular(2)' created for font 'Shobhika Regular' with
. options [Mapping=itrans-iast2].
. 
. This font family consists of the following NFSS series/shapes:
. - 'normal' (m/n) with NFSS spec.: <->"Shobhika
. Regular/OT:script=latn;language=DFLT;mapping=itrans-iast2;"
. - 'small caps'  (m/sc) with NFSS spec.: - 'bold' (bx/n) with NFSS spec.:
. <->"Shobhika Regular/B/OT:script=latn;language=DFLT;mapping=itrans-iast2;"
. - 'bold small caps'  (bx/sc) with NFSS spec.: - 'bold italic' (bx/it) with
. NFSS spec.: <->"Shobhika
. Regular/BI/OT:script=latn;language=DFLT;mapping=itrans-iast2;"
. - 'bold italic small caps'  (bx/itsc) with NFSS spec.: 
.................................................

I verified that the Shobhika font is indeed installed on my mac by running xetex opentype-info.tex after setting myfontname to Shobhika Regular:

Output of xetex opentype-info.tex for Shobhika font

The font features directive in the fontspec in my source (swara.tex) refers to Mapping=itrans-dvn2 but I don't find any map or tec files named itrans-dvn2* under /usr/local/texlive/texmf-local/fonts/misc/xetex/fontmapping/xetex-itrans/ This is one of the errors in the log file. @Cicada never said anything about generating this file and I don't see it in the git repo either.

I changed the font name from Shobhika to Sanskrit 2003 in my source and that failed too. Entire log is here

Update 1

Without relying on the .tec files to provide swara markings, I inserted the them manually into my document (as was suggested in another post):

\documentclass[12pt,varwidth,border=6pt]{standalone}
\usepackage{fontspec}
\newcommand\mysktfont{Shobhika Regular}
\newfontface\fplain{\mysktfont}% no mapping
\newcommand\devtext{
\fontspec[Script=Devanagari,Mapping=itrans-dvn]{\mysktfont}}%mapping transliteration to Devanagari
\newcommand\iast{
           \fontspec[Mapping=itrans-iast]{\mysktfont}} %mapping transliteration to IAST transliteration scheme

\newcommand\svarita{^^^^0951}
\newcommand\anudatta{^^^^0952}
\newcommand\doublesvarita{^^^^1cda}

 \newcommand{\Paragraph}[1]{\devtext{#1}
\par\medskip
{\iast{#1}}}

\begin{document}
\fplain
नम॑ः 

\Paragraph{nama\svarita ste\doublesvarita\ rudra ma\anudatta nyava\svarita\ u\anudatta tota\anudatta\ iSha\svarita ve\anudatta\ namaH. \\
 nama\svarita ste\doublesvarita\ astu\anudatta\ dhanva\svarita ne bA\anudatta hubhyA\svarita mu\anudatta ta te\anudatta\ nama\svarita H}

\end{document}

This gives me text with swara markings, with one exception that I have pointed out with a red arrow:

Image with macros for swara markings

If there's a way to get rid of the weird circle between नम and , my problem would be resolved.

Update 2

Output with font Siddhanta

Output with font Siddhanta

  • Update: I changed Mapping=itrans-dvn2 to Mapping=itrans-dvn and used the macros for anudatta etc. and can now see swara markings in my document. There is a weird character between the svarita marking and H in ` nama{\svarita}H`. How can it be fixed? – linuxfan Feb 2 '20 at 22:43
  • itrans-iast2 is distribution file itrans-iast with two lines added: svarita > U+0951 anudatta > U+0952 and itrans-dvn2 is distribution file iast-dvn with the equivalent: svarita > vstroke anudatta > hstroke if I recall correctly. \svarita with a \ is a macro - a mapped font converts the input characters into the output characters according to the conversion rules specified in the mapping file. Macro names are not part of that process. Just like you type the characters na (not \na) and they are mapped to . – Cicada Feb 3 '20 at 12:51
  • What code did you run? \svarita macro is not defined in the MWE posted above, so it gives the error ! Undefined control sequence. – Cicada Feb 3 '20 at 12:52
  • 1
    In your dropbox link for new-svara.tex, the three macros \newcommand\svarita{^^^^0951} \newcommand\anudatta{^^^^0952} \newcommand\doublesvarita{^^^^1cda} illustrate how the itrans mapping file cannot handle some combinations in the devanagari: compare the mapped output (नम॑ः displays wrong in my browser also) with the unmapped one (that uses the \fplain font and produces the correct shape). The macros do not rely on mapping, in any case; so you can use them in place of direct input if you do not have a Vedic IME. Similarly with all the other accents. – Cicada Feb 4 '20 at 11:48
  • 1
    If you have Sanskrit 2003 why don't you install Siddhanta from the same place I installed Sanskrit2003: sanskritweb.net/itrans/index.html#SIDDHANTA this font is much better set up and námaḥ should work out of the box with it – Au101 Feb 10 '20 at 0:22
4
+500

I have no knowledge of devanagari but it looks as if the input order of the stress sign UDATTA (U+0951) and VISARGA (U+0903) matters. There is a discussion here about the input order: https://github.com/harfbuzz/harfbuzz/issues/2017

It also looks as if the noto fonts has small problems and that siddhanta is better. (https://github.com/googlefonts/noto-fonts/issues/1551).

When I compile the following in a current texlive with lualatex-dev (and so with harfbuzz enabled) (the ^^^^-notation is only there as it is easier for me to input)

\documentclass{article}
\usepackage{fontspec}
\setmainfont{NotosansDevanagari}[Renderer=Harfbuzz,Script=Devanagari]

\setsansfont{siddhanta}[Renderer=Harfbuzz,Script=Devanagari]

\begin{document}
^^^^0928^^^^092e^^^^0951^^^^0903 नम॑ः

^^^^0928^^^^092e^^^^0903^^^^0951 नमः॑

\sffamily

^^^^0928^^^^092e^^^^0951^^^^0903 नम॑ः

^^^^0928^^^^092e^^^^0903^^^^0951 नमः॑

\end{document}

I get this output:

enter image description here

  • Thanks very much Ulrike! Can you explain the benefits, if any, of using lualatex/lualatex-dev over xelatex? – linuxfan Feb 12 '20 at 3:24
  • 2
    luatex has better microtype and bidi features and you can use the lua callbacks. And now that harfbuzz has been integrated (in the luahbtex engine used by lualatex-dev) the main advantage of xetex is gone. Beside this the maintainer of luaotfload are nice people ;-). – Ulrike Fischer Feb 12 '20 at 8:26
  • side remark: In case you are considering it: don't assign the bounty directly. – Ulrike Fischer Feb 12 '20 at 10:03
  • I don't understand what you mean by not assigning the bounty directly. – linuxfan Feb 13 '20 at 1:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.