Here's an updated file, slightly delayed by a bug in 1.2 -- be careful
with cut-and-pasting ERT!

Robin
#LyX 1.2 created this file. For more info see http://www.lyx.org/
\lyxformat 220
\textclass article
\language english
\inputencoding auto
\fontscheme default
\graphics default
\paperfontsize default
\spacing single 
\papersize Default
\paperpackage a4
\use_geometry 0
\use_amsmath 0
\use_natbib 0
\use_numerical_citations 0
\paperorientation portrait
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\defskip medskip
\quotes_language english
\quotes_times 2
\papercolumns 1
\papersides 1
\paperpagestyle default

\layout Subsection

Using different fonts in LyX
\layout Standard

by 
\noun on 
Robin Turner
\layout Standard


\begin_inset ERT
status Open

\layout Standard

\backslash 
newfont{
\backslash 
yinit}{yinit}
\backslash 
yinit
\end_inset 


\layout Standard

L 
\begin_inset ERT
status Open

\layout Standard

\backslash 
normalfont
\end_inset 

 yX currently uses a fairly limited selection of fonts.
 While it may come as a disappointment to people used to the thousands of
 TrueType fonts available to conventional word processors, there are in
 fact good reasons for this choice.
 LyX actually has no fonts of its own; for the screen it uses whatever fonts
 are available to the X-window system, and for output it uses the fonts
 of the TeX setup it is operating with.
 The selection of default faults correspond to the most useful and commonly-foun
d fonts available in TeX.
 The 
\begin_inset Quotes eld
\end_inset 

L
\begin_inset Quotes erd
\end_inset 

 at the beginning of this section is a case in point: most TeX distributions
 include the 
\family typewriter 
yinit
\family default 
 font, so you should see a nice decorated 
\begin_inset Quotes eld
\end_inset 

L
\begin_inset Quotes erd
\end_inset 

 at the beginning; some distributions may not, so you won't.
\layout Standard

Another point is that the profusion of fonts which TrueType brought about
 has generally had a bad effect on desktop publishing, leading to documents
 with inappropriate, badly-scaled or simply too many fonts.
 You should therefore think carefully before using a different default font,
 or mixing font families in the same document.
\layout Standard

Nevertheless, you can, with a little Evil Red Text, make LyX produce just
 about any font you want, and even design your own fonts.
 What follows is a 
\begin_inset Quotes eld
\end_inset 

quick fix
\noun on 

\begin_inset Quotes erd
\end_inset 


\noun default 
 guide; it is no substitute for reading a good book on (La)TeX.
\layout Subsubsection

Changing the default font
\layout Standard

The easiest and most reliable way to change the default font is from within
 LyX, through 
\family sans 
Layout\SpecialChar \menuseparator
Document\SpecialChar \menuseparator
Fonts
\family default 
.
 The next easiest is to use a package contained in your TeX distribution.
 For example, the rather pretty Pandora font family can be accessed simply
 by putting 
\family typewriter 

\backslash 
usepackage{pandora}
\family default 
 in your LaTeX preamble (
\family sans 
Layout\SpecialChar \menuseparator
LaTeX\SpecialChar ~
preamble
\family default 
).
 Similarly, 
\family typewriter 

\backslash 
usepackage{oldgerm}
\family default 
 in the preamble gives you access to Yannis Haralambous' Old German (Gothisch)
 fonts via the specially-defined 
\family typewriter 

\backslash 
gothfamily
\family default 
, 
\family typewriter 

\backslash 
swabfamily
\family default 
, and 
\family typewriter 

\backslash 
frakfamily 
\family default 
commands, which you insert in your document (as TeX) to obtain the desired
 font (note that nothing will change in your screen display, which considering
 the difficulty involved in reading some of these fonts is just as well).
 Other useful packages are 
\family typewriter 
concrete
\family default 
, which gives access to both the Concrete Roman and the Euler math fonts,
 and 
\family typewriter 
chancery
\family default 
, which gives you the Zapf Chancery font
\layout Standard

A less reliable method is the
\family typewriter 
 
\backslash 
familydefault
\family default 
 command.
 If you have a font installed and know its family name, you can put something
 like 
\layout Quote


\family typewriter 

\backslash 
renewcommand{
\backslash 
familydefault}{pzc} 
\layout Standard

in the preamble (
\begin_inset Quotes eld
\end_inset 

pzc
\begin_inset Quotes erd
\end_inset 

 is the family name for the Zapf Chancery font).
 You should be aware, however, that this method may produce strange results
 if the font you have selected does not have the sizes or shapes you want
 (e.g.
 adding emphasis to text has no effect on Zapf Chancery, and choosing the
 sans serif or typewriter series will cause it to revert to the standard
 font).
\layout Subsubsection

More than one font family in one document
\layout Standard

As I've said, different font families in the same document can spell trouble.
 Unlike many human families, the members of a font family work well together,
 so the eye is not overly disturbed when changing from a medium roman to
 a bold sans serif font, for example.
 Different font families may not have this visual compatibility, and clashing
 fonts are a common reason for amateur publishing looking amateurish.
 (End of sermon.)
\layout Standard

Nevertheless, you may need different fonts for some reason: maybe you have
 to include a different alphabet, like Klingon or Cuneiform
\begin_inset Foot
collapsed true

\layout Standard

These can be downloaded from CTAN.
 Remember, though, that some 
\begin_inset Quotes eld
\end_inset 

normal
\begin_inset Quotes erd
\end_inset 

 fonts can be turned into a different alphabet by changing the font encoding;
 see a good LaTeX book if you want to do this.
\end_inset 

, or you want a structural/aesthetic effect, such as putting poetry in a
 different font from prose, like this:
\layout Standard


\begin_inset ERT
status Open

\layout Standard

\backslash 
newfont{
\backslash 
poetry}{eurm8}
\backslash 
poetry
\end_inset 


\layout Verse

Myself when young did eagerly frequent
\newline 
Emacs and vi, and heard great Argument
\layout Standard


\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
normalfont
\end_inset 

 One way to do this is to declare your own font commands.
 For example, writing 
\layout Quote


\family typewriter 

\backslash 
newfont{
\backslash 
avant}{pagd} 
\layout Standard

will define a command, 
\family typewriter 

\backslash 
avant
\family default 
, which can be invoked anywhere in your document to change to the 
\begin_inset ERT
status Open

\layout Standard

\backslash 
newfont{
\backslash 
avant}{pagd}
\backslash 
avant
\end_inset 

 Avant Garde font.
 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
normalfont
\end_inset 

 You can return to your default font by typing 
\family typewriter 

\backslash 
normalfont
\family default 
.
\layout Standard

Some fonts will perform adequately with just the basic font name (as above);
 others require that you specify a font size; for example, the verse above,
 aside from mangling Omar Khayyam, used the font command 
\family typewriter 
eurm8
\family default 
 (i.e.\SpecialChar ~
Euler Roman 8pt).
\layout Standard

Some fonts may also need scaling using the 
\family typewriter 
scaled
\backslash 
magstep
\family default 
\emph on 
n
\emph default 
 option, since their idea of, say, 10pt, may not be the same as that of
 your default font family.
 If the font looks too small, try a command like this:
\layout Quote


\backslash 
newfont{
\backslash 
zapf}{pzci10 scaled
\backslash 
magstep1}
\layout Standard

This scales the rather small-looking Zapf Chancery font so that it looks
 the same size as the default (10pt) font.
 If your font looks too big, select a smaller fontsize (e.g.
 8pt) and scale up.
\layout Subsubsection

Finding new fonts
\layout Standard

So where do you find all these exciting new fonts? There are three main
 methods:
\layout Enumerate

Look around in your TeX distribution.
\layout Enumerate

Download TeX fonts.
\layout Enumerate

Convert TrueType fonts to TeX.
\layout Standard

The first stage is as far as most people will want to go.
 Have a look in
\family sans 
 
\family typewriter 
$TEXMF/fonts/tfm
\family default 
 to see what you've got (where 
\family typewriter 
$TEXMF
\family default 
 is the location of your TeX system, usually something like
\family typewriter 
 /usr/share/texmf
\family default 
).
 When you see something that looks promising, test it in a LyX document
 using the method described above, i.e.
 make a new font command and use it on some text, then preview and see what,
 if anything, you get.
 Note that the font name you want is usually the first four letters of the
 file name, e.g.
 a file named 
\family typewriter 
pncb8a.afm
\family default 
 is actually the bold (b) version of Adobe's (p) New Century (nc) family.
 If in doubt about names, check out the files in 
\family typewriter 
$TEXMF/fontname
\family default 
.
\layout Standard

TeX fonts can be downloaded from your nearest CTAN mirror (e.g.
 
\begin_inset LatexCommand \url{ftp.ivorytower.edu/pub/tex/ctan/fonts}

\end_inset 

).
 At first, look for font directories which include a 
\family typewriter 
.sty
\family default 
 file which you can invoked in your preamble, as this will make life easier
 (as in the case of Pandora).
 Failing that, look for directories which give you the full set of TeX font
 files.
 Failing 
\emph on 
that
\emph default 
, look for an 
\family typewriter 
.afm
\family default 
 file and run the program 
\family typewriter 
fontinst
\family default 
 on it (read, or at least skim, the manual first---you've probably got it
 in 
\family typewriter 
$TEXMF/doc/fontinst/base/fontinst.dvi
\family default 
).
 You should now have a directory filled with downloaded or converted files.
 
\layout Standard

Now you need to put the font files in the right places.
 Unless you're running Windows 9* or have an entire TeX system in your home
 directory, you need to be root to do this.
 The basic rule is to look at the extension of the file and move it to the
 corresponding directory, and put 
\family typewriter 
.sty
\family default 
 files in the 
\family typewriter 
/latex
\family default 
 directory:
\layout Itemize


\family typewriter 
.sty, .cls 
\family default 
or
\family typewriter 
 .fd 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/tex/latex/
\family default 
\emph on 
<package_name>
\family typewriter 
\emph default 
/
\layout Itemize


\family typewriter 
.dvi, .ps 
\family default 
or
\family typewriter 
 .pdf 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/doc/latex/
\family default 
\emph on 
<package_name>
\family typewriter 
\emph default 
/
\begin_inset Foot
collapsed false

\layout Standard

These will be documentation files for the font, not fonts themselves.
\end_inset 


\layout Itemize


\family typewriter 
.tfm 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/fonts/tfm/
\family default 
\emph on 
<supplier>
\family typewriter 
\emph default 
/
\family default 
\emph on 
<font_name>
\family typewriter 
\emph default 
/
\layout Itemize


\family typewriter 
.vf 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/fonts/vf/
\family default 
\emph on 
<supplier>
\family typewriter 
\emph default 
/
\family default 
\emph on 
<font_name>
\family typewriter 
\emph default 
/
\layout Itemize


\family typewriter 
.afm 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/fonts/afm/
\family default 
\emph on 
<supplier>
\family typewriter 
\emph default 
/
\family default 
\emph on 
<font_name>
\family typewriter 
\emph default 
/
\layout Itemize


\family typewriter 
.pfb 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/fonts/type1/
\family default 
\emph on 
<supplier>
\family typewriter 
\emph default 
/
\family default 
\emph on 
<font_name>
\family typewriter 
\emph default 
/
\layout Itemize


\family typewriter 
.ttf 
\begin_inset Formula $\rightarrow $
\end_inset 

 $TEXMF/fonts/truetype/
\family default 
\emph on 
<supplier>
\family typewriter 
\emph default 
/
\family default 
\emph on 
<font_name>
\family typewriter 
\emph default 
/
\layout Standard

If this sounds confusing, check out 
\begin_inset LatexCommand \url{http://www.ctan.org/installationadvice/}

\end_inset 

.
\layout Standard

Thought you were finished? Not quite.
 First you need to hack the file 
\family typewriter 
$TEX/dvips/base/psfonts.map (
\family default 
there is a script to do this in a more orderly manner if you want---look
 at the comments at the top of the file for details).
 You need to add a line describing your new font so that 
\family typewriter 
dvips
\family default 
 can recognise it.
 Look at the other lines to get an idea of the format.
 The basic format is:
\layout Quote


\emph on 
TeX_name
\emph default 

\hfill 
 
\emph on 
Real_name
\emph default 

\hfill 
<
\emph on 
encoding
\emph default 
 
\emph on 
(optional)
\emph default 

\hfill 
<
\emph on 
pfbfilename
\family typewriter 
\emph default 
.pfb
\layout Standard

Now run 
\family typewriter 
texhash
\family sans 
 
\family default 
(as root, of course), or 
\family typewriter 
initexmf\SpecialChar ~
-update-fndb
\family default 
, if you're using MikTeX on Windows.
\layout Standard

If that wasn't enough for you, you may want to try converting your favourite
 TrueType font into a form that LyX can get at.
 It's a long, tiring process, but if you really want that font, it's worth
 it.
 First download the program 
\family typewriter 
ttf2pt
\family default 
, run it on your font, then run 
\family typewriter 
fontinst
\family default 
 on the output, and proceed as before.
 Have a look at 
\begin_inset LatexCommand 
\url{http://www.pegasus.rutgers.edu/~elflord/unix/latex/no-bs.html}

\end_inset 

\SpecialChar ~
.
\layout Subsubsection

Making your own fonts
\layout Standard

There are (at least) three ways to do this.
\layout Paragraph

The proper way
\layout Standard

Set aside some time---maybe a summer vacation.
 Get a copy of 
\emph on 
The
\emph default 
 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
newfont{
\backslash 
mf}{logo10}
\backslash 
mf
\end_inset 

 METAFONT 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
normalfont
\end_inset 

 
\emph on 
book
\emph default 
.
\begin_inset Foot
collapsed false

\layout Standard


\emph on 
This should have been one word, but there is a bug in the beta version of
 lyx-1.2 which means ERT can't be run into a word without a space.
 RT.
\end_inset 

 Learn the 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
mf
\end_inset 

 METAFONT 
\begin_inset ERT
status Collapsed

\layout Standard

\backslash 
normalfont
\end_inset 

 program.
 Produce beautiful fonts.
\layout Paragraph

A quick kludge
\layout Standard

Get a TrueType font editor.
 Make a TrueType font.
 Convert to TeX.
 This may work, but may produce rather ugly results.
\layout Paragraph

A very quick kludge
\layout Standard

If all you want is a few words (e.g.\SpecialChar ~
for a heading), rather than making an
 entire font, write want you want by hand and scan it, then insert it as
 a graphic.
 You could in theory make a whole alphabet like this and insert each letter
 as an inline .
\family typewriter 
eps
\family default 
 file, but it would be tedious, and probably not very aesthetic.
\layout Subsubsection

Recommended reading
\layout Standard
\noindent 
For a good overview of fonts in LaTeX:
\layout Standard
\added_space_bottom smallskip \noindent 
Michel Goossens, Frank Mittelbach and Alexander Samarin: 
\emph on 
The LaTeX Companion.
 
\emph default 
Addison-Wesley, 1994
\layout Standard
\noindent 
For more technical information about fonts and some samples:
\layout Standard
\added_space_bottom smallskip \noindent 
Norman Walsh: 
\emph on 
Making TeX Work
\emph default 
.
 O'Reilly, 1994
\layout Standard
\added_space_bottom smallskip \noindent 
If you really, really want to design fonts:
\layout Standard
\added_space_bottom smallskip \noindent 
Donald Knuth: 
\emph on 
The METAFONTbook
\emph default 
.
 Addison Wesley, 1986.
\the_end

Reply via email to