A font sampler

Alan Jeffrey

v0.09

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 \begin{document}
20 \maketitle
21 \fontfamily{\family}\selectfont
22 \fontencoding{T1}\selectfont\fontsample
23 \fontencoding{OT1}\selectfont\fontsample
24 \itshape
25 \fontencoding{T1}\selectfont\fontsample
26 \fontencoding{OT1}\selectfont\fontsample
27 \slshape
28 \fontencoding{T1}\selectfont\fontsample
29 \fontencoding{OT1}\selectfont\fontsample
30 \scshape
31 \fontencoding{T1}\selectfont\fontsample
32 \fontencoding{OT1}\selectfont\fontsample
33 \upshape\bfseries
34 \fontencoding{T1}\selectfont\fontsample
35 \fontencoding{OT1}\selectfont\fontsample
36 \itshape
37 \fontencoding{T1}\selectfont\fontsample
38 \fontencoding{OT1}\selectfont\fontsample
39 \slshape
40 \fontencoding{T1}\selectfont\fontsample
41 \fontencoding{OT1}\selectfont\fontsample
42 \scshape
43 \fontencoding{T1}\selectfont\fontsample
44 \fontencoding{OT1}\selectfont\fontsample
45 \end{document}

46 ⟨/document⟩

4 Font sample package

The fontsmpl package is a L^{A}TEX 2ε package.

47 ⟨∗package⟩

48 \NeedsTeXFormat{LaTeX2e}
49 \ProvidesPackage{fontsmpl}[1994/10/29 Font sample package]

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

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

55 }

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

56 \newcommand{\fontsampletext}{%
57 Some text:

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

81

82 \end{flushleft}\end{quote}

83 }

\fontsampleglyphs \fontsampleglyph A list of sample glyph commands.
84 \newcommand{\fontsampleglyphs}{%
85 Some glyphs:
86 \begin{quote}\begin{flushleft}
87  \fontsampleglyph{\#}
88  \fontsampleglyph{\$}
89  \fontsampleglyph{\%}
90  \fontsampleglyph{\&}
91  \fontsampleglyph{\AA}
92  \fontsampleglyph{\AE}
93  \fontsampleglyph{\DH}
94  \fontsampleglyph{\DJ}
95  \fontsampleglyph{\L}
96  \fontsampleglyph{\NG}
97  \fontsampleglyph{\OE}
98  \fontsampleglyph{\O}
99  \fontsampleglyph{\P}
100  \fontsampleglyph{\SS}
101  \fontsampleglyph{\S}
102  \fontsampleglyph{\TH}
103  \fontsampleglyph{\_}
104  \fontsampleglyph{\aa}
105  \fontsampleglyph{\ae}
106  \fontsampleglyph{\copyright}
107  \fontsampleglyph{\dag}
108  \fontsampleglyph{\ddag}
109  \fontsampleglyph{\dh}

110  \fontsampleglyph{\dj}
111  \fontsampleglyph{\dots}
112  \fontsampleglyph{\guillemotleft}
113  \fontsampleglyph{\guillemotright}
114  \fontsampleglyph{\guilsinglleft}
115  \fontsampleglyph{\guilsinglright}
116  \fontsampleglyph{\i}
117  \fontsampleglyph{\j}
118  \fontsampleglyph{\l}
119  \fontsampleglyph{\ng}
120  \fontsampleglyph{\oe}
121  \fontsampleglyph{\o}
122  \fontsampleglyph{\pounds}
123  \fontsampleglyph{\quotedblbase}
124  \fontsampleglyph{\quotesinglbase}
125  \fontsampleglyph{\ss}
126  \fontsampleglyph{\textasciicircum}
127  \fontsampleglyph{\textasciitilde}
128  \fontsampleglyph{\textbackslash}
129  \fontsampleglyph{\textbar}
130  \fontsampleglyph{\textbullet}
131  \fontsampleglyph{\textcompwordmark}
132  \fontsampleglyph{\textemdash}
133  \fontsampleglyph{\textendash}
134  \fontsampleglyph{\textexclamdown}
135  \fontsampleglyph{\textgreater}
136  \fontsampleglyph{\texthyphenchar}
137  \fontsampleglyph{\textless}
138  \fontsampleglyph{\textperiodcentered}
139  \fontsampleglyph{\textquestiondown}
140  \fontsampleglyph{\textquotedblleft}
141  \fontsampleglyph{\textquotedblright}
142  \fontsampleglyph{\textquotedbl}
143  \fontsampleglyph{\textquoteleft}
144  \fontsampleglyph{\textquoteright}
145  \fontsampleglyph{\textvisiblespace}
146  \fontsampleglyph{\th}
147  \fontsampleglyph{\{}
148  \fontsampleglyph{\}}
149 \end{flushleft}\end{quote}

150 }

151 \newcommand{\fontsampleglyph}[1]{%
152 \ifx#1\@undefined
153  {\typewriterfont\string#1}~is~undefined
154 \else
155  {\typewriterfont\string#1}~is~`#1'
156 \fi

157 }

\fontsampleaccents \fontsampleaccent A sample of accents.
158 \newcommand{\fontsampleaccents}{%
159 Some accents:
160 \begin{quote}\begin{flushleft}
161  \fontsampleaccent{\"} \\

162  \fontsampleaccent{\'} \\
163  \fontsampleaccent{\.} \\
164  \fontsampleaccent{\=} \\
165  \fontsampleaccent{\H} \\
166  \fontsampleaccent{\^} \\
167  \fontsampleaccent{\`} \\
168  \fontsampleaccent{\b} \\
169  \fontsampleaccent{\c} \\
170  \fontsampleaccent{\d} \\
171  \fontsampleaccent{\k} \\
172  \fontsampleaccent{\u} \\
173  \fontsampleaccent{\v} \\
174  \fontsampleaccent{\~}
175 \end{flushleft}\end{quote}

176 }

177 \newcommand{\fontsampleaccent}[1]{%
178 \makebox[1em][r]{\typewriterfont\string#1}
179 \makebox[15em][l]{%
180  #1A#1C#1D#1E#1G#1I#1L#1N%
181  #1O#1R#1S#1T#1U#1Y#1Z%
182  #1a#1c#1d#1e#1g#1\i#1i#1l#1n%
183  #1o#1r#1s#1t#1u#1y#1z%

184 } 185 }

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

186 \DeclareFixedFont{\typewriterfont}
187 {\encodingdefault}{\ttdefault}{\mddefault}{\updefault}{10}

188 ⟨/package⟩

\@changed@x@err Switch off the error message from missing glyphs.

189 \def\@changed@x@err#1{%
190 \textbf{?}\PackageInfo{fontsmpl}{%
191  Command \protect#1 undefined in encoding \f@encoding%

192 }% 193 }