A font sampler

Alan Jeffrey

v0.06

1 Introduction

This document describes the font test document fontsmpl.tex and the accompanying package fontsmpl.sty. This produces a test of a font family, printing a sample text, a table of accents, and a sample of commands such as \pounds.

It can be used in two ways. The fontsmpl package provides the command \fontsample, which produces a sample of the current font.

The fontsmpl document prompts interactively for a font family (for example ‘cmr’) and produces a sample of that family.

2 Documentation

This docstrip document has three docstrip options:

   • document the code for fontsmpl.tex.
   • package the code for fontsmpl.sty.

• driver this documentation.

The code for the driver is: 1 ⟨∗driver⟩

 2 \NeedsTeXFormat{LaTeX2e}
 3 \documentclass{ltxdoc}
 4 \begin{document}
 5 \DocInput{fontsmpl.dtx}
 6 \end{document}

7 ⟨/driver⟩

3 Font sample document

The sample document prompts for a family, and uses the fontsmpl package. If there is a file fontsmpl.cfg, this is loaded. 8 ⟨∗document⟩

 9 \NeedsTeXFormat{LaTeX2e}

10 \documentclass{article}
11 \usepackage{fontsmpl}
12 \makeatletter
13 \InputIfFileExists{fontsmpl.cfg}{}{}
14 \makeatother
15 \typein[\family]{Please enter a family name (for example `cmr').}
16 \title{Test of \LaTeX{} font family `\family'}
17 \author{Font sample produced with `fontsmpl'}
18 \raggedright
19 \pagestyle{empty}
20 \begin{document}
21 \maketitle
22 \fontfamily{\family}\selectfont
23 \fontencoding{T1}\selectfont\fontsample
24 \fontencoding{OT1}\selectfont\fontsample
25 \itshape
26 \fontencoding{T1}\selectfont\fontsample
27 \fontencoding{OT1}\selectfont\fontsample
28 \slshape
29 \fontencoding{T1}\selectfont\fontsample
30 \fontencoding{OT1}\selectfont\fontsample
31 \scshape
32 \fontencoding{T1}\selectfont\fontsample
33 \fontencoding{OT1}\selectfont\fontsample
34 \upshape
35 \bfseries
36 \fontencoding{T1}\selectfont\fontsample
37 \fontencoding{OT1}\selectfont\fontsample
38 \itshape
39 \fontencoding{T1}\selectfont\fontsample
40 \fontencoding{OT1}\selectfont\fontsample
41 \slshape
42 \fontencoding{T1}\selectfont\fontsample
43 \fontencoding{OT1}\selectfont\fontsample
44 \scshape
45 \fontencoding{T1}\selectfont\fontsample
46 \fontencoding{OT1}\selectfont\fontsample
47 \end{document}

48 ⟨/document⟩

4 Font sample package

The fontsmpl package is a L^{A}TEX 2ε package. 49 ⟨∗package⟩

50 \NeedsTeXFormat{LaTeX2e}
51 \ProvidesPackage{fontsmpl}[1994/07/13 Font sample package]

\fontsample The \fontsample command prints out a sample text, a selection of glyphs, and a table of accents.

52 \newcommand{\fontsample}{%
53 Test of font \f@encoding/\f@family/\f@series/\f@shape.
54 \fontsampletext
55 \fontsampleglyphs
56 \fontsampleaccents

57 }

\fontsampletext A sample text, taken from Knuth’s testfont.tex.

58 \newcommand{\fontsampletext}{%
59 Some text:
60 \begin{quote}\begin{flushleft}
61  On November 14, 1885, Senator \& Mrs.~Leland Stanford called
62  together at their San Francisco mansion the 24~prominent men who
63  had been chosen as the first trustees of The Leland Stanford
64  Junior University.  They handed to the board the Founding Grant
65  of the University, which they had executed three days before.
66  This document---with various amendments, legislative acts, and
67  court decrees---remains as the University's charter.  In bold,
68  sweeping language it stipulates that the objectives of the
69  University are ``to qualify students for personal success and
70  direct usefulness in life; and to promote the publick welfare by
71  exercising an influence in behalf of humanity and civilization,
72  teaching the blessings of liberty regulated by law, and
73  inculcating love and reverence for the great principles of
74  government as derived from the inalienable rights of man to life,
75  liberty, and the pursuit of happiness.''
76 \\
77  (!`THE DAZED BROWN FOX QUICKLY GAVE 12345--67890 JUMPS!)
78 \\
79  ?`But aren't Kafka's Schlo\ss\
80  and \AE sop's \OE uvres often na\"\i ve vis-\`a-vis the
81  d\ae monic ph\oe nix's official r\^ole in fluffy souffl\'es?
82 \end{flushleft}\end{quote}

83 }

\fontsampleglyphs \fontsampleglyph A list of sample glyph commands. I’ve commented out the glyphs that aren’t present in the OT1 encoding.

84 \newcommand{\fontsampleglyphs}{%
85 Some glyphs:
86 \begin{quote}\begin{flushleft}
87 \fontsampleglyph{\AA}
88 \fontsampleglyph{\AE}
89 \fontsampleglyph{\L}
90 \fontsampleglyph{\O}
91 \fontsampleglyph{\OE}
92 \fontsampleglyph{\S}
93 \fontsampleglyph{\SS}
94 \fontsampleglyph{\_}
95 \fontsampleglyph{\aa}
96 \fontsampleglyph{\ae}

 97 %   \fontsampleglyph{\guillemotleft}
 98 %   \fontsampleglyph{\guillemotright}
 99 %   \fontsampleglyph{\guilsinglleft}
100 %   \fontsampleglyph{\guilsinglright}
101 \fontsampleglyph{\i}
102 \fontsampleglyph{\j}
103 \fontsampleglyph{\l}
104 \fontsampleglyph{\o}
105 \fontsampleglyph{\oe}
106 \fontsampleglyph{\pounds}
107 %   \fontsampleglyph{\quotedblbase}
108 %   \fontsampleglyph{\quotesinglbase}
109 \fontsampleglyph{\ss}
110 \fontsampleglyph{\{}
111 \fontsampleglyph{\}}
112 \fontsampleglyph{\$}
113 \end{flushleft}\end{quote}

114 }

115 \newcommand{\fontsampleglyph}[1]{%
116 \ifx#1\@undefined
117  {\typewriterfont\string#1}~is~undefined
118 \else
119  {\typewriterfont\string#1}~is~`#1'
120 \fi

121 }

\fontsampleaccents \fontsampleaccent A sample of accents.
122 \newcommand{\fontsampleaccents}{%
123 Some accents:
124 \begin{quote}\begin{flushleft}
125  \fontsampleaccent{\"} \\
126  \fontsampleaccent{\'} \\
127  \fontsampleaccent{\.} \\
128  \fontsampleaccent{\=} \\
129  \fontsampleaccent{\^} \\
130  \fontsampleaccent{\`} \\
131  \fontsampleaccent{\~} \\
132  \fontsampleaccent{\H} \\
133  \fontsampleaccent{\u} \\
134  \fontsampleaccent{\v} \\
135  \fontsampleaccent{\b} \\
136  \fontsampleaccent{\c} \\
137  \fontsampleaccent{\d}
138 \end{flushleft}\end{quote}

139 }

140 \newcommand{\fontsampleaccent}[1]{%
141 \makebox[2em][r]{\typewriterfont\string#1}
142 #1A#1C#1D#1E#1G#1I#1L#1N%
143 #1O#1R#1S#1T#1U#1Y#1Z%
144 #1a#1c#1d#1e#1g#1\i#1i#1l#1n%

145 #1o#1r#1s#1t#1u#1y#1z

146 }

\typewriterfont Not all sites have the T1 typewriter fonts, so we set the typewriter font to be a fixed font.

147 \DeclareFixedFont{\typewriterfont}
148 {\encodingdefault}{\ttdefault}{\mddefault}{\updefault}{10}

149 ⟨/package⟩