# XeTeX and Luatex fail to display correctly biblical hebrew fonts

My question is related to both XeTeX and LuaTeX; both fail to display correctly biblical hebrew fonts.

More precisely, the text is truncated at some point, and the nikud (meaning something like accents in hebrew) is incorrectly positioned, as well as the diacritic other signs.

Other free editors like OpenOffice or Notepad++ display correctly these signs.

I installed the Shlomo font in my computer. Thence I compiled a biblical segment with XeTeX and Luatex, and both engines incorrectly positioned the ''nikud'' and the diacritic signs around the letters. Even more importantly, they both damaged the biblical segment. I tried with other hebrew fonts and this gave the same result. Here is the piece of code and the processed result (note: hebrew is written from right to left):

%%%%%%%%%%%%%%% XETEX %%%%%%%%%%%%%%%%%%%
% XETEX Version 3.1415926-2.3-0.9997.5 (MiKTeX 2.9)
\TeXXeTstate = 1

\font\Shlomofnt="Shlomo" at 14pt

\Shlomofnt

\beginR
א וַיִּשְׁלַ֣ח יְהוֹשֻֽׁעַ־בִּן־נ֠וּן מִֽן־הַשִּׁטִּ֞ים שְׁנַֽיִם־אֲנָשִׁ֤ים מְרַגְּלִים֙ חֶ֣רֶשׁ לֵאמֹ֔ר לְכ֛וּ רְא֥וּ אֶת־הָאָ֖רֶץ וְאֶת־יְרִיח֑וֹ וַיֵּ֨לְכ֜וּ וַ֠יָּבֹאוּ בֵּית־אִשָּׁ֥ה זוֹנָ֛ה וּשְׁמָ֥הּ רָחָ֖ב וַיִּשְׁכְּבוּ־שָֽׁמָּה׃
ב וַיֵּ֣אָמַ֔ר לְמֶ֥לֶךְ יְרִיח֖וֹ לֵאמֹ֑ר הִנֵּ֣ה אֲ֠נָשִׁים בָּ֣אוּ הֵ֧נָּה הַלַּ֛יְלָה מִבְּנֵ֥י יִשְׂרָאֵ֖ל לַחְפֹּ֥ר אֶת־הָאָֽרֶץ׃
ג וַיִּשְׁלַח֙ מֶ֣לֶךְ יְרִיח֔וֹ אֶל־רָחָ֖ב לֵאמֹ֑ר ה֠וֹצִיאִי הָֽאֲנָשִׁ֨ים הַבָּאִ֤ים אֵלַ֨יִךְ֙ אֲשֶׁר־בָּ֣אוּ לְבֵיתֵ֔ךְ כִּ֛י לַחְפֹּ֥ר אֶת־כָּל־הָאָ֖רֶץ בָּֽאוּ׃

\end
% Note : the fragment appears here written from right to left because my
% notepad++ editor automatically inverts the direction of writing when it sees
% hebrew characters, but in fact, it is written in logical order.


Here is the result after XeTeX processing; nikud and diacritics are incorrectly positioned, and at some point, the text becomes unreadable:

Here is how the biblical segment looks in OpenOffice (The ''nikud'' is correctly positioned, as well as the diacritic signs) :

Similarly, in Notepad++, the segment looks quite well:

Now, I used the following piece of code and compiled it with Luatex (Version beta- 0.70.1-2011080216 (rev 4277) ) :

%%%%%%%%%%%% LUATEX %%%%%%%%%%%%%%%%%

\font\Shlomofnt={file:C:/Windows/Fonts/Shlomo.ttf} at 14pt
\Shlomofnt

{\pardir TRT \noindent {\textdir TRT
א וַיִּשְׁלַ֣ח יְהוֹשֻֽׁעַ־בִּן־נ֠וּן מִֽן־הַשִּׁים שְׁנַֽיִם־אֲנָשִׁ֤ים מְרַגְּלִים֙ חֶ֣רֶשׁ לֵאמֹ֔ר לְכ֛וּ רְא֥וּ אֶת־הָאָ֖רֶץ וְאֶת־יְרִיח֑וֹ וַיֵּ֨לְכ֜וּ וַ֠יָּבֹאוּ בֵּית־אִשָּׁ֥ה זוֹנָ֛ה וּשְׁמָ֥הּ רָחָ֖ב וַיִּשְׁכְּבוּ־שָֽׁמָּה׃ ב וַיֵּ֣אָמַ֔ר לְמֶ֥לֶךְ יְרִיח֖וֹ לֵאמֹ֑ר הִנֵּ֣ה אֲ֠נָשִׁים בָּ֣אוּ הֵ֧נָּה הַלַּ֛יְלָה מִבְּנֵ֥י יִשְׂרָאֵ֖ל לַחְפֹּ֥ר אֶת־הָאָֽרֶץ׃ ג וַיִּשְׁלַח֙ מֶ֣לֶךְ יְרִיח֔וֹ אֶל־רָחָ֖ב לֵאמֹ֑ר ה֠וֹצִיאִי הָֽאֲנָשִׁ֨ים הַבָּאִ֤ים אֵלַ֨יִךְ֙ אֲשֶׁר־בָּ֣אוּ לְבֵיתֵ֔ךְ כִּ֛י לַחְפֹּ֥ר אֶת־כָּל־הָאָ֖רֶץ בָּֽאוּ׃
}}

\end


And the result is again truncated and incorrect:

(This question can also be found on Google Docs as a pdf.)

• i think it's a bit rude to put your examples somewhere we have to sign-in to. how do we know you're not collecting ids for some nefarious purpose. – wasteofspace Dec 2 '12 at 20:37
• Welcome to TeX.sx! Examples are always very welcome, but are much better as part of the question than an external link. As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Joseph Wright Dec 2 '12 at 20:52
• Just copy what you have in that PDF here, even if people went to that link they wouldn’t be able to reproduce your issue since copying Hebrew from PDF gives garbage. You are making it hard for people who want to help you. – Khaled Hosny Dec 2 '12 at 23:54
• @MikeTeX I imported your question with code, pictures, and everything. Please make sure everything has been ported here, I have no knowledge of Hebrew whatsoever. Also let us know if you have any other questions about using this site. Joseph already commented on the picture issue. I hope you'll have a good time here on tex.sx and your problems will be solved! – doncherry Dec 3 '12 at 1:03
• On an unrelated note: It'd be great if you considered changing your user name to something that cannot be misread as indicating an affiliation of yours with some official *TeX entity (like MiKTeX) -- even though I appreciate the pun on your real name. Similarly, we once asked a user named "Moderator" to change their name, and I think we also had similar cases with names like "Google" or "LaTeX". – doncherry Dec 3 '12 at 1:04

I get neither the boxes with XeTeX 0.9998 nor the truncated lines with LuaTeX 0.70.2. For the nikud placement issue, you have to tell the engine which OpenType script to use (they don’t select it automatically; it has to be explicitly set). With this test file I get the same output with both engines:

% allow the test file to work with both engines to easily compare the result
\input ifluatex.sty
\ifluatex
\def\setRTL{\pardir TRT\textdir TRT}
\def\endLTR{\pardir TLT\textdir TLT}
\else
\input bidi
\fi

\font\Shlomofnt="Shlomo:script=hebr" at 14pt
\Shlomofnt

\setRTL
\noindent
א וַיִּשְׁלַ֣ח יְהוֹשֻׁעַ־בִּן־נ֠וּן מִֽן־הַשּׁטִּים שְׁנַֽיִם־אֲנָשִׁים מְרַגְּלִים֙ חֶ֣רֶשׁ לֵאמֹ֔ר לְכ֛וּ רְא֥וּ אֶת־הָאָ֖רֶץ וְאֶת־יְרִיח֑וֹ וַיֵּלְכ֜וּ וַ֠יָּבֹאוּ בֵּית־אִשּׁה זוֹנָ֛ה וּשְׁמָ֥הּ רָחָ֖ב וַיִּשְׁכְּבוּ־שָׁמָּה׃
ב וַיֵּאָמַ֔ר לְמֶ֥לֶךְ יְרִיח֖וֹ לֵאמֹ֑ר הִנֵּה אֲ֠נָשִׁים בָּאוּ הֵ֧נָּה הַלַּיְלָה מִבְּנֵ֥י יִשְׂרָאֵ֖ל לַחְפֹּר אֶת־הָאָֽרֶץ׃
ג וַיִּשְׁלַח֙ מֶ֣לֶךְ יְרִיח֔וֹ אֶל־רָחָ֖ב לֵאמֹ֑ר ה֠וֹצִיאִי הָֽאֲנָשִׁים הַבָּאִ֤ים אֵלַ֨יִךְ֙ אֲשֶׁר־בָּאוּ לְבֵיתֵ֔ךְ כִּי לַחְפֹּר אֶת־כָּל־הָאָ֖רֶץ בָּאוּ׃
\bye


• thank you (ooops this is forbiden - please someone, vote for him in my place, I don't know how). According to the images you post, you have indeed successed in compiling nicely the fragment, both with XeTeX and XeLatex and probably with Luatex. I would like to know if you have exactly used the command that are reported above, at the only exception of the font command that you modified.I've try to introduce your improvement but at a first glance, this haven't change anything with XeTeX. When I come from work, I will try to update my versions of XeTeX and Luatex and to try again. – MikeTeX Dec 3 '12 at 17:27
• after updating, the problem was solved for XeTeX: thanks to your indications, the nikud was correctly positioned. Nevertheless, my Luatex continue to fail to compile the fragment incorrectly. Can you post the code you used to compile with Luatex? thx. – MikeTeX Dec 3 '12 at 20:09
• @MikeTeX: I updated my answer. – Khaled Hosny Dec 3 '12 at 21:58

Can you use xelatex? I guess it works fine:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Shlomo}
\usepackage{polyglossia}
\setmainlanguage{hebrew}

\begin{document}
א וַיִּשְׁלַ֣ח יְהוֹשֻֽׁעַ־בִּן־נ֠וּן מִֽן־הַשִּׁטִּ֞ים שְׁנַֽיִם־אֲנָשִׁ֤ים מְרַגְּלִים֙ חֶ֣רֶשׁ לֵאמֹ֔ר לְכ֛וּ רְא֥וּ אֶת־הָאָ֖רֶץ וְאֶת־יְרִיח֑וֹ וַיֵּ֨לְכ֜וּ וַ֠יָּבֹאוּ בֵּית־אִשָּׁ֥ה זוֹנָ֛ה וּשְׁמָ֥הּ רָחָ֖ב וַיִּשְׁכְּבוּ־שָֽׁמָּה׃
ב וַיֵּ֣אָמַ֔ר לְמֶ֥לֶךְ יְרִיח֖וֹ לֵאמֹ֑ר הִנֵּ֣ה אֲ֠נָשִׁים בָּ֣אוּ הֵ֧נָּה הַלַּ֛יְלָה מִבְּנֵ֥י יִשְׂרָאֵ֖ל לַחְפֹּ֥ר אֶת־הָאָֽרֶץ׃
ג וַיִּשְׁלַח֙ מֶ֣לֶךְ יְרִיח֔וֹ אֶל־רָחָ֖ב לֵאמֹ֑ר ה֠וֹצִיאִי הָֽאֲנָשִׁ֨ים הַבָּאִ֤ים אֵלַ֨יִךְ֙ אֲשֶׁר־בָּ֣אוּ לְבֵיתֵ֔ךְ כִּ֛י לַחְפֹּ֥ר אֶת־כָּל־הָאָ֖רֶץ בָּֽאוּ׃
\end{document}

• My second question is : have you used exactly the code reported above for Luatex and compiled it successfully, as it seems you mean ? or have you used another commands ? – MikeTeX Dec 3 '12 at 17:22
• Regarding XeLateX, I confess I am not a Latex user. I have my own plain TeX based format (I call it HebTeX) I've used for years. Unfortunately for me, the TeX world become more and more a Latex world, without paying attention to the fact that some people hate Latex or simply prefer other formats. – MikeTeX Dec 3 '12 at 17:28