[XeTeX] Fontspec and testing smallcaps presence

Will Robertson wspr81 at gmail.com
Wed Apr 22 07:07:59 CEST 2009


On 2009-04-22 07:47:06 +0930, James Crippen 
<jcrippen at gmail.com> said:

> I'm hacking on a Biblatex style and there's the following little macro
> to detect whether smallcaps are available in a font:
> [snip]
> It's supposed to convert acronyms to smallcaps when possible. This
> doesn't work as intended with fonstpec fonts.

It took me a little while debugging my package before I realised that 
the \mkbibacro macro isn't supposed to be given lowercase text. You 
give it uppercase text (only) and it will either spit out small caps or 
leave things alone.

	\documentclass{article}
	\usepackage{fontspec,etoolbox}
	\makeatletter	
	\newcommand*{\mkbibacro}[1]{%
	    \ifcsundef{\f at encoding/\f at family/\f at series/sc}
	       {#1}
	       {\textsc{\MakeLowercase{#1}}}}
	\begin{document}
	\fontspec{Hoefler Text}
	\mkbibacro{SMALL CAPS?}
	\fontspec{Times}
	\mkbibacro{SMALL CAPS?}
	\end{document}

You could change {#1} to {\MakeUppercase{#1}} in the code above and 
then both \mkbibacro{ANZAC} and \mkbibacro{anzac} would give you the 
same results.
	
Cheers,
Will




More information about the XeTeX mailing list