[Tex/LaTex] XeTeX and Luatex fail to display correctly biblical hebrew fonts

fontshebrewluatexxetex

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 %%%%%%%%%%%%%%%%%
\input luaotfload.sty

\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.)

Best Answer

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
  \input luaotfload.sty
  \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

output sample

Related Question