[XeTeX] Numerals in Right-to-Left

Hans Hagen pragma at wxs.nl
Wed Nov 17 17:38:37 CET 2004


Otared Kavian wrote:
> At 9:32 -0500 17/11/04, Jonathan Kew wrote:
> 
>> I suppose people might like an example of how this could be done. 
>> Here's a possible approach:
>>
>> % - - - - - convert numbers to different digit sets - - - - -
>> \font\x="Geeza Pro" at 12pt \x
>>
>> \def\translitnumber#1#2{%
>>   % #1 -> the number to transliterate
>>   % #2 -> unicode value of "zero" in the desired digit set
>>   \begingroup
>>   \count255=#2
>>   \uccode`\0=\count255 \advance\count255 by 1
>>   \uccode`\1=\count255 \advance\count255 by 1
>>   \uccode`\2=\count255 \advance\count255 by 1
>>   \uccode`\3=\count255 \advance\count255 by 1
>>   \uccode`\4=\count255 \advance\count255 by 1
>>   \uccode`\5=\count255 \advance\count255 by 1
>>   \uccode`\6=\count255 \advance\count255 by 1
>>   \uccode`\7=\count255 \advance\count255 by 1
>>   \uccode`\8=\count255 \advance\count255 by 1
>>   \uccode`\9=\count255
>>   \edef\thenumber{#1}%
>>   \expandafter\uppercase\expandafter{\thenumber}%
>>   \endgroup}
>>
>> \def\arabicnumber#1{\translitnumber{#1}{"0660}}
>> \def\persiannumber#1{\translitnumber{#1}{"06F0}}
> 
> 
> Thanks a lot Jonathan! This is exactly what I wanted to know, but was 
> afraid to ask...
> I am writing a few macros for Plain XeTeX in order o use your suggestion 
> in other situations (footnotes, section numbers and so on) for Persian 
> (and Arabic). When they are clean I'll let know the community.
> 
> I imagine that there is more or less the same procedure in order to have 
> Persian or Arabic numbers in math mode (the above command does not 
> produce what is wanted).

actually this kind of features should be built in, kind of:

\xetexdigitbase=<number>

\def\arabicnumber  {\xetexdigitbase"0660\relax}
\def\persiannumber {\xetexdigitbase"06F0\relax}

otherwise one has to tag all his/her numbers; that way one can easily implement 
math vs text vs table numbers just by calling one macro

Hans



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the XeTeX mailing list