Passing unicode characters
Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
Dear Mehdi,
سلام
On Tue, 22 Jul 2008 08:48:46 -0600, Mehdi Omidali
Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
I'm not quite sure I understand you, but there is a mechanism so that you can write your own feature file with your own gsubs and gposs and then pass those along to luatex. This was broken in earlier versions of luatex; seems to be working now -- just checked. See below. Best wishes Idris ===============verbose.fea================== lookup NumericLookupDFLT { lookupflag 0 ; sub zero by z e r o ; sub one by o n e ; sub two by t w o ; sub three by t h r e e ; sub four by f o u r ; sub five by f i v e ; sub six by s i x ; sub seven by s e v e n ; sub eight by e i g h t ; sub nine by n i n e ; } NumericLookupDFLT ; feature verb { script DFLT ; language dflt ; lookup NumericLookupDFLT ; script latn; language dflt ; lookup NumericLookupDFLT ; language AZE exclude_dflt ; lookup NumericLookupDFLT ; language CRT exclude_dflt ; lookup NumericLookupDFLT ; language MOL exclude_dflt ; lookup NumericLookupDFLT ; language ROM exclude_dflt ; lookup NumericLookupDFLT ; language TRK exclude_dflt ; lookup NumericLookupDFLT ; } verb ; ============================================ =================verb.tex=================== % engine=luatex % \setupoutput[pdftex] \starttext \installfontfeature[otf][verb] \definefontfeature [test][mode=node,language=dflt,script=latn,verb=yes,featurefile=verbose.fea] \font\test=lmroman10-regular*test at 20pt \test 1 2 3 4 \stoptext ============================================ -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shi`i Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
ِDear Idris,
سلام
Thank you. I will test that and let you know if it is what I realy
want. And again another problem that I encountered in conversion to
persiannumerals or arabicnumerals. I used an style you offered in one
of your posts and modified it for persian typesetting. I declared
\setuppagenumbering[conversion=persiannumerals]
and unfortunately the page numbering started from zero. The same thing
happens in footnote numbers even thouth I haven't use any conversion
for footnotes. All chapters, sections, and ... numbers starts from
zero. How can I solve this problem. Please see the attached files.
Best regards,
On 7/22/08, Idris Samawi Hamid ادريس سماوي حامد
Dear Mehdi, سلام
On Tue, 22 Jul 2008 08:48:46 -0600, Mehdi Omidali
wrote: Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
I'm not quite sure I understand you, but there is a mechanism so that you can write your own feature file with your own gsubs and gposs and then pass those along to luatex.
This was broken in earlier versions of luatex; seems to be working now -- just checked. See below.
Best wishes Idris
===============verbose.fea================== lookup NumericLookupDFLT { lookupflag 0 ; sub zero by z e r o ; sub one by o n e ; sub two by t w o ; sub three by t h r e e ; sub four by f o u r ; sub five by f i v e ; sub six by s i x ; sub seven by s e v e n ; sub eight by e i g h t ; sub nine by n i n e ; } NumericLookupDFLT ;
feature verb {
script DFLT ; language dflt ; lookup NumericLookupDFLT ;
script latn; language dflt ; lookup NumericLookupDFLT ; language AZE exclude_dflt ; lookup NumericLookupDFLT ; language CRT exclude_dflt ; lookup NumericLookupDFLT ; language MOL exclude_dflt ; lookup NumericLookupDFLT ; language ROM exclude_dflt ; lookup NumericLookupDFLT ; language TRK exclude_dflt ; lookup NumericLookupDFLT ;
} verb ; ============================================
=================verb.tex=================== % engine=luatex
% \setupoutput[pdftex]
\starttext
\installfontfeature[otf][verb]
\definefontfeature [test][mode=node,language=dflt,script=latn,verb=yes,featurefile=verbose.fea]
\font\test=lmroman10-regular*test at 20pt
\test 1 2 3 4
\stoptext ============================================ -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shi`i Studies Department of Philosophy Colorado State University Fort Collins, CO 80523 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Dear Idris,
سلام
I tested your file. What I mean is more than that. In your file if I
write 1 then it is printed as one. But I mean something like
conversion command. For example look at the output of your file. The
page number is 1. But what I mean is that engine prints every 1 as one
for example. Let me explain in a different way. I declare
\setupsection [chapter][conversion=persiannumerals]
and the engine puts persiandecimalseparator character "E8C8" between
chapter numbers and section numbers. I am not satisfied with this
character and like the separator character to be a period "002E". In
XeTeX one of the font features is to assign the value of "E8C8" to
"002E". Then the engine automatically prints "002E" whenever it has to
print "E8C8" (except in math mode for which there is a \XeTeXmathcode
command).
Best wishes
On 7/22/08, Idris Samawi Hamid ادريس سماوي حامد
Dear Mehdi, سلام
On Tue, 22 Jul 2008 08:48:46 -0600, Mehdi Omidali
wrote: Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
I'm not quite sure I understand you, but there is a mechanism so that you can write your own feature file with your own gsubs and gposs and then pass those along to luatex.
This was broken in earlier versions of luatex; seems to be working now -- just checked. See below.
Best wishes Idris
===============verbose.fea================== lookup NumericLookupDFLT { lookupflag 0 ; sub zero by z e r o ; sub one by o n e ; sub two by t w o ; sub three by t h r e e ; sub four by f o u r ; sub five by f i v e ; sub six by s i x ; sub seven by s e v e n ; sub eight by e i g h t ; sub nine by n i n e ; } NumericLookupDFLT ;
feature verb {
script DFLT ; language dflt ; lookup NumericLookupDFLT ;
script latn; language dflt ; lookup NumericLookupDFLT ; language AZE exclude_dflt ; lookup NumericLookupDFLT ; language CRT exclude_dflt ; lookup NumericLookupDFLT ; language MOL exclude_dflt ; lookup NumericLookupDFLT ; language ROM exclude_dflt ; lookup NumericLookupDFLT ; language TRK exclude_dflt ; lookup NumericLookupDFLT ;
} verb ; ============================================
=================verb.tex=================== % engine=luatex
% \setupoutput[pdftex]
\starttext
\installfontfeature[otf][verb]
\definefontfeature [test][mode=node,language=dflt,script=latn,verb=yes,featurefile=verbose.fea]
\font\test=lmroman10-regular*test at 20pt
\test 1 2 3 4
\stoptext ============================================ -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shi`i Studies Department of Philosophy Colorado State University Fort Collins, CO 80523 ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Tue, 22 Jul 2008 12:14:30 -0600, Mehdi Omidali
Dear Idris, سلام I tested your file. What I mean is more than that. In your file if I write 1 then it is printed as one. But I mean something like conversion command. For example look at the output of your file. The page number is 1. But what I mean is that engine prints every 1 as one for example. Let me explain in a different way. I declare \setupsection [chapter][conversion=persiannumerals] and the engine puts persiandecimalseparator character "E8C8" between chapter numbers and section numbers. I am not satisfied with this character and like the separator character to be a period "002E". In XeTeX one of the font features is to assign the value of "E8C8" to "002E". Then the engine automatically prints "002E" whenever it has to print "E8C8" (except in math mode for which there is a \XeTeXmathcode command).
سلام Mehdi, Well, the easy way is to make E8C8 active then \define E8C8 to be the character 002E. It sounds like XeTeX has a dedicated mechanism. But since I don't use XeTeX maybe Mojca or one of the other XeTeX experts can look at this. You may not even need active char's: There should be a way to control the separator char in \setupsection. I'm at work right now but maybe I can look at this later. Can you send a sample file? Best wishes Idris -- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shi`i Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
Dear Idris,
سلام
you are right. I found that \setupheads[separator=something] works,
but I found a mysterious bug. Whatever one declares as a separator,
when you make a reference to the chapter, section, etc, lua writes the
number with periods.compile the attached file and look at the
reference.
Best regards,
ps: I sent a test file, but it needs a moderator confirmation. I will
send it to your email.
%%%%%%%%%%%%%%%%%%%%%%
% engine=luatex
\setupheads[separator=--]
\starttext
\font\test=lmroman10-regular*test at 20pt
\chapter{First}
\section[one]{one}
No matter what you have declared as section separator, here I am \in[one].
\stoptext
%%%%%%%%%%%%%%%%%%%%%%
On 7/22/08, Idris Samawi Hamid
On Tue, 22 Jul 2008 12:14:30 -0600, Mehdi Omidali
wrote: Dear Idris, سلام I tested your file. What I mean is more than that. In your file if I write 1 then it is printed as one. But I mean something like conversion command. For example look at the output of your file. The page number is 1. But what I mean is that engine prints every 1 as one for example. Let me explain in a different way. I declare \setupsection [chapter][conversion=persiannumerals] and the engine puts persiandecimalseparator character "E8C8" between chapter numbers and section numbers. I am not satisfied with this character and like the separator character to be a period "002E". In XeTeX one of the font features is to assign the value of "E8C8" to "002E". Then the engine automatically prints "002E" whenever it has to print "E8C8" (except in math mode for which there is a \XeTeXmathcode command).
سلام Mehdi,
Well, the easy way is to make E8C8 active then \define E8C8 to be the character 002E. It sounds like XeTeX has a dedicated mechanism. But since I don't use XeTeX maybe Mojca or one of the other XeTeX experts can look at this.
You may not even need active char's: There should be a way to control the separator char in \setupsection. I'm at work right now but maybe I can look at this later.
Can you send a sample file?
Best wishes Idris
-- Professor Idris Samawi Hamid, Editor-in-Chief International Journal of Shi`i Studies Department of Philosophy Colorado State University Fort Collins, CO 80523
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Tue, 22 Jul 2008, Mehdi Omidali wrote:
Dear Idris, سلام you are right. I found that \setupheads[separator=something] works, but I found a mysterious bug. Whatever one declares as a separator, when you make a reference to the chapter, section, etc, lua writes the number with periods.compile the attached file and look at the reference.
Unfortunately, this is an old bug. Hans is planning to revamp the handling of sections and references in mkiv. So, hopefully this will be corrected soon. If you really need this functionality now, there are ugly workarounds. I can post them when I get back to home computer. Aditya
Hi,
Please look at the attached file. Why numbering starts from zero?
%%%%%%%%%%%%%
%-----------------------------lang-far.tex------------------------------------
\writestatus{loading}{Farsi Languages}
\unprotect
\setupheadtext [content=فهرست مطالب]
\setupheadtext [tables=ليست جداول]
\setupheadtext [figures=ليست تصاوير]
\setupheadtext [graphics=ليست اشکال]
\setupheadtext [index=نمايه]
\setupheadtext [abbreviations=اختصارات]
\setupheadtext [units=واحدها]
\setuplabeltext [table=جدول ]
\setuplabeltext [figure=شكل ]
\setuplabeltext [graphic=طرح ]
%D We don't set these here. One can do that in a style.
\setuplabeltext [chapter=فصل ] % Chapter
\setuplabeltext [section=بخش ]
\setuplabeltext [subsection=زيربخش ]
\setuplabeltext [subsubsection=زيرزيربخش ]
\setuplabeltext [subsubsubsection=زيرزيرزيربخش ]
\setuplabeltext [appendix=پيوست ] % Appendix
\setuplabeltext [part=قسمت ]
\setuplabeltext [line=خط ]
\setuplabeltext [lines=خطهاي ]
\setuplabeltext [january=ژانويه]
\setuplabeltext [february=فوريه]
\setuplabeltext [march=مارس]
\setuplabeltext [april=آوريل]
\setuplabeltext [may=مي]
\setuplabeltext [june=ژوئن]
\setuplabeltext [july=ژوييه]
\setuplabeltext [august=آگوست]
\setuplabeltext [september=سپتامبر]
\setuplabeltext [october=اکتبر]
\setuplabeltext [november=نوامبر]
\setuplabeltext [december=دسامبر]
\setuplabeltext [sunday=يکشنبه]
\setuplabeltext [monday=دوشنبه]
\setuplabeltext [tuesday=سهشنبه]
\setuplabeltext [wednesday=چهارشنبه]
\setuplabeltext [thursday=پنجشنبه]
\setuplabeltext [friday=جمعه]
\setuplabeltext [saturday=شنبه]
%D Rather new ...
\setuplabeltext [page=صفحه]
\setuplabeltext [atpage=در صفحهٔ ]
%\setuplabeltext [hencefore=كما وضحنا سابقا]
%\setuplabeltext [hereafter=كما نوضح لاحقا]
\setuplabeltext [see=نگاه کنيد به]
%D ... and to be completed!
\protect
\endinput
%-----------------------------end----------------------------
%-------------------------far-env.tex-----------------------------------
%This file is designed by Mehdi Omidali for easy typesetting farsi in Context
%File Versin:2008-7-20
\startenvironment far-env
\usemodule[lang-far]
\mainlanguage[arabic]
% Font setup
\definefontfeature
[arabic]
[mode=node,language=dflt,script=arab,
init=yes,medi=yes,fina=yes,isol=yes,
liga=yes,dlig=yes,rlig=yes,clig=yes,
mark=yes,mkmk=yes,kern=yes,curs=yes,futerfile=verbose.fea]
\starttypescript [serif] [arabic]
\definefontsynonym [Farsi-Light] [name:ScheherazadeRegOT.ttf]
[features=arabic]
\definefontsynonym [Farsi-Bold] [name:ScheherazadeRegOT.ttf]
[features=arabic]
\definefontsynonym [Farsi-Italic] [name:ScheherazadeRegOT.ttf]
[features=arabic]
\definefontsynonym [Farsi-Bold-Italic] [name:ScheherazadeRegOT.ttf]
[features=arabic]
\stoptypescript
\starttypescript [serif] [arabic] [name]
\usetypescript[serif][fallback]
\definefontsynonym [Serif] [Farsi-Light] [features=arabic]
\definefontsynonym [SerifItalic] [Farsi-Italic] [features=arabic]
\definefontsynonym [SerifBold] [Farsi-Bold] [features=arabic]
\definefontsynonym [SerifBoldItalic] [Farsi-Bold-Italic] [features=arabic]
\stoptypescript
\starttypescript [Farsi]
\definetypeface [Farsi] [rm] [serif] [arabic] [default]
\stoptypescript
\def\FarsiGlobalDir {\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
\def\FarsiParDir {\textdir TRT\pardir TRT}
\def\FarsiTextDir {\textdir TRT}
\def\LatinParDir {\textdir TLT\pardir TLT}
\def\LatinTextDir {\textdir TLT}
\def\LatinGlobalDir {\pagedir TLT\bodydir TLT\pardir TLT\textdir TLT}
\define\setfarsi
{\FarsiGlobalDir%
\usetypescript[Farsi]%
\setupbodyfont[Farsi,18pt]}
\definestartstop
[farsipar]
[commands=\Farsi\FarsiParDir]
\define[1]\RT
{{\Farsi\FarsiTextDir#1}}
\define\setlatin
{\LatinGlobalDir%
\usetypescript[lm]%
\setupbodyfont[lm,18pt]}
\definestartstop
[latinpar]
[commands=\Farsi\LatinParDir]
\define[1]\LT
{{\LatinTextDir#1}}
\setuphead
[chapter]
[ page=yes,
before=\hairline\blank,
after=\nowhitespace\hairline,
header=nomarking,
textstyle=bold,
numberstyle=bold,
]
\setupheads[separator=\LT{--}]
\setuppagenumbering[conversion=persiannumerals]
\setupheadertexts[]%We put here because we want to define headertexts next.
%\setupheadertexts[][pagenumber]
\setupsection [chapter]
[conversion=persiannumerals]
\setupsection [section]
[conversion=persiannumerals]
\setupsection [subsection]
[conversion=persiannumerals]
\setupsection [subsubsection]
[conversion=persiannumerals]
\setupfootnotes
[conversion=persiannumerals]
\stopenvironment
---------------------------------------------end--------------------
% engine=luatex
\setupinteraction
[state=start,
title={راهنمای نگارش فارسی با کانتکست},
author={مهدی امیدعلی},
subtitle={حروفچینی بهوسیلهٔ لواتک},
keyword={فارسی لواتک كانتكست}]
\starttext
\environment far-env
\setfarsi
\startfrontmatter
\startstandardmakeup
\midaligned{راهنمای فارسی کانتکست}
\midaligned{نويسنده}
\midaligned{مهدی امیدعلی}
\stopstandardmakeup
\completecontent
\stopfrontmatter
\startbodymatter
\chapter{پیشگفتار}
\section[firstsection]{کانتکست چیست؟}\index{کانتکست}
این یک پانوشت است
\footnote{\LT{Numbers starts from zero}}
\subsection{روش نصب}
\in{ بخش}[firstsection]
\footnote{\LT{The reference number is not correct}}
\stopbodymatter
\completeindex
\stoptext
------------------------------------end--------------------------------
On 7/22/08, Aditya Mahajan
On Tue, 22 Jul 2008, Mehdi Omidali wrote:
Dear Idris, سلام you are right. I found that \setupheads[separator=something] works, but I found a mysterious bug. Whatever one declares as a separator, when you make a reference to the chapter, section, etc, lua writes the number with periods.compile the attached file and look at the reference.
Unfortunately, this is an old bug. Hans is planning to revamp the handling of sections and references in mkiv. So, hopefully this will be corrected soon.
If you really need this functionality now, there are ugly workarounds. I can post them when I get back to home computer.
Aditya
On Wed, Jul 23, 2008 at 08:37:12AM +0200, Wolfgang Schuster wrote:
2008/7/22 Mehdi Omidali
: Hi, Please look at the attached file. Why numbering starts from zero?
Your ConTeXt could be too old or you run texexec only once, try to run texexec at least twice and the numbering should be correct.
I think this is a bug in converters.alphabetic function, it doesn't handle zero and seem to convert 1->0 2->1 etc. The following code: \ctxlua{converters.alphabetic(0,"arabic")} \ctxlua{converters.alphabetic(123456789,"arabic")} gives "0 ٠١٢٣٤٥٦٧٨", while it should give "٠١٢٣٤٥٦٧٨٩". Regards, Khaled
Wolfgang ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- Khaled Hosny Arabic localizer and member of Arabeyes.org team
Hi everyone,
Another thing that have to be fixed is about formula numbering in
right-to-left texts. By default I think lua prints a formula number in
a formula in the wrong direction, like
\thechapter.\thesection.\theequation
but it should be
\theequation.\thesection.\thechapter
because chapter and section numbering is expanded from right to left.
Also be aware of equation numbers when one call it from a reference
like \in[formulalabel].
It should also be
\theequation.\thesection.\thechapter
As far as I know, equation nembering is a big problem in all tex
engines (for right-to-left texts).
Fortunately, the way that lua act with other numbered bodies, like
tables, figures, ... (in right-to-left texts) is perfect as far as I
have checked.
Best wishes.
On 7/28/08, Khaled Hosny
On Wed, Jul 23, 2008 at 08:37:12AM +0200, Wolfgang Schuster wrote:
2008/7/22 Mehdi Omidali
: Hi, Please look at the attached file. Why numbering starts from zero?
Your ConTeXt could be too old or you run texexec only once, try to run texexec at least twice and the numbering should be correct.
I think this is a bug in converters.alphabetic function, it doesn't handle zero and seem to convert 1->0 2->1 etc. The following code:
\ctxlua{converters.alphabetic(0,"arabic")} \ctxlua{converters.alphabetic(123456789,"arabic")}
gives "0 ٠١٢٣٤٥٦٧٨", while it should give "٠١٢٣٤٥٦٧٨٩".
Regards, Khaled
Wolfgang
Mehdi Omidali wrote:
Hi everyone, Another thing that have to be fixed is about formula numbering in right-to-left texts. By default I think lua prints a formula number in a formula in the wrong direction, like \thechapter.\thesection.\theequation but it should be \theequation.\thesection.\thechapter because chapter and section numbering is expanded from right to left. Also be aware of equation numbers when one call it from a reference like \in[formulalabel]. It should also be \theequation.\thesection.\thechapter As far as I know, equation nembering is a big problem in all tex engines (for right-to-left texts). Fortunately, the way that lua act with other numbered bodies, like tables, figures, ... (in right-to-left texts) is perfect as far as I have checked.
we struggled with this in the past (interfacing) ... ab.cd.ef = ab.cd.ef (explicit textdir rules) ab.cd.ef = ef.cd.ab ab.cd.ef = fe.dc.ba (textdir on components) eventually i think that we settled to something that worked with the examples at that time 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 -----------------------------------------------------------------
On Tue, Jul 22, 2008 at 4:48 PM, Mehdi Omidali wrote:
Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
There definitely is a way, but I don't know why you would want to do remap numbers on font level. You need such hacks in LaTeX where changing page numbers is a pain, but I would do that with conversions in ConTeXt. "arabic" (starting with U+0660) is already defined. If you need U+06F0, you might need to do minor modification in core-con.*, but try with normal arabic first. \setuppagenumbering [conversion=arabicnumerals] Here are the needed modifications: core-con.lua: ['arabic'] = { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 }, you need to add the same for extendedarabic ['extendedarabic'] = { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 }, core-con.mkiv: \def\arabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"arabic")}} \def\extendedarabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"extendedarabic")}} \defineconversion [arabicnumerals] [\arabicnumerals] \defineconversion [extendedarabicnumerals] [\extendedarabicnumerals] (You also need to modify core-con.mkii if you want the same feature to be available in XeTeX afterwards.) And then you should be able to use \setuppagenumbering [conversion=extendedarabicnumerals] You can also set up itemize to use arabic numbers. What exactly would you like to do with those numbers? Then you can probably get a more precise answer. Mojca
Dear Mojca,
Thanks for your complete answer. In fact, in persian (and maybe
arabic) documents, we need every digit be in persian, like chapter,
section, figure, and even formula numbers (most of the people even
prefer persian digits in formulas which is possible in xetex).
As you know, the Mapping=farsidigits in a font definition works
perfect in xelatex.
Best wishes.
On 7/22/08, Mojca Miklavec
On Tue, Jul 22, 2008 at 4:48 PM, Mehdi Omidali wrote:
Hi everyone, Is it possible to pass a character to another in MKIV, I mean, like XeTeX in which one can pass one unicode character to another one (this is done in some mapping files with some lines in it of the form U+0030 <> U+06F0 )
There definitely is a way, but I don't know why you would want to do remap numbers on font level. You need such hacks in LaTeX where changing page numbers is a pain, but I would do that with conversions in ConTeXt.
"arabic" (starting with U+0660) is already defined. If you need U+06F0, you might need to do minor modification in core-con.*, but try with normal arabic first.
\setuppagenumbering [conversion=arabicnumerals]
Here are the needed modifications:
core-con.lua: ['arabic'] = { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 },
you need to add the same for extendedarabic ['extendedarabic'] = { 0x0660, 0x0661, 0x0662, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669 },
core-con.mkiv: \def\arabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"arabic")}} \def\extendedarabicnumerals #1{\ctxlua{converters.alphabetic(\number#1,"extendedarabic")}}
\defineconversion [arabicnumerals] [\arabicnumerals] \defineconversion [extendedarabicnumerals] [\extendedarabicnumerals]
(You also need to modify core-con.mkii if you want the same feature to be available in XeTeX afterwards.)
And then you should be able to use
\setuppagenumbering [conversion=extendedarabicnumerals]
You can also set up itemize to use arabic numbers. What exactly would you like to do with those numbers? Then you can probably get a more precise answer.
Mojca ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
On Tue, Jul 22, 2008 at 9:39 PM, Mehdi Omidali wrote:
Dear Mojca, Thanks for your complete answer. In fact, in persian (and maybe arabic) documents, we need every digit be in persian,
But when you write, you probably write numbers in persian already?
like chapter, section,
\chapter and \section are a bit buggy as far as numbering is concerned, but you can use \setuphead [section] [conversion=arabicnumerals]
figure, and even formula numbers
Try \defineconversion [ar] [numbers] [\arabicnumerals] This one doesn't work on sections (same argument as Aditya pointed out), but it does quite a lot already :) Can you try it out and report? I didn't try it out (no idea how to work with Arabic), but I consider it a much cleaner approach than redefining characters in fonts. (You could also use \setupformulas[conversion=arabicnumerals], similar for tables, ..., but in theory you should not need anything else but \defineconversion [ar] [numbers] [\arabicnumerals] in lang-ara.tex if that's of general interest.)
(most of the people even prefer persian digits in formulas which is possible in xetex). As you know, the Mapping=farsidigits in a font definition works perfect in xelatex.
I would say that ConTeXt lacks a nice interface for that at the moment. There is tlig/trep feature that works that way (remaps ' to rightquote for example), but it's spread all over the place and might be likely to change. One option are fea files (like the one Idris pointed you to). Still, I would go for "conversion", not for redefining fonts. Redefining fonts is just an ugly hack that happens to solve a problem temporary. People use it just because it's too difficult to do it in some other way. Mojca
Dear Mojca,
Thanks to the conversion option I found a clean way to setup a good
left-to-right layout. But I found a mysterious bug in the
bidirectional algorithm. Please run the attached file and look at the
formula.
%%%%%%%%%%%%%%%%%%
% engine=luatex
\def\FarsiGlobalDir {\pagedir TRT\bodydir TRT\pardir TRT\textdir TRT}
\definestartstop
[farsidocument]
[commands={\FarsiGlobalDir},before=\page,after=\page]
\starttext
\startfarsidocument
\placeformula[formula1] $$y=123456789x^2$$
hi\footnote{hi}
\page
\stopfarsidocument
Why the formula in the previous page is not shown correct.
\stoptext
On 7/23/08, Mojca Miklavec
On Tue, Jul 22, 2008 at 9:39 PM, Mehdi Omidali wrote:
Dear Mojca, Thanks for your complete answer. In fact, in persian (and maybe arabic) documents, we need every digit be in persian,
But when you write, you probably write numbers in persian already?
like chapter, section,
\chapter and \section are a bit buggy as far as numbering is concerned, but you can use \setuphead [section] [conversion=arabicnumerals]
figure, and even formula numbers
Try \defineconversion [ar] [numbers] [\arabicnumerals]
This one doesn't work on sections (same argument as Aditya pointed out), but it does quite a lot already :) Can you try it out and report? I didn't try it out (no idea how to work with Arabic), but I consider it a much cleaner approach than redefining characters in fonts.
(You could also use \setupformulas[conversion=arabicnumerals], similar for tables, ..., but in theory you should not need anything else but \defineconversion [ar] [numbers] [\arabicnumerals] in lang-ara.tex if that's of general interest.)
(most of the people even prefer persian digits in formulas which is possible in xetex). As you know, the Mapping=farsidigits in a font definition works perfect in xelatex.
I would say that ConTeXt lacks a nice interface for that at the moment. There is tlig/trep feature that works that way (remaps ' to rightquote for example), but it's spread all over the place and might be likely to change. One option are fea files (like the one Idris pointed you to).
Still, I would go for "conversion", not for redefining fonts. Redefining fonts is just an ugly hack that happens to solve a problem temporary. People use it just because it's too difficult to do it in some other way.
Mojca ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
Mehdi Omidali wrote:
Dear Mojca, Thanks to the conversion option I found a clean way to setup a good left-to-right layout. But I found a mysterious bug in the bidirectional algorithm. Please run the attached file and look at the formula.
This definately looks like a bug in luatex itself. In fact, both dvi and pdf modes seem to generate incorrect results, even in plain.fmt. I've added a bug tracker item for luatex. Best wishes, Taco
Mojca Miklavec wrote:
On Tue, Jul 22, 2008 at 9:39 PM, Mehdi Omidali wrote:
Dear Mojca, Thanks for your complete answer. In fact, in persian (and maybe arabic) documents, we need every digit be in persian,
But when you write, you probably write numbers in persian already?
like chapter, section,
\chapter and \section are a bit buggy as far as numbering is concerned, but you can use \setuphead [section] [conversion=arabicnumerals]
the section numbering has to take too many things into account (there are sveral places where one can hook in conversion commands); complications are for instance in supporting chinese (left/right stuff) and separators; one problem is that the number needs to be expanded when it is written to lists; separator handlign (esp replacement) then can become rather hairy too concerning left/right handling ... there has been added some trickery when idris needed it and was still using otp's but since otp's were error prone, this can easily interfere with other things anyhow, in mkiv there will be a more flexible mechanism with more data being carried around so that in various stages one can tweak things like conversions, separators, prefixes is much more detail (which then of course will lead to more demands) Hans (btw, you really don't want to know what numbering we have to use in our projects; it hardly fits a model) ----------------------------------------------------------------- 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 -----------------------------------------------------------------
participants (9)
-
Aditya Mahajan
-
Hans Hagen
-
Idris Samawi Hamid
-
Idris Samawi Hamid ادريس سماوي ح امد
-
Khaled Hosny
-
Mehdi Omidali
-
Mojca Miklavec
-
Taco Hoekwater
-
Wolfgang Schuster