[XeTeX] Mysterious nonzero lastskip

David M. Jones dmj at ams.org
Wed Dec 2 04:07:58 CET 2009


> From: Jonathan Kew <jfkthame at googlemail.com>
> Date: Wed, 2 Dec 2009 00:28:10 +0000
> Reply-To: Unicode-based TeX for Mac OS X and other platforms <xetex at tug.org>
> 
> This seems wrong to me. Simplifying a bit by eliminating packages, and  
> using only ASCII characters:
> 
>    \documentclass{minimal}
>    \usepackage[EU1]{fontenc}
> 
>    \let\star*
>    \catcode`\*=\active
>    \def*{\ifdim\lastskip>0pt\message{!!!}\showthe\lastskip\fi\star}
> 
>    \begin{document}
>    This is a test*
>    \end{document}
> 
> still shows the same peculiar behavior; removing [EU1] eliminates it.
> 
> Inserting \relax before \ifdim, as Ross suggested, fixes the problem;  
> but I don't yet understand why it's happening.

This seems to be a bad interaction between OpenType fonts and
\lastskip.  With the EU1 option, xetex is using Latin Modern; without
it, Computer Modern.

Try this:

First, recompile xetex with the modified <Fetch an item in the current
node...> found at the end of this message.

Second, run this modified file through the recompiled xetex:

    \documentclass{minimal}
    \usepackage[EU1]{fontenc}
    
    \showboxdepth=10000
    \showboxbreadth=10000
    
    \let\star*
    \catcode`\*=\active
    \def*{%
        \ifdim\lastskip>0pt
            \message{^^J!!! non-zero lastskip???^^J}%
        \else
            \message{^^J!!! normal lastskip^^J}%
        \fi
        \star
    }
    
    \begin{document}
    This is a\quad test*
    \end{document}
    
and note the following output:

    \hbox(0.0+0.0)x20.0
    \EU1/lmr/m/n/10 This
    \glue 3.33 plus 1.665 minus 1.11
    \EU1/lmr/m/n/10 is
    \glue 3.33 plus 1.665 minus 1.11
    \EU1/lmr/m/n/10 a
    \glue 10.0
    FETCH: found a glue_node
    10.0
    
    !!! non-zero lastskip???

\lastskip is reporting the amount of glue *before* the word test
because the node representing "test" apparently hasn't been added to
the list yet.

If you take out the the fontenc line, you get

    \hbox(0.0+0.0)x20.0
    \OT1/cmr/m/n/10 T
    \OT1/cmr/m/n/10 h
    \OT1/cmr/m/n/10 i
    \OT1/cmr/m/n/10 s
    \glue 3.33333 plus 1.66666 minus 1.11111
    \OT1/cmr/m/n/10 i
    \OT1/cmr/m/n/10 s
    \glue 3.33333 plus 1.66666 minus 1.11111
    \OT1/cmr/m/n/10 a
    \glue 10.00002
    \OT1/cmr/m/n/10 t
    \OT1/cmr/m/n/10 e
    \OT1/cmr/m/n/10 s
    \OT1/cmr/m/n/10 t
    
    !!! normal lastskip

I don't even begin to understand how OpenType fonts are integrated
into XeTeX, so that's as far as I can go.

Cheers,
David.

############################## END EXTRACT ##############################

@<Fetch an item in the current node...@>=
    if m >= input_line_no_code then
        if m >= eTeX_glue then
            @<Process an expression and |return|@>@;
        else if m >= eTeX_dim then
        begin 
            case m of
                @/@<Cases for fetching a dimension value@>@/
            end; {there are no other cases}
            cur_val_level:=dimen_val;
        end
    else
    begin
        case m of
            input_line_no_code: cur_val:=line;
            badness_code: cur_val:=last_badness;
            @/@<Cases for fetching an integer value@>@/
        end; {there are no other cases}

        cur_val_level:=int_val;
    end
    else
    begin
show_box(head);
        if cur_chr = glue_val then
            cur_val := zero_glue
        else
            cur_val := 0;

        if cur_chr = last_node_type_code then
        begin
            cur_val_level := int_val;
            if (tail = head) or (mode = 0) then
                cur_val : =-1;
        end
        else
            cur_val_level := cur_chr;

        if not is_char_node(tail) and (mode<>0) then
        begin
            if (type(tail) = math_node) and (subtype(tail) = end_M_code) then
                remove_end_M;

            case cur_chr of
                int_val: if type(tail)=penalty_node then cur_val:=penalty(tail);

                dimen_val: if type(tail)=kern_node then cur_val:=width(tail);

                glue_val: if type(tail) = glue_node then
                begin
print_nl("FETCH: found a glue_node");
print_ln;

                    cur_val := glue_ptr(tail);
print_spec(cur_val, 0);
print_ln;
                    if subtype(tail) = mu_glue then
                        cur_val_level := mu_val;
                end;

                last_node_type_code:
                    if (type(tail) <> math_node) or (subtype(tail) <> end_M_code) then
                        if type(tail) <= unset_node then
                            cur_val := type(tail) + 1
                        else
                            cur_val := unset_node + 2;
            end; {there are no other cases}

            if LR_temp <> null then insert_end_M;
        end
        else if (mode = vmode) and (tail = head) then
            case cur_chr of
                int_val:   cur_val := last_penalty;
                dimen_val: cur_val := last_kern;
                glue_val:
                    if last_glue <> max_halfword then
                        cur_val := last_glue;

                last_node_type_code: cur_val := last_node_type;
            end; {there are no other cases}
    end

############################## END EXTRACT ##############################


More information about the XeTeX mailing list