15

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.

Ulrike Fischer
  • 327,261

2 Answers2

19

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}

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

Old version (Installation of harftex)

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{harfload}
\usepackage{fontspec}

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

\end{document}

output with harflatex

enter image description here

output with lualatex for comparision:

enter image description here

Ulrike Fischer
  • 327,261
  • 1
    I'm experiencing similar problems, but with Arabic. See https://github.com/khaledhosny/harf/issues/35. I haven't had time to investigate further. – Javier Bezos May 29 '19 at 15:57
  • @Ulrike Fischer, after updating TexLive, first I've deleted all those files I copied earlier, then did what I had done earlier BUT it's not working! –  May 29 '19 at 16:14
  • Try if it work if you do \font\test={file:notosansbengali-regular.ttf:mode=harf;}\test just before your banga. – Ulrike Fischer May 29 '19 at 16:44
  • @Ulrike Fischer, tried with and without commenting \setmainfont... part, doesn't work! –  May 29 '19 at 17:02
  • 1
    @Ulrike Fischer, how is it working on your machine? are you on Linux or Mac? –  May 29 '19 at 17:04
  • I'm following the thread and making tests, too. With Vrinda, Shonar and Nirmala it fails too. – Javier Bezos May 29 '19 at 17:05
  • 2
    I think it is a change in the binary. On the other pc I still had harftex 0.1.1 but now with 0.1.2 it fails. Some should please make a bug report at https://github.com/khaledhosny/harftex/issues with a link to the discussion here. I'm busy now. – Ulrike Fischer May 29 '19 at 17:09
  • @Ulrike Fischer, JavierBezos and I at least have got an answer for now. I never had used git, I didn't even know how to clone, lol! You taught me! –  May 29 '19 at 17:17
  • @JavierBezos, Arabic works nicely for me in lualatex with arabluatex package, I've linked my previous question, where I'd used those, in this post. –  May 29 '19 at 17:20
  • 1
    I'll report it. – Javier Bezos May 29 '19 at 17:23
  • Hi @UlrikeFischer thanks for the guide. I think I will include binaries and support files into tlcontrib (https://contrib.texlive.info/) so that it easy to install. – norbert May 30 '19 at 02:20
  • @norbert I don't know about binaries for other OS. – Ulrike Fischer May 30 '19 at 07:07
  • @JavierBezos Thanks. Looks as if Khaled already found the source of the problem, and patches have been sent to texlive, so one only has to wait until Akira rebuilds the w32tex.org binaries (which normally is done fast). – Ulrike Fischer May 30 '19 at 10:05
  • @UlrikeFischer it works the same across all supported architectures. I have already put x86_64-linux binary and package into tlcontrib, and will add Windows and Mac binaries, as well as i386-linux binaries later on. The installation with tlmgr already takes care of the format generation, so everything should be ready to go. – norbert May 30 '19 at 12:54
  • @norbert well that's nice. When the windows binaries are there I will try and adapt/extend the installation advice above. Did you rebuild the binaries with the patches Akira added today? – Ulrike Fischer May 30 '19 at 12:58
  • Just to confirm - I've downloaded the binaries from w32tex and now it works. – Javier Bezos May 30 '19 at 13:14
  • @JavierBezos, ok I'll give it a try after setting up my desktop pc. –  May 30 '19 at 13:18
  • @JavierBezos where is the new version? I just checked and still see a date of 25 may. – Ulrike Fischer May 30 '19 at 13:19
  • @UlrikeFischer, let us know whether your instructions above are valid for the latest update of harftex –  May 30 '19 at 13:22
  • @JavierBezos I now got the newest binary from the ctan.ijs.si server and after rebuilding the formats the example behaves again. – Ulrike Fischer May 30 '19 at 13:33
  • @UlrikeFischer, probably JavierBezos have tried it only with Arabic! –  May 30 '19 at 13:53
  • no idea, but I tried with notosansbengali and this works again with the binary from today. – Ulrike Fischer May 30 '19 at 14:00
  • @UlrikeFischer, could you please give me the link of the latest binaries? My desktop is almost ready! –  May 30 '19 at 14:04
  • 1
    As I wrote I got if from the ctan.ijs.si server: http://ctan.ijs.si/mirror/w32tex/current/ – Ulrike Fischer May 30 '19 at 14:07
  • 1
    @EmonHaque I wonder if you are seeing a cached page. It works for me with Vrinda, Shonar and Nirmala (still experimenting with Arabic, but I think the issues I'm finding are not related to the binary). – Javier Bezos May 30 '19 at 14:27
  • @JavierBezos, super, It works! Thanks for taking this issue to the developers. –  May 30 '19 at 14:49
  • @UlrikeFischer, it works with Kalpurush font, thanks for your time! –  May 30 '19 at 14:49
  • @UlrikeFischer, update the answer, I'd to copy everything from the harftex bin to texlive's bin/win32! –  May 30 '19 at 14:52
  • @JavierBezos, no, it doesn't show cached file. I've checked it with the laptop now. –  May 30 '19 at 16:17
  • @UlrikeFischer I just pushed out binaries for win32 (taken today from w32tex) and x86_64-linux (build 2 days ago) to tlcontrib. I will rebuild the Linux version on older system, for i386, after the weekend. Have the changes of AKira found its way into the harftex git repo already? Thanks for any comments and testing – norbert May 31 '19 at 11:52
  • @norbert As the changes from Akira orginated from patches suggested by Khaled they are probably also in the harftex git. I will do some testing but probably only next week. – Ulrike Fischer May 31 '19 at 12:02
  • 1
    @norbert, Yes, all relevant changes are in HarfTeX repo. – خالد حسني May 31 '19 at 13:06
  • 1
    @EmonHaque No idea, but looks like something new (the fontspec and fontenc warnings) and I don’t have them with LuaTeX. Please ask a new question. – خالد حسني May 31 '19 at 15:07
  • 1
    @EmonHaque sorry for the trouble, I was debugging this and found the cause. See the last edit in the answer above. Turns out there are two fines named fonttext.cfg in the texmf tree (one from LaTeX kernel and one from CSLaTeX), without the proper kpse search path set HarfTeX finds the forms which misses the TU encoding definition. – خالد حسني May 31 '19 at 15:40
  • @KhaledHosny, excellent! no warnings! –  May 31 '19 at 15:50
  • @khaled-hosny thanks, I'll rebuild on Monday, currently mountaineering – norbert Jun 01 '19 at 03:46
  • @KhaledHosny I tried to implement and use your package with Hebrew, but in my output the vowel positioning is wrong despite the absence of error messages. Should your package display Hebrew correctly? [I.e. Should I ask a question?] – Kazi bácsi Nov 03 '19 at 12:53
  • @Kazibácsi the answer is basically outdated. As engine you should now use luahbtex, and the lua code was moved into luaotfload (but isn't on ctan yet, you would have to get a development version from the repository). – Ulrike Fischer Nov 03 '19 at 14:11
  • @UlrikeFischer How should now this work with Hebrew? I refreshed now everything, and luaotfload seems to work on MikTeX, but I still get bad vowel positioning (despite no error messages). – Kazi bácsi Dec 04 '19 at 19:59
  • @Kazibácsi are you using lualatex-dev? – Ulrike Fischer Dec 04 '19 at 20:04
  • @UlrikeFischer Somehow I understood that lualatex-dev refers only to TeXLive users. Despite all my respect for this huge development effort, I suppose average users are not informed well. Here I should have only replaced lualatex.exe with the lualatex-dev.exe, yet I can't find anywhere a proper documentation, where it is written down in a comprehensible way. – Kazi bácsi Dec 07 '19 at 20:04
  • @Kazibácsi lualatex-dev can be used in miktex too. https://tex.stackexchange.com/questions/506646/what-is-latex-dev – Ulrike Fischer Dec 07 '19 at 20:09
  • @UlrikeFischer See my edit. – Kazi bácsi Dec 07 '19 at 20:18
12

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

If I get access to other binaries I will add them later on.

norbert
  • 8,235