# [XeTeX] Numerals in Right-to-Left

Jonathan Kew jonathan_kew at sil.org
Mon Nov 15 15:07:16 CET 2004

On 14 Nov 2004, at 7:14 am, Otared Kavian wrote:

> Dear Jonathan Kew, Dear List members,
>
> Sometimes ago I discovered XeTeX on Mac OS X (through a message posted
> by Adam Lindsay for ConTeXt users: thanks, Adam). You have done a
> wonderful work and letting the whole community using it, is really
> both a great achievement and a great decision! Thank you.

You're welcome; glad to know people find it interesting.

> 1) I would like to use (Plain) XeTeX to write in Persian (indeed the
> same problem appears with Arabic). In Persian the digits 0--9 are
> different than the so-called "arabic numerals" (some call them indic
> or persian numerals, but I am not sure about the correct
> denomination). Now, in XeTeX when the file contains these numerals, in
> the typeset they don't appear. In a message of Jonathan K. answering a
> to solve the problem.
> Can anyone tell us more?

The appropriate numerals for Arabic are the Unicode characters
0660..0669, and for Persian, 06F0..06F9. The Apple Arabic keyboard
generates the Arabic digits, and the Persian keyboard generates the
Persian ones. Both sets should work in Geeza Pro, for example; it's
possible that some other Arabic fonts may not support the Persian
characters.

Depending on the particular font, you may find that the default Latin
digits (Unicode 0030..0039) are *not* supported and will appear blank.
Some applications may automatically display these codes as Arabic or
Persian forms when used in an Arabic-script context, so it's possible
to be misled as to what characters are actually in your text.

A short test for the three sets of digits could be:
%%% arabdigits.tex
\TeXXeTstate=1
\font\x="Geeza Pro" at 24pt \x
\everypar={\setbox0=\lastbox \beginR \box0 }

العربي ١٢٣٤٥٦ العربي

فرسى ۱۲۳۴۵۶ فرسى

فرسى 123456 فرسى

\end
%%% end

With Geeza Pro, the first two sets of digits are fine; the third set
appear blank. Other fonts may vary.

Note that "auto-generated" numbers from TeX macros (like \pageno, for
example) will be the Latin digits 0030..0039, and this may be a problem
when working with non-Latin fonts. It's possible to wrap such things in
additional macro code to replace the Latin digits with the appropriate
codes for a different script, but this requires extra TeX macro
programming.

Jonathan