7

I'm in the process of trying to turn an English document into Hindi based on a translation in Word. However, I'm struggling to find a font that does what I want. As I'm working with an existing document in XeLaTeX, I need fonts with bold and italics available, which many Hindi unicode fonts don't have.

I have found one font that does what I want (Osho), but I don't like its punctuation marks (eg, the comma looks like an 'undo'-type up arrow). Is it possible for me to use the Osho font, with punctuation coming from another font?

I've now included a sample of my file below - some of the code may not be necessary, but I think most of it is - and heaps has been left out style-wise.

\documentclass[twoside]{report}
\usepackage{fontspec} 
\usepackage{polyglossia} 
\usepackage{xltxtra} 
\setdefaultlanguage{hindi}
\setotherlanguage{english}
\setmainfont[Script=Devanagari,Ligatures=TeX]{Osho}
\newfontfamily\devanagarifont[Script=Devanagari,Ligatures=TeX]{Osho}
%\setotherfont[Script=English,Ligatures=TeX]{Times New Roman}
\newfontfamily{\englishfont}{Times New Roman}
\usepackage{newunicodechar}
\newunicodechar{‘}{{\englishfont ‘}}
\newunicodechar{’}{{\englishfont ’}}

\begin{document}

\section{परमेश्वर का प्रेरित वचन}

बाइबल की 66 पुस्तकें विशेष क्या है? क्या परमेश्वर ने अन्य दूसरी पुस्तकें भी लिखी है? इस अंक में हम 
‘‘प्रेरणा’’पर विचार करेंगे, जिसके द्वारा परमेश्वर ने बाइबल को लिखा। (2~पतरस 1:12-2:3)

\end{document}
  • 1
    Welcome to TeX.SX. Please add a small example showing your document. Just add the documentclass, the font, and one sentence with comma and period. Maybe you want to link to the font-files, if they are freely available. – LaRiFaRi May 22 '14 at 13:17
2

You can define a specific font command in fontspec just for punctuation. In this example I create an \englishfont family for Latin script (your commands for this were not quite right), then I create a command \punct just for punctuation that uses the \englishfont. It takes one argument, which could be any string you want in the other font, such as \punct{``}.

For convenience, I've demonstrated how you might create further macros to simplify entering the punctuation, like \qql for a left double quote (note that with these you have to put {} or a space after them.

This works perfectly, as far as I can tell, in LuaLaTeX. With XeLaTeX I get some error messages and some characters don't come through correctly. (I don't know Hindi, and my text editor behaved strangely with the Devanagari characters, so I apologize for garbling the text in the example.)

\documentclass[twoside]{report}
\usepackage{fontspec} 
\usepackage{xltxtra} % not needed with LuaLaTeX 

\usepackage{polyglossia} 
\setdefaultlanguage{hindi}
\setotherlanguage{english}

\setmainfont[Script=Devanagari,Ligatures=TeX]{Osho}
\newfontfamily{\englishfont}[Script=Latin,Ligatures=TeX]{Times New Roman}
\newcommand{\punct}[1]{\bgroup\englishfont #1 \egroup}

\newcommand{\qql}{\punct{``}}
\newcommand{\qqr}{\punct{''}}
\newcommand{\ql}{\punct{`}}
\newcommand{\qr}{\punct{'}}

\begin{document}

\section{परमेश्वर का प्रेरित वचन}

बाइबल की 66 पुस्तकें विशेष क्या है? क्या परमेश्वर ने अन्य दूसरी पुस्तकें भी लिखी है? इस अंक में हम 
\punct{‘‘}प्रेरणा’’पर विचार करेंगे, जिसके द्वारा परमेश्वर ने बाइबल को लिखा। (2~पतरस 1:12-2:3)

\qql{}प्रेरणा’’पर \ql{}विचार करेंगे, जि\qr{} द्वारा परमेश्वर ने\qqr{}   बाइबल को लिखा। (2~पतरस 1:12-2:3)
\end{document}

enter image description here

| improve this answer | |
1

You may use \newunicodechar in a more complicated way to check whether the next character is the same. We need a different active character (here ?) because \newunicodechar already uses ~ internally.

\documentclass[twoside]{report}
\usepackage{fontspec} 
\usepackage{polyglossia} 
\setdefaultlanguage{hindi}
\setotherlanguage{english}
\setmainfont[Script=Devanagari,Ligatures=TeX]{Devanagari MT}
\newfontfamily\devanagarifont[Script=Devanagari,Ligatures=TeX]{Devanagari MT}

\newfontfamily{\englishfont}{Times New Roman}
\usepackage{newunicodechar}

\makeatletter
\begingroup\catcode`?=\active \lccode`?=`‘
\lowercase{\endgroup
  \newunicodechar{‘}{\@ifnextchar?{{\englishfont “}\@gobble}{{\englishfont ‘}}}
}
\begingroup\catcode`?=\active \lccode`?=`‘
\lowercase{\endgroup
\newunicodechar{’}{\@ifnextchar?{{\englishfont ”}\@gobble}{{\englishfont ’}}}
}
\makeatother

\begin{document}

\section{परमेश्वर का प्रेरित वचन}

बाइबल की 66 पुस्तकें विशेष क्या है? क्या परमेश्वर ने अन्य दूसरी पुस्तकें भी लिखी है? इस अंक में हम 
‘‘प्रेरणा’’पर विचार करेंगे, जिसके द्वारा परमेश्वर ने बाइबल को लिखा। (2~पतरस 1:12-2:3)

‘बाइबल’
\end{document}

enter image description here

| improve this answer | |

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.