Behaviour of \latinfamily

Ulrik Vieth vieth@thphy.uni-duesseldorf.de
Fri, 29 May 1998 11:59:52 +0200



> I've found that common sense always fails me in this sort of work.
> I haven't a clue what \font_family is without finding out where it
> comes from.  I tried working through the \latinfamily to find out,
> but failed here:

> \def\latinfamily#1#2{
>    \edef\temp_command{#1}
>    \expandafter\parse_family\temp_command
>       \empty_command\empty_command\end_parse_family

> \parse_family makes no sense to me, so I can't get anywhere in
> understanding \latinfamily.

I think this is a particular tricky example of TeX parsing tricks.
Essentially, this does something like calling

    \parse_family#1  \end_parse_family

where \parse_family takes a delimited argument, i.e. everything
that follows until \end_parse_family.

The purpose of \parse_family is to pick apart the first argument
of \latinfamily, which is a 3-letter family code, optionally 
followed by a variant code ('t' or 's' for typerwriter or sans)
or an expert flag ('x' for expert, '9' for oldstyle digits).

The effect of \parse_family is to initalize the variables
\font_family, \font_variant, \raw_variant and \latex_family.

\def\parse_family #1#2#3#4#5\end_parse_family{ 
    \edef\font_family{#1#2#3} 
   \edef\font_variant{#4#5} 
   \edef\raw_variant{#4#5} 
   \edef\latex_family{#1#2#3#4#5} 

As a result, \font_family will contain the first three letters of 
the first argument of \latinfamily, i.e. the family code only.

\font_variant and \raw_variant will contain the following two
characters, if any, or else they will be empty.  Both \font_family 
and \font_variant will later be used to construct font file names.

Finally, \latex_family will contain the full argument, which
will end up in the .fd files and the names of the .fd files.

Examples: 

  \latin_family{ptm}{}

  -> \font_family  = \latex_family  = ptm
     \font_variant = \raw_variant = <empty>

  \latin_family{hslt}{}	% Lucida Sans Typewriter

  -> \font_family  = hls, \latex_family  = hlst
     \font_variant = \raw_variant = t

  \latin_family{psts}{}	% Stone Sans

  -> \font_family  = pst, \latex_family  = pst
     \font_variant = \raw_variant = s

(Note: The prefered method seems to be to assign new family codes
for sans variants, treating Stone Sans as family of its own (ps8),
rather than as a variant of Stone Serif, which would be psts.)

  \latin_family{pmnx}{}	% Minion Expert

  -> \font_family  = pmn \latex_family  = pmnx
     \font_variant = \raw_variant = x (initially)

In the case of expert fonts, the remaining code of \parse_family,
will set the flag \if_expert_ and subsequently remove the 'x' 
from \font_variant and \raw_variant.

Hope this helps.
Cheers, Ulrik.

P.S. As for the difference of \font_variant and \raw_variant, I don't
know.  I'd have to dig further through the code to find out if it ever
needed, or if it would be sufficient to have \font_variant only.