[XeTeX] If font under fontspec

Gareth Hughes garzohugo at gmail.com
Tue Sep 21 14:49:38 CEST 2010


Will Robertson wrote:
> It sort of depends how you want to write the code for the test. Here's a
> proof of concept that might do what you need:
> 
> \documentclass{article}
> \usepackage{fontspec}
> 
> \makeatletter
> \newcommand\IsFont[4][]{%
>  \begingroup
>    \let\current at family\f at family
>    \fontspec[#1]{#2}
>    \ifx\current at family\zf at family
>      \global\let\@tempa\@firstoftwo
>    \else
>      \global\let\@tempa\@secondoftwo
>    \fi
>  \endgroup
>  \@tempa{#3}{#4}
> }
> \makeatother
> 
> \begin{document}
> \newfontfamily\foo{Times New Roman}
> \setmainfont{Helvetica}
> test: \IsFont{Times New Roman}{Times}{not Times}
> \par\foo
> test: \IsFont{Times New Roman}{Times}{not Times}
> \end{document}
> 
> 
> I've considered adding such code to fontspec before. But this interface
> is not very reliable -- font options must be exactly the same for two
> fonts to be "equal". See how you go, though.
> 
> Will

Thanks for this, Will. This is exactly the kind of thing I wanted. I
could use it to create a usable command that will 'fix' all subsequent
instances of the font. If it's designed as a command for an end user,
then the user can specify the exact set options.

I think that this might be easier than defining a new fontspec option to
fix a font, which would require redefining fontspec.

Thanks,

Gareth.


More information about the XeTeX mailing list