[XeTeX] Allocation mechanism for \XeTeXintercharclass

enrico.gregorio at univr.it enrico.gregorio at univr.it
Thu May 28 10:14:19 CEST 2009


It seems that more and more people are using \XeTeXintercharclass and related
primitives; this of course arises the problem that different macros might use the
same class (polyglossia is one package and Kazuomi Kuniyoshi sent something
to this list using the same features).

It's probably time to set up an allocation mechanism for these integer parameters;
just a small modification of the Plain TeX's one would suffice.

=== This might go in xelatex.ini (?) ===
\newcount\xe at alloc@intercharclass % allocates intercharclass
\xe at alloc@intercharclass=\thr@@ % from 4 (1,2 and 3 are used by CJK, AFAIK)
\def\xe at alloc@#1#2#3#4#5{\global\advance#1\@ne
  \xe at ch@ck#1#4#2% make sure there's still room
  \allocationnumber#1%
  \global#3#5\allocationnumber
  \wlog{\string#5=\string#2\the\allocationnumber}}
\def\xe at ch@ck#1#2#3{%
  \ifnum#1<#2\else
   \errmessage{No room for a new #3}%
  \fi}
\def\newXeTeXintercharclass{%
  \xe at alloc@\xe at alloc@intercharclass\XeTeXintercharclass\chardef\@cclv} %at most 254
===

The limitation on new classes comes from page 10 in Will Robertson's "XeTeX reference":
0 is the normal class, from 1 to 3 are reserved for CJK, and 255 is special (is it really?).
There's plenty of room: it's difficult to imagine a document using as many as 250
different intercharclasses. One might reserve some of the classes for temporary uses,
starting the allocation from 11 instead of 4.

The new allocation might be used as follows (proposed to François Charette):

===
\newXeTeXintercharclass\french at punctthin % ! ? ;
\newXeTeXintercharclass\french at punctthick % :
\newXeTeXintercharclass\french at punctguill % « »

\def\french at punctthinspace{\unskip\thinspace}
\def\french at punctthickspace{\unskip\nobreakspace}

\def\french at punctuation{%
    \frenchspacing
    \XeTeXinterchartokenstate=1
    \XeTeXcharclass `\! \french at punctthin
    \XeTeXcharclass `\? \french at punctthin
    \XeTeXcharclass `\; \french at punctthin
    \XeTeXcharclass `\: \french at punctthick
    \XeTeXinterchartoks \z@ \french at punctthin = \french at punctthinspace
    \XeTeXinterchartoks \z@ \french at punctthick = \french at punctthickspace
    }
===

Probably this needs also some wrapper in LaTeX style, something like

\DeclareInterCharClass{\french at punctthin}
\DeclareCharClass{`\!}{\french at punctthin}
\DeclareInterCharToks{0}{\french at punctthin}{\french at punctthinspace}

In general:

\DeclareInterCharClass{<intercharclass>}
\DeclareCharClass{<charcode>}{<intercharclass>}
\DeclareInterCharToks{<left intercharclass>}{<right intercharclass>}{<code>}

Of course these commands should not be in the \@onlypreamble list, since they
typically are used in language or font switching macros.

In my opinion this should be done as soon as possible, in order that package
writers can use it from the start of XeLaTeX packages development.

Ciao
Enrico

--
Enrico Gregorio          + Dipartimento di Informatica          + Tel: +39 045 8027937
Enrico.Gregorio at univr.it + Università degli Studi di Verona     +
(gregorio at math.unipd.it) + Strada le Grazie 15 / I-37134 Verona + Fax: +39 045 8027928




More information about the XeTeX mailing list