# How to install HarfTeX on TeXLive?

I've Installed TeX Live 2019 and downloaded HarfTeX. I'm using Visual Studio Code along with LatexWorkshop on Windows 10 and without any problem tex files compile with xelatex and lualatex. What to do now to make HarfTex work with it or with TexStudio?

Here's my problem with lualatex without HarfTeX.

# Update november 2019

From now on the recommended way to use harfbuzz with luatex and latex is to use a latex format based on the engine luahbtex together with the version 3.11 or newer of luaotfload which contains support for the harf mode.

The binary luahbtex has been added to texlive 2019 for the major OS. It has been connected to the lualatex-dev format. So texlive user can try it out by compiling with lualatex-dev. (see What is "latex-dev"? about what latex-dev means)

MiKTeX has luahbtex too. It has also mapped lualatex-dev to this engine. You should have both executables in the \miktex\bin folder of MiKTeX.

With the new engine and luaotfload 3.11 the example below would look like this. It is no longer needed to load special lua code. Starting with this version the script should be a script in the font (similar to the normal handling with luatex and mode=node).

\documentclass{article}
\usepackage{fontspec}

\setmainfont{notosansbengali-regular.ttf}[RawFeature={mode=harf;script=ben2;}]
\begin{document}
কণ্যা এখন কি করিবে?
\end{document}


With a current fontspec the mode and the script can be selected like this.

\documentclass{article}
\usepackage{fontspec}

\setmainfont{notosansbengali-regular.ttf}[Renderer=Harfbuzz,Script=Bengali]
\begin{document}
কণ্যা এখন কি করিবে?
\end{document}


======================================

## First step

As you are on windows, get binaries from http://w32tex.org/. If you follow the link ctan you will find a link to harftex-w32.tar.xz.

Unpack it and copy harftex.dll, perhaps icudt64.dll, harflatex.exe and harftex.exe to your texlive/<year>/bin/win32 folder.

Create in texmf-local/web2c a fmtutil.cnf with this content

harflatex harftex language.dat,language.dat.lua lualatex.ini
harftex harftex language.def,language.dat.lua luatex.ini


Then create a texmf.cnf in the same directory with this content

TEXINPUTS.harftex   = $TEXMFDOTDIR;$TEXMF/tex/{harftex,luatex,plain,generic,}//
TEXINPUTS.harflatex = $TEXMFDOTDIR;$TEXMF/tex/{harflatex,lualatex,latex,luatex,generic,}//

LUAINPUTS.harflatex = $TEXMFDOTDIR;$TEXMF/scripts/{$progname,$engine,}/{lua,}//;\$TEXMF/tex/{harflatex,lualatex,latex,luatex,generic,}//


Then run in command line

mktexlsr
fmtutil-sys --byengine=harftex


You can then try if harflatex works by running a small document with

harflatex test-document


You will see no real difference to using lualatex here. To make use of the additional feature of harflatex more files are needed, but this is then the second step.

## Second step

get from https://github.com/khaledhosny/harf/tree/master/src all luafiles and the harfload.sty file. Put them e.g. in texmf-local/tex/latex/harf. Run mktexlsr.

Then test e.g. with this document (I used the noto-font as I don't have yours). The important part is (beside loading the harfload-package) the mode=harf in the font definitions. Fonts with this settings will use harfbuzz in the background. Don't use it for fonts that should use the "normal" lualatex fontloader.

\documentclass{article}
\usepackage{fontspec}

\setmainfont{notosansbengali-regular.ttf}[RawFeature={mode=harf}]
\begin{document}
কণ্যা এখন কি করিবে? \

\end{document}


### output with lualatex for comparision:

harftex for (currently) x86_64-linux, i386-linux, and win32 is now in contrib.texlive.info. One can install it with

  tlmgr --repository https://contrib.texlive.info/current install harftex