[Tex/LaTex] How to use a Gurumukhi font to typeset Punjabi with XeLaTeX or PDFLatex

indiclanguagesxetex

Folks I'm having a hard time using a non-English font with my LaTeX file. I've struggled for the last few days without success.
Some background I'm using Kile on Windows (with MikTeX). I know I need to compile with XeLateX for some reason and yes, I am doing that. I need to type a few sentences in the Gurumukhi/Punjabi font. After this sentence things don't make much sense to me. This font is available as i) .ttf file and I have it installed on my computer, ii) on CTAN here:https://www.ctan.org/pkg/gurmukhi-singh, and iii) as an .itx file here: http://www.aczoom.com/itrans/html/pundoc/pundoc.html . I have no idea what to do with the font, however.

Can someone provide detailed instructions on how to use it for someone who is not well-versed in installing stuff on .tex? Also: I can type in Punjabi that is not an issue; i.e., I do not need any transliterations – just how to get it into my tex file.

Best Answer

Here is a possible solution using the Saab font. I don't know anything about the Gurmukhi script, and the Saab font doesn't seem to recognize the Gurmukhi script tag, even though it should, so there may be problems with the font. For small sections of Punjabi text, this may be sufficient. For whole documents you would need to write your own version of a polyglossia .ldf file for Punjabi, but this is not really a beginner's task, unfortunately.

(If there are major problems with the output of this, (apart from the bad Google translation) please let me know in the comments and I will delete the answer.)

% !TEX TS-program = XeLaTeX

\documentclass[10pt]{article}
\usepackage{fontspec}
\newfontfamily\punjabifont{Saab}
\DeclareTextFontCommand{\textpunjabi}{\punjabifont}

\begin{document}
\section{A section}
\textpunjabi{ ਇਹ ਇੱਕ ਦੀ ਸਜ਼ਾ ਜੋ ਕਿ ਹੈ ਬੁਰੀ} Google \textpunjabi{ਦੁਆਰਾ ਅਨੁਵਾਦ ਕੀਤਾ ਗਿਆ ਹੈ.}
\end{document}

output of code

Related Question