[XeTeX] Colored Arabic in Tables

Ross Moore ross at ics.mq.edu.au
Wed Mar 11 22:02:30 CET 2009

Hi Francois, and others,

On 12/03/2009, at 6:49 AM, François Charette wrote:

> I'm still puzzled about the reason for this, but again, this has  
> nothing
> to do with setting colors!
> The same behaviour occurs with the following minimal document, in  
> which

Yes. Roughly speaking, it is because the  \addfontfeature
was made *inside* the {tabularx}.
Perhaps a local counter is reset as that grouping is departed,
leading to the next attempt to add a feature getting the same
internal name as the previous one.

Result: a font with the new settings is never actually created,
since TeX sees only a request for the same one as previously.

This would appear to be the same problem identified last month,
in the thread:

    Re: [XeTeX] Problem with font features in tables


> I only use the relevant portions of the code in arabxetex.sty:
> \documentclass{minimal}
> \usepackage{fontspec}
> \newfontfamily{\arabicfont}[Script=Arabic,Scale=1.7]{Scheherazade}
> \usepackage{tabularx}
> \begin{document}
> \begin{tabularx}{\linewidth}{X}
>     {\arabicfont\addfontfeature{Mapping=arabtex-fdf2alif-fullvoc}  
> ha}\\
> \end{tabularx}
> {\arabicfont\addfontfeature{Mapping=arabtex-fdf2alif-novoc} h}
> \end{document}

Here's how to see what is happening.
Modify the above code slightly, to get extra console messages:

>> \usepackage{tabularx}
>> \begin{document}
>> %\begin{tabularx}{\linewidth}{X}
>>     {\arabicfont\addfontfeature{Mapping=arabtex-fdf2alif-fullvoc} ha
>>     \showthe\font}\\
>> %\end{tabularx}
>> {\arabicfont\addfontfeature{Mapping=arabtex-fdf2alif-novoc} h
>>  \showthe\font}
>> \end{document}

With no use of {tabularx} the log messages are:

>> > \EU1/Scheherazade(1)/m/n/10 .
>> <recently read> \font
>> l.11     \showthe\font
>>                       }
>> ?
>> Underfull \hbox (badness 10000) in paragraph at lines 10--14
>> > \EU1/Scheherazade(2)/m/n/10 .
>> <recently read> \font
>> l.17  \showthe\font
>> ?

The font-instance counter has moved from 0 to 1 to 2.

Next remove the comments to use the {tabularx} environment.
The messages become:

>> > \EU1/Scheherazade(1)/m/n/10 .
>> <recently read> \font
>> l.11 \end{tabularx}
>> ?
>> > \EU1/Scheherazade(1)/m/n/10 .
>> <recently read> \font
>> l.11 \end{tabularx}
>> ?
>> Overfull \hbox (20.0pt too wide) in paragraph at lines 11--12
>> [][]
>> > \EU1/Scheherazade(1)/m/n/10 .
>> <recently read> \font
>> l.14  \showthe\font
>>                    }
>> ?

Note that there are 2 differences.
  a)  the code is interpreted twice.
  b)  the counter for distinct font instances has
      been reset to 0 upon leaving the {tabularx}
      so increases again to only 1 with the 2nd
      use of \addfontfeature .

> The problem is that the fullvoc mapping, when called locally in  
> tabularx
> first, remains active afterwards, even if one uses a font with a
> different mapping once the tabularx environment is closed. As  
> Ulrike has
> found out, this strange behaviour is neutralised if one uses  
> \arabicfont
> first before the tabularx env. To my unexpert eyes, this could be a
> problem with the \addfontfeature macro in fontspec, or a strange  
> bug in
> tabularx. Bidi and arabxetex are not guilty in any case ;)

Replacing {tabularx} by {tabular} the problem does not appear.
So certainly the problem is triggered by some action taken in
the coding for a {tabularx}.

I suspect that it either changes the global/local nature of
some commands that advance counters or disables them altogether
  --- presumably related to the double-pass action that it takes
when first working out the width of columns. (Otherwise the
counter would be advanced twice by the time its value is needed
to be used in the table contents.) However, this strategy seems
to be inconsistent with declaring new font features.

Is there a solution/workaround?

First declare *outside* the table any special font requirements
that you'll be wanting to use inside a {tabularx}.
Associate these fonts with a macro name, and then use this macro
to get the font+attributes.

> F

Hope this helps,


Ross Moore                                       ross at maths.mq.edu.au
Mathematics Department                           office: E7A-419
Macquarie University                             tel: +61 (0)2 9850 8955
Sydney, Australia  2109                          fax: +61 (0)2 9850 8114

More information about the XeTeX mailing list