Using Hebrew TrueType fonts with pdfTeX

This guide is base on a guide published by Dekel Tsur that can be found here. Dekel Tsur’s guide was very good but now it is outdated since it doesn’t work with teTex 3.0. In this guide I addressed this issue and updated the instructions and scripts so it will work with teTex 3.0.Since the quality of the Hebrew metafonts that comes with the Hebrew LaTeX is quite poor, alternative fonts are needed. The best quality free Hebrew fonts are TrueType fonts (for example, the times new/arial/courier new fonts). Using TrueType fonts with TeX is somewhat complicated, but it is quite easy with pdfTeX, as pdfTeX has native support for TrueType fonts. This document explains how to use TrueType fonts with pdfTeX. Since Hebrew requires the use of the eTeX engine, you need to have the pdfelatex program. It is available in teTeX 1.0 (which comes with recent Linux distributions). The instruction below allows using nikud, although the result is quite poor as the nikud glyphs are not aligned correctly (but it is better than nothing).

Hebrew TrueType fonts can be downloaded from here.

In the following, TEXMF is the place of the (local) TeX tree (usually /usr/share/texmf), and TMP is some temporary directory you need to create. Steps 1-3 can be done as a regular user, while the other steps need to be done as root.

  1. Create the directory TMP, and chdir into it. Copy (or link) your TrueType fonts to TMP. Download the tar.gz file ttf.tar.gz and extract it into TMP.
  2. Run the python script `ttf.py’:
    python ttf.py *.ttf

    If you are unable to run this script, you can manually perform the following steps for each font (you also need to create an empty file called `hebrew.map’). Steps (d) and (e) are optional. These steps are needed for nikud. Step (e) is also needed for ligatures. The instruction are written for the times.ttf font (for other font, you might need to replace winheb2.enc by another encoding file).

    1. Create a tfm file by
      ttf2tfm times.ttf -N -T winheb2.enc -v tmp.vpl htimes.tfm
    2. Get the font name by running
      ttf2afm times.ttf | grep FontName

      For the times font, the result is `TimesNewRomanPSMT’

    3. Add the following line to the file `hebrew.map’:
      htimes TimesNewRomanPSMT <winheb2.enc <times.ttf
    4. Edit the file `tmp.vpl’. Change the width of each nikud character to 0. For example, change
      (CHARACTER O 300(comment sheva)
      (CHARWD R 333)
      (CHARDP R 215) )

      to

      (CHARACTER O 300(comment sheva)
      (CHARWD R 0)
      (CHARDP R 215) )
    5. Run
    vptovf tmp.vpl tmp.vfm htimes.tfm
  3. If you don’t have the times/arial/courier fonts (or you don’t want to use them as default fonts), you need to edit the file `ttfheb.sty’
  4. Run `su’ to get root access.
  5. Move the file ttfheb.sty to the directory of the Hebrew latex files (it should be `TEXMF/tex/generic/babel/hebrew/’. If it is not, you can find this directory with `locate rlbabel.def‘.)
  6. Run
    sh install TEXMF

    If you are unable to use this script, perform the following steps manually:

    1. Create a directory called `TEXMF/fonts/truetype/hebrew/‘,
      and move the .ttf files to this directory.
    2. Create a directory called `TEXMF/fonts/tfm/truetype/hebrew/‘,
      and move the .tfm files into this directory.
    3. Move the .enc files and `hebrew.map’ to `TEXMF/fonts/map/pdftex/
    4. while in the TEXMF/fonts/map/pdftex/ directory run:
      updmap-sys –enable Map hebrew.map


    5. Run
      mktexlsr TEXMF
  7. The final test: as a regular user run
    pdftex test.tex
    pdfelatex test2.tex

To make a LaTeX document use the TrueType fonts, add the line `\usepackage{ttfheb}’ to the preamble (see `test2.tex’).

UPDATES:

18/03/2007: added the new ttfheb.sty file by Artyom Tonkikh and fixed some typos.

9 thoughts on “Using Hebrew TrueType fonts with pdfTeX”

  1. Noam Raphael brought to my attention that I should specify the actual font names the script is looking for (I assumed they are installed with corefonts package or copied from a windows partition). So script excepts to find the following font files:

    arialbd.ttf arialbi.ttf ariali.ttf arial.ttf
    timesbd.ttf timesbi.ttf timesi.ttf times.ttf
    courbd.ttf courbi.ttf couri.ttf cour.ttf

  2. First of all, thanks for the tutorial.

    One thing that I couldn’t figure out: the python script, and the manual algorithm you’ve suggested as well, run a command named “ttf2tfm”.

    I have ubuntu 7.04, and running that command (with root privileges) on terminal outputs “ttf2tfm: command not found”, and the python script outputs:
    – Running ttf2tfm arialbd.ttf -O -N -T winheb2.enc -v tmp.vpl harialbd.tfm
    – sh: ttf2tfm: not found
    which kills the script, because right after that I get:
    – IOError: [Errno 2] No such file or directory: ‘tmp.vpl’

    I have seen the same command in other tutorials (including the one you based this article on), so I guess it is something crucial.

    Any ideas what can cause that?

    Thanks ahead,
    Peleg.

  3. I have found this command – I needed to install freetype1-tools package in ubuntu for that…

    So: this wasn’t a problem after all, and everything went well following your instructions. The only problem is that I still have fuzzy fonts using pdflatex via lyx (only in Hebrew).

    If you have any advice, I would be glad to hear.

    Thanks,
    Peleg.

  4. Hi Peleg,
    I’m glad you solved out the problem with the ttf2tfm and came back to write about it. About the fonts, make sure you got

    \usepackage{ttfheb}

    In you latex preamble (this enables the true-type fonts package). If you still want a better result get culmus-latex package from the Ivritex site. It’s a font package I help maintain that uses the Culmus fonts, which I find to have higher quality than the default true-type fonts.

    Regards,
    Guy

  5. shalom ubracha
    perhaps you can help me on a related matter

    I have an old Hebrew font called chatsi kulmus which sefardim used to write a hundred years ago

    I got some handwriting and scanned each and every letter of the alef bet into my computer and then pasted them onto a yourfonts.com template which I uploaded to them

    They then sent me my ttf font. However, its set up as an English font so when I type it types backwards

    Do you know how to amend the TTF font so that the computer thinks itā€™s a right-to-left font and it would therefore allow me to type properly using eg davka

    Thanks in advance ā€“ I really appreciate your help

    Kol tuv

    Regards

    Ariel Belilo

  6. Dear Guy,,

    Are the instructions above for TTF still valid today (October 2010)? I wish to improve the typography of my Hebrew latex. I am using
    >> This is pdfTeX, Version 3.1415926-1.40.10
    >> (TeX Live 2009/openSUSE) (format=pdflatex 2010.10.8)

    Thanks, Amnon

  7. Thanks for another excellent article. The place else may anybody get that type of information in such a perfect method of writing? I’ve a presentation next week, and I am at the search for such information.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.