On 2010-09-21 09:39:51 +0930, Gareth Hughes
<garzoh...@gmail.com> said:
Peter Dyballa wrote:
Am 20.09.2010 um 20:44 schrieb Gareth Hughes:
I'm asking for a more useful implementation that checks whether a
certain font is in use now
Wouldn't it be sufficient to check what \{rm,sf,tt}default are set to?
Perhaps, but a more general, fontspec solution is needed because the
fonts I want to work with are Syriac fonts. Also, I need to activate
kerning corrections only when that font is in use, i.e. it would be no
good to see if the font is being used in a document and then apply the
kerning corrections for all fonts in the document.
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\curr...@family\f@family
\fontspec[#1]{#2}
\ifx\curr...@family\zf@family
\global\l...@tempa\@firstoftwo
\else
\global\l...@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
--------------------------------------------------
Subscriptions, Archive, and List information, etc.:
http://tug.org/mailman/listinfo/xetex