[XeTeX] Determining current font

Ross Moore ross at ics.mq.edu.au
Mon Jun 9 01:50:52 CEST 2008


Hi James, Ulrike, and others,

On 08/06/2008, at 6:41 PM, Ulrike Fischer wrote:
> Am Sat, 7 Jun 2008 20:04:03 -1000 schrieb James Crippen:
>
>> This is a XeLaTeX/fontspec problem, I've got a current SVN  
>> checkout of
>> XeTeX and fontspec 1.17, both on Mac OS X 10.5.3. I'm trying to write
>> a macro which selects a specific nonstandard symbol from two  
>> different
>> fonts. Specifically, both Charis SIL and Adobe Minion offer a slashed
>> zero symbol, but encoded differently for both. In addition, both have
>> different OpenType features used to access them (Charis SIL uses a
>> variation of the empty set, and Minion uses the SlashedZero feature,
>> IIRC).
>>
>> My idea was to simply check which font was currently in use when the
>> macro is called, and specify one or the other ɡlyph dependinɡ on  
>> the
>> font. But I've been looking around in the documentation and sources
>> for fontspec and XeTeX and I can't find a macro that returns the  
>> value
>> of the current font which I could use for a conditional.
>>
>> Is there a way to get information about the current font in use? A
>> macro or variable I can poke at?
>
> The family is stored in \f at family (standard LaTeX} and \zf at family  
> (from
> fontspec) (I don't know if there are cases where the commands give
> different results).

To get the actual font at any particular place in the document,
you can insert  \showthe\font  at that place in your source.
This will pause processing with a .log  message, such as:

 > \OT1/cmr/m/n/10.95 .
<recently read> \font

If letters follow, then this is the font that will be used.
But if you are in special situations, such as math-mode,
and use macros for characters (e.g. \left\{ )
then the '{' may need a different font.


If you don't want processing to stop, the  \the\font
expands to the string identifying the font
(e.g.  \OT1/cmr/m/n/10.95  above).

However, there is a catch!
All the characters in this string have category code 12,
rather than the usual 11 for letters.
This means that you need to be very familiar with low-level
TeX (rather than LaTeX) commands, to be able to write
comparison macros to make use of this information.


In LaTeX, the internal macro  \font at name  holds the same
information as  \the\font ; try this anywhere in your doc:

\makeatletter
  \showthe\font
  \show\font at name
\makeatletter

The macro \font at name  may be a bit easier to work with,
for automated testing and comparisons. That depends upon
precisely what you want to do with this information.



> -- 
> Ulrike Fischer


Hope this helps,

	Ross

------------------------------------------------------------------------
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