# [XeTeX] \fontname bugs?

Jonathan Kew jonathan_kew at sil.org
Mon Jan 16 12:05:18 CET 2006

On 16 Jan 2006, at 6:40 am, Will Robertson wrote:

> Hello,
>
> Bug?

No.... undocumented feature! :)

> XeTeX 0.99b:
>
> %%%%
> \font\1="Hoefler Text/B" at 10pt
> \fontname\1
> % output: "Hoefler Text Black/B"
> % Shouldn't the "/B" disappear after the bold font name is resolved?
> %%%%
>
> Rationale: I want to present better error messages in fontspec. I
> have a macro that holds the user's requested font name, say, \def\fn
> {Hoefler Text}. When dealing with the italic and bold fonts, this
> is changed to \def\fn{Hoefler Text/B}; if I resolve this name (as
> above), then strip the quotes, it will function the same in the
> macros that use it but will make more sense when displayed.
>

Yes, it would make sense to strip the /B, wouldn't it? Sorry; I was
aware of this, but too lazy to do it right at the time. <blush>

The behavior of 0.99b seemed preferable to 0.99a, which omitted all
such "qualifiers" from the name that \fontname gives you. The trouble
with that is that if you then re-use that name, you could end up with
a different rendering engine or a different optical size, which I
would consider a more serious bug.

But you're right, the /B or /I should really be removed once they've
been used to resolve a specific font face. I'd better do this for
0.991, I guess, since you've caught me being sloppy here! For now,
the residual qualifiers on the name should be harmless if you re-use
it, I believe; XeTeX will end up ignoring them.

> Cheers,
>
> Will
>
> P.S. It seems a side effect of TeX's "weird" parsing of the
> arguments of \font that
>   \font\1="Hoefler Text"        \fontname\1
>   \font\1="Hoefler Text" at 12pt\fontname\1
> return 'nullfont' and '"Hoefler Text"' respectively -- not what I
> expected). I checked, and pdfTeX behaves the same.

Yes, it would. Slightly unexpected, perhaps, but correct according to
TeX's rules.

See if you can predict the error message this will generate, under
standard TeX (or XeTeX):

* make a copy of "cmr10.tfm" with the name "scaled.tfm", in the
current directory

* run TeX with the input (pay attention to the numbers!):

\font\1 = scaled at 10pt \fontname\1
\font\2 = cmr10 \fontname\1
\end

JK