[XeTeX] expandable version of \char

Bruno Le Floch blflatex at gmail.com
Tue May 27 19:46:00 CEST 2014


Hello all,

On 5/4/14, David Carlisle <d.p.carlisle at gmail.com> wrote:
> Would it be possible (ever:-) to add a \Uchar primitive like that in
> luatex?
>
> So like \char but is expandable and returns a character token rather than a
> typesetting primitive.

I think it should not be too hard to use the procedures scan_int and
print_char to build the primitive \Uchar.  My main question will be:
where do I find the XeTeX codebase?  I seem to have found it at some
point, so I have an old version on my computer, but it would be better
if I make a diff starting from the right files.

Here is how it could be done.  First declare a new command code for
\Uchar by defining XeTeX_Uchar_code and shifting etex_convert_codes by
1:

    @d XeTeX_glyph_name_code=10
    @d XeTeX_Uchar_code = 11
    @d etex_convert_codes=XeTeX_Uchar_code+1 {end of \eTeX's command codes}

Then declare the primitive via

    primitive("Uchar",convert,XeTeX_Uchar_code);@/
    @!@:XeTeX_Uchar_}{\.{\\Uchar} primitive@>

Then add the second line in

    XeTeX_glyph_name_code: print_esc("XeTeXglyphname");
    XeTeX_Uchar_code: print_esc("Uchar");

In @ @<Cases of `Scan the argument for command |c|'@>= add

    XeTeX_Uchar_code: scan_int;

In @ @<Cases of `Print the result of command |c|'@>= add

    XeTeX_Uchar_code: print_char(cur_val);

Am I missing anything?  Ah, I don't know if this works for >BMP
characters, as it seems XeTeX's print_char treats them specially.

Regards,
Bruno



More information about the XeTeX mailing list