3

I am typing Hindi by using google input tools, code is given below, running by LuaLaTeX. But code not giving same words of Hindi which I am writing in there, there is a lot of difference

Output image is given here

\documentclass{article}
\usepackage{amsmath,comment,color}
\usepackage{blindtext}\usepackage{accsupp}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\newfontface{\hindi}[Script=Devanagari]{Lohit Devanagari}
\usepackage[a4paper,left=1in,right=1in,top=.5in,bottom=.5in,footskip=.25in]{geometry}
\date{}
\title{\underline {\bf {Bloch Siegert Shift in Weyl}}}
\date{}
\begin{document}
\maketitle
{\hindi उपेन्द्र अवस्थी एक शोध रत विद्यार्थी है |}
\end{document}  

3 Answers3

5

Generally speaking, the current state is that xetex (via the harfbuzz library) is better at shaping indic scripts than luatex at the present time.

I can't read this or comment which is more correct but your test file produces

enter image description here

in xelatex and

enter image description here

in lualatex.


2018 update

With current luatex, if you give it a hint to use the deva feature rather than dev2 feature then the lualatex output is better (comparable to Luigi's context answer)

enter image description here

\documentclass{article}
\usepackage{amsmath,comment,color}
\usepackage{blindtext}\usepackage{accsupp}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\newfontscript{Devanagari}{deva,dev2}
\newfontface{\hindi}[Script=Devanagari]{Lohit-Devanagari.ttf}
\usepackage[a4paper,left=1in,right=1in,top=.5in,bottom=.5in,footskip=.25in]{geometry}
\date{}
\title{\underline {\bf {Bloch Siegert Shift in Weyl}}}
\date{}
\begin{document}
\maketitle
{\hindi उपेन्द्र अवस्थी एक शोध रत विद्यार्थी है |}
\end{document} 
David Carlisle
  • 757,742
4

(too long for a comment, hence posted as an answer)

I'm not sure if I understood your query: Are you saying that you don't like the look of the Lohit Devanagari font, or are you saying there's an error in the way the test string is typeset?

Anyway, here's how the test string is typeset via LauLaTeX using six different font families: Lohit Devanagari, and 5 systems fonts I found on my system (MacOS 10.12.4). Do let me know if you can spot a problem with one or more of the fonts.

enter image description here

\documentclass{article}
\usepackage[a4paper,hmargin=1in,vmargin=0.5in,footskip=0.25in]{geometry}
\usepackage{fontspec}
\setmainfont{Times New Roman}
\newcommand\hhh{उपेन्द्र अवस्थी एक शोध रत विद्यार्थी है |} % test string
\newcommand\hin[1]{\newfontface{\hindi}[Script=Devanagari]{#1}}
\newcommand\test[1]{#1 & \hin{#1}\hindi\hhh }

\begin{document}

\noindent
\begin{tabular}{@{}lr@{}}
\test{DevanagariMT} \\
\test{Lohit Devanagari} \\
\test{Kohinoor Devanagari} \\
\test{Devanagari Sangam MN} \\
\test{ITF Devanagari Book} \\
\test{Shree Devanagari 714} \\
\end{tabular}
\end{document} 
Mico
  • 506,678
  • 1
    I suspect that just the last of those is correct (with just three glyphs in the first word) all the others show 5, as I also got with lualatex with the OPs font, showing that it hasn't combined some things that could be combined. (But I can't read this at all so I could be wrong:-) – David Carlisle Apr 08 '17 at 10:43
  • can you post the xelatex output from the same? – David Carlisle Apr 08 '17 at 11:48
  • @DavidCarlisle - Not sure what I'm doing wrong (or even if I'm doing some wrong...), but try as I might I cannot get my answer to compile under XeLaTeX. – Mico Apr 08 '17 at 16:24
  • doesn't find the fonts? (sometimes helps to use the filenames rather than internal font names, depending on fontconfig voodoo:-) or do you mean it finds the fonts then gives errors? – David Carlisle Apr 08 '17 at 16:29
  • @DavidCarlisle - XeLaTeX does seem to find the fonts. But I either get complaints about Script=Devanagari being wrong or nothing happens at all -- no errors or warnings, but also no output. – Mico Apr 08 '17 at 16:48
  • http://chat.stackexchange.com/transcript/message/36592153#36592153 – David Carlisle Apr 08 '17 at 16:59
  • @DavidCarlisle - Thanks! Glad you (and egreg) were able to get the code to work under XeLaTeX, confirming your earlier hunch that XeLaTeX does a better job with Indic scripts than LuaLaTeX does. (I still have no idea why the code of my answer has steadfastly refused to run successfully under XeLaTeX.) – Mico Apr 08 '17 at 17:06
  • 1
    The Shree Devanagari 714 example is absolutely correct and you can refer to it to see how this string should appear. All of the others are wrong I'm afraid, unfortunately not in the sense of being ugly, but being wrong. For example, at the very least, in the penultimate word विद्यार्थी if you look at the bottom line it is वि as it should be with that hook above the व and to the left of it. All the others have it afterwards actually making it seem to go with the next letter which is totally wrong. (Obviously this is not to impune your fine answer, but to highlight the problem :) ) – Au101 Apr 08 '17 at 23:10
  • 1
    By the way your code runs fine on my machine, mind you i only have one of the fonts. The `fontspec warning: "script-not-exist"
    • Font 'Lohit Devanagari' does not contain script 'Devanagari'.warning doesn't appear to be important, it's something I started getting recently, but it renders absolutely perfectly anyway. If you take out[Script=Devanagari]` it may not render correctly
    – Au101 Apr 08 '17 at 23:14
4

It depends on the features enabled: in ConTeXt mkiv (luatex engine) with the feature "devangari-two" (expanded as below) we have

\definefont
  [DevaLohiTwo]
  [file:Lohit-Devanagari.ttf*devanagari-two at 16pt]
\starttext
\startTEXpage
Features enabled:

\starttyping
abvm | abvs | akhn | blwf | blwm | blws | dist | half | haln | 
language=dflt | mode=node | nukt | pres | psts | rphf | script=deva | 
vatu
\stoptyping
\hbox to\textwidth{\ss\tfb Lohit-Devanagari:\hfill%
{\DevaLohiTwo उपेन्द्र अवस्थी एक शोध रत विद्यार्थी है}\|}
\stopTEXpage
\stoptext

enter image description here

If we don't use this set of features the result can be different, as is in this case:

\definefont
  [DevaLohi]
  [file:Lohit-Devanagari.ttf at 16pt]
\starttext
\startTEXpage
\hbox to\textwidth{\ss\tfb Lohit-Devanagari:\hfill%
{\DevaLohi उपेन्द्र अवस्थी एक शोध रत विद्यार्थी है}\|}
\stopTEXpage
\stoptext

enter image description here

Luigi Scarso
  • 566
  • 2
  • 4