OpenType support for Hebrew fonts

This page presents some FontForge scripts which I find useful in creating OpenType fonts. An example can be found at the end of the page.

Scripts

Glyph substitution

Hebrew typefaces may include several features for glyph substitution. These features can be created semi-automatically using the provided script AddHebrewGSUB.py. The features include

Diacritics positioning

The method I use for diacritics is somewhat idiosyncratic, but I find it convenient. I use FontForge metrics view (Window->New Metrics Window) to define a diacritical mark position in the form of a kerning pair between the basic glyph (consonant) and the mark (vowel). This view provides an immediate visual feedback, which greatly simplifies the task of the fine tuning. Then I run script Kern2Comments.py which converts the kerning pair to a special form of comment stored in the appropriate basic glyph. Another script AddHebrewGPOS.pe converts these comments into final OpenType information.

The most interesting script in this process is AddHebrewGPOS.py, as it creates the actual OpenType anchors which set the positioning of nikkud. The positioning values for the script are stored in a special format inside glyph comments. For example, the glyph lamed may contain the following comment:

%DiaToBase1=200
%DiaToBase2=220
%DiaToBaseU=220
%DiaToBaseO=-70

This comment can be translated as follows:

The anchor DiaToBase1 for narrow diacritics (hiriq, shwa) shall be located at (200,0)
The anchor DiaToBase2 for medium-width diacritics (tsere, patah, qamats, segol) shall be located at (220,0)
The anchor DiaToBaseU for qubutz shall be located at (220, 0)
The anchor DiaToBaseO for holam haser shall be located at (-70,0)

First the script creates five anchor classes named DiaToBase[123UO]. In this list 1 stands for narrow marks, 2 stands for medium-width marks, 3 stands for hataf marks, U stands for qubutz, and O stands for holam haser. Then it traverses all vowels and sets on each vowel an anchor of the appropriate class. The vowel anchors are always set at (0,0).

Furthermore, the script automatically traverses all consonants and parses their respective comments to create anchors as appropriate. The anchors set on consonants correspond to the anchors set on vowels, to produce OpenType marks positioning. Generally, each consonant bears an anchor for each class, thus having up to 5 anchors. In practice, some anchors may be absent, e.g. only glottal consonants have anchor DiaToBase3 defined.

The script supports the notion of glyph equivalence, e.g. comments stored for lamed are applied on lamed dagesh too, since these two glyphs should have similar diacritics positioning.

An auxiliary script InitHebrewGlyphData.py defines static arrays of vowels and consonants for use in AddHebrewGPOS.py. It maintains consonant equivalence tables, describing glyphs which should be considered equivalent for the purpose of diacritics positioning. It also maintains vowel tables which describe anchor classes and marks corresponding to these classes.

Another two auxiliary scripts DumpComments.pe and LoadComments.pe dump glyph comments to external file comments_dump.txt, and load them accordingly.

Example [outdated]

The package below contains a sample source SFD file and the resulting OpenType font.

In order to get the OpenType font from the source file, the following should be done:

  1. Download the scripts AddHebrewGSUB.py, AddHebrewGPOS.py and InitHebrewGlyphData.py.

  2. Open the file David-Medium.sfd in the FontForge.

  3. Run the script AddHebrewGSUB.py by choosing “File->Execute script...”, “Call...” and selecting the script from the download location.

  4. Perform manual instructions listed in the script.

  5. Run the script AddHebrewGPOS.py.

  6. Export the font as OpenType by choosing “File->Generate Fonts...”, type “OpenType (CFF)”, “Save”.

The resulting file David-Medium.otf can be installed using your desktop's standard font installation procedure. Compare the results with the provided font to make sure everything went fine.