[XeTeX] Problem with font features in tables

Michael Lynch michael.s.lynch at googlemail.com
Wed Feb 4 02:04:29 CET 2009


Thanks for the help! I did see the bit on font efficiency in the fontspec
manual, but wasn't entirely clear as to whether addfontfeatures introduced a
new font at each call if the arguments were the same. I've tried what you've
suggested, and this works fine.

As this is a much better solution anyway, it's all slightly academic, but if
you're interested, here's hopefully a better description of the problem I
had before:

(The \fullcaps{2007} was only ever meant to apply to that individual cell. I
also do seem to need both Letters=Uppercase and Numbers=Uppercase/Lining for
my fullcaps command.)

The key point I explained very badly in my earlier email was that the call
to \fullcaps{2007} works fine, if used by itself. It only fails to work if
before \fullcaps is first used, there is a call to \abbracr - this seems
very strange to me, as they should presumably be independent. Effectively,
this means the difference between TestCommented.pdf and TestUncommented.pdf
is that in TestCommented.pdf, \abbracr is called before the first instance
of \fullcaps (\abbracr works, but \fullcaps does not), whereas in the
TestUncommented.pdf case, \fullcaps is called first (both commands work). To
write this out for clarity, with my original definitions 

\newcommand{\abbracr}[ 1
]{{\addfontfeatures{LetterSpace=5.0,Letters=SmallCaps}\MakeTextLowercase{#1}
}}
\newcommand{\fullcaps}[ 1
]{{\addfontfeatures{Letters=Uppercase,Numbers=Uppercase}\MakeTextUppercase{#
1}}}

I have the two cases,

Case A (effectively in TestCommmented.pdf):

\begin{tabularx}{\textwidth}{ p{4cm} X }
	a & \abbracr{ILC} \\					% Correctly
sets in small caps
\end{tabularx}

\begin{tabularx}{\textwidth}{ p{4cm} X }
	\fullcaps{2007} & a					%
Incorrectly set, using old style/lowercase figures
\end{tabularx}

Case B (effectively in TestUncommented.pdf):

\fullcaps{}
\begin{tabularx}{\textwidth}{ p{4cm} X }
	a & \abbracr{ILC} \\					% Correctly
set in small caps
\end{tabularx}

\begin{tabularx}{\textwidth}{ p{4cm} X }
	\fullcaps{2007} & a					% Correctly
set with lining/uppercase figures
\end{tabularx}

My point with the \phantom{\fullcaps{}} was that it didn't matter if it any
text was set in the first call of \fullcaps - even just saying \fullcaps{}
was sufficient for the later output in the cell to use lining figures (I've
just realised that phantom here is a complete red herring, and serves no
purpose at all).

I really don't see why case B should behave any differently to case A.
Interestingly, if I get rid of all the tables, both cases work, so I'm left
wondering if there's something strange happening with the tabularx
environment, but have no idea how to go about checking this.

Thanks once more,

Michael



-----Original Message-----
From: xetex-bounces at tug.org [mailto:xetex-bounces at tug.org] On Behalf Of
Peter Dyballa
Sent: 04 February 2009 00:04
To: Unicode-based TeX for Mac OS X and other platforms
Subject: Re: [XeTeX] Problem with font features in tables


Am 03.02.2009 um 19:34 schrieb Michael Lynch:

> \newcommand{\abbracr}[ 1
> ]{{\addfontfeatures{LetterSpace=5.0,Letters=SmallCaps} 
> \MakeTextLowercase{#1}
> }}
>
> The second, to be used in some headings, should make the text upper  
> case and
> select lining figures:
>
> \newcommand{\fullcaps}[ 1
> ]{{\addfontfeatures{Letters=Uppercase,Numbers=Uppercase} 
> \MakeTextUppercase{#
> 1}}}

These two are not good! Every time you use any of these commands a  
new font instance is created - and in another thread it was found  
that only a few thousand fonts are allowed. It's better to first   
declare these two font instances and then create commands that re-use  
them over and over again:

\newfontfamily\abbr[LetterSpace=5.0,Letters=SmallCaps]{Constantia}
\newfontfamily\fulc[Letters=Uppercase,Numbers=Uppercase]{Constantia}

\DeclareRobustCommand{\abbracr}[1]{{\abbr\MakeTextLowercase{#1}}}
\DeclareRobustCommand{\fullcaps}[1]{{\fulc\MakeTextUppercase{#1}}}


>
> However, for my document, they are both used for the first time in  
> a table.
> The problem occurs when my "fullcaps" command has not been used in  
> the body
> text first. If I run it on my sample document (Test.tex), it does not
> produce "full caps" numerals as I'd expect. If however, I include a
> \phantom{\fullcaps{}} command prior to the first table, it works as  
> I'd
> like! This isn't a problem to do, and seems to have no effect on  
> the final
> layout, but I wondered if anyone could explain why it does this?
>

I either don't understand what you are describing here or you are not  
understanding what a line

	\fullcaps{2007a} & a \\

in a table environment will do. In the above example the fullcaps  
feature is only applied for the first cell - not the whole line! Does  
this explain what you get?

Or did you forget what Will Robertson wrote on page 17 of his  
fontspec manual on numbers?

	 "The synonyms Uppercase and Lowercase are equivalent to Lining and

OldStyle, respectively."

Since, IMO, numbers are neither upper nor lower case I'd recommend to  
use the terms "Lining" or "OldStyle."

--
Greetings

   Pete

When in doubt, use brute force.
				- Ken Thompson



_______________________________________________
XeTeX mailing list
postmaster at tug.org
http://tug.org/mailman/listinfo/xetex



More information about the XeTeX mailing list