LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show HTML Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: Mailing list for the LaTeX3 project <[log in to unmask]>
From: Frank Mittelbach <[log in to unmask]>
Date: Sat, 3 Feb 2001 15:15:03 +0100
In-Reply-To: <[log in to unmask]>
Reply-To: Mailing list for the LaTeX3 project <[log in to unmask]>
Parts/Attachments: text/plain (139 lines)
after having handwaved myself through the ideas of  specifying glyph
collections rather than font encodings, here is a "hand waving" sort of
implementation of the idea.

basically \fontencoding is changed to accept a comma list of encodings and
\selectfont is changed to try these encodings in order (keeping the other font
characteristics) until it finds a font or runs out of encodings. in the latter
case it trys to find a font by changing the characteristics to defaults.

the latter process could and should be made smarter, eg given

 encodings T1,OT1
 family    xxx
 series    yyy
 shape     zzz

it will try

 T1/xxx/yyy/zzz
OT1/xxx/yyy/zzz
 T1/xxx/yyy/<defaultshape>
 T1/xxx/<defaultseries>/<defaultshape>
 T1/<defaultfamily>/<defaultseries>/<defaultshape>
 FAIL

instead of

 T1/xxx/yyy/zzz
OT1/xxx/yyy/zzz
 T1/xxx/yyy/<defaultshape>
OT1/xxx/yyy/<defaultshape>
 T1/xxx/<defaultseries>/<defaultshape>
OT1/xxx/<defaultseries>/<defaultshape>
 ...

which might be a better approach.

anyway, here it is and it seems to work more or less. what do you think?

frank


--------------------------- glyphcoll.tex
\documentclass{article}

\usepackage[T1,OT6,OT1]{fontenc}


\makeatletter
\DeclareRobustCommand\fontencoding[1]{\edef\glyph@collection{#1}}

\DeclareRobustCommand\Xfontencoding[1]{%
    \expandafter\ifx\csname T@#1\endcsname\relax
      \@latex@error{Encoding scheme `#1' unknown}\@eha
    \else
      \edef\f@encoding{#1}%
      \ifx\cf@encoding\f@encoding
        \let\enc@update\relax
      \else
        \let\enc@update\@@enc@update
      \fi
    \fi
}

\DeclareRobustCommand\Xselectfont
        {%
    \ifx\f@linespread\baselinestretch \else
      \set@fontsize\baselinestretch\f@size\f@baselineskip \fi
    \expandafter\get@next@encoding\glyph@collection,\@nil
    \xdef\font@name{%
      \csname\curr@fontshape/\f@size\endcsname}%
    \Xpickup@font
    \font@name
    \size@update
    \enc@update
    }



\def\get@next@encoding#1,#2\@nil{%
  \Xfontencoding{#1}%
  \def\sub@glyph@collection{#2}%
}

\def\Xpickup@font{%
\@font@warning{Trying for \font@name ...}%
    \expandafter \ifx \font@name \relax
       \Xdefine@newfont
    \fi}


\def\Xdefine@newfont{%
\@font@warning{  ... undefined ... try to load it ...}%
  \begingroup
    \let\typeout\@font@info
    \escapechar\m@ne
    \expandafter\expandafter\expandafter
       \split@name\expandafter\string\font@name\@nil
      \try@load@fontshape % try always
    \expandafter\ifx
       \csname\curr@fontshape\endcsname \relax
\@font@warning{  ... unloadable ... }%
      \Xwrong@fontshape\else
\@font@warning{  ... loadable ... extract it}%
      \extract@font\fi
  \endgroup}


\def\Xwrong@fontshape{%
  \expandafter\get@next@encoding\sub@glyph@collection,\@nil
  \ifx\f@encoding\@empty
     \expandafter\get@next@encoding\glyph@collection,\@nil
     \wrong@fontshape
  \else
    \xdef\font@name{%
      \csname\curr@fontshape/\f@size\endcsname}%
    \Xpickup@font
  \fi
}

\makeatother



\begin{document}

\fontfamily{cmr}
\fontencoding{OT6,T1}\selectfont
AA

\fontfamily{ptm}\selectfont
BB

\fontseries{b}\selectfont
CC

\showoutput
\stop

ATOM RSS1 RSS2