[XeTeX] "Hoefler Text" XeLaTeX interface
Jonathan Kew
jonathan_kew at sil.org
Mon Oct 4 13:16:41 CEST 2004
On 4 Oct 2004, at 10:56 am, Will Robertson wrote:
>> To some extent, even "standard" features such as Small Caps could be
>> auto-detected and supported, using the AAT/OT query primitives that
>> XeTeX already has. I'll probably have a go at writing such macros
>> sometime, if nobody else gets there first, but I'd like to get font
>> family discovery working first.
>
> I looked in your AAT-info.tex macro, but I could only see how to get
> the actual name of the feature, not a standardised flag of what the
> feature actually is. So with Apple's naming scheme hopelessly
> ridiculous, I figured at present it wasn't possible (for me at least).
Features and selectors do have numeric IDs (which are supposedly
standard, for registered features); there's a feature registry
somewhere on Apple's site (see http://developer.apple.com/fonts). The
AAT-info.tex file uses \XeTeXfeaturename and \XeTeXselectorname to
display the names for these, but you could ask it to display the
numbers as well. Just add something to the loop that prints the
features:
---
\ifnum\nf>0
\loop
\fc=\XeTeXfeaturecode\testfont\f
\noindent \XeTeXfeaturename\testfont\fc \ [\number\fc] % output ID
as well as name
\endgraf
\ns=\XeTeXcountselectors\testfont\fc
{
\loop
\sc=\XeTeXselectorcode\testfont\fc\s
\textindent{%
\ifnum\XeTeXisexclusivefeature\testfont\fc>0
\ifnum\XeTeXisdefaultselector\testfont\fc\sc>0 \radioOn \else
\radioOff \fi
\else
\ifnum\XeTeXisdefaultselector\testfont\fc\sc>0 \checkOn \else
\checkOff \fi
\fi
}\XeTeXselectorname\testfont\fc\sc \ [\number\fc] % output ID as
well as name
\endgraf
\advance\s by 1 \ifnum\s<\ns \repeat
}
\smallskip
\advance\f by 1 \ifnum\f<\nf \repeat
\else
\noindent {No AAT features available}\par
\fi
---
Given this, you can discover that the Letter Case feature, for example,
is 3; and that the Small Caps selector within that feature is also 3,
as it happens. Knowing this, you can write macros that discover whether
a given font has a small caps feature (with the standard ID), and
exactly what the name should be:
---
\nopagenumbers \frenchspacing
\def\myfont{Hoefler Text}
\font\testfont="\myfont" at 10pt \testfont
\edef\lettercasename{\XeTeXfeaturename\testfont 3 }
\ifx\lettercasename\empty
Font \myfont\ doesn't seem to support Letter Case features.
\else
\edef\smallcapsname{\XeTeXselectorname\testfont 3 3 }
\ifx\smallcapsname\empty
Font \myfont\ doesn't seem to support a Caps and Small Caps feature.
\else
\font\scfont="\myfont:\lettercasename=\smallcapsname" at 10pt
For {\scfont Caps and Small Caps} in \myfont, specify
the option "\lettercasename=\smallcapsname".
\fi
\fi
\end
---
>> Full support of rich fonts with unique features will still require
>> manually-constructed .fd files, I expect, but many of the simpler
>> cases should become virtually painless.
>
> One of the problems for complex fonts is trying to squeeze everything
> in! Is there any way of applying a known feature to the already
> selected font? That would make things a lot easier for ligatures and
> so on.
>
> At the moment I need a separate font family for literally almost every
> (if I choose to make them, which I don't) permutation of font feature
> choice. But if there was an XeTeX command I didn't know about that
> would do say:
>
> \font\f="Hoefler Text"
> \f
> text with normal ligatures
>
> \xetexchangefontfeature{"Ligatures = Rare\space Ligatures;"}
> text with rare ligatures
>
> That would be fantastic. Is such a thing conceivable or in existence
> already?
It's something I've thought about, though it would be a significant
break from the current model where a TeX \font is directly associated
with one specific ATSUI style. I can think of a couple of ways it might
be implemented, but I'm not ready to promise anything!
In principle, you could probably do it directly in TeX macros even
now--use \fontname to get the name of the current font, and then
declare a new \font with the feature setting you want added. But that
sort of string manipulation in TeX macros can get tricky, I admit.
JK
More information about the XeTeX
mailing list