summaryrefslogtreecommitdiff
path: root/fonts/frcursive/frcursive.dtx
blob: 40161ec74cca5a93043f0a7ac7ec573dc0973b1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage[latin1]{inputenc}
\usepackage{frcursive,url}
\title{French Cursive for \LaTeX}
\author{Emmanuel \textsc{Beffara}\\\url{manu@beffara.org}}
\date{version 1.2, February 2nd, 2004}
\begin{document}
\DocInput{frcursive.dtx}
\end{document}
%</driver>
% \fi
% \maketitle
%
% \section{Presentation}
%
% French Cursive is a cursive hand-writing font family. Its design is based on
% the French academic tradition for running-hand. The base shape is upright
% with lightly contrasted stems and hairlines. All lowercase letters are
% connected, but most uppercase are independent.
%   \vspace{-3ex}
% \begin{center}
%   \newcommand{\exmpl}[2]{%
%     #1&\cursive#2\relax The quick brown fox jumps over the lazy dog.}
%   \linespread{1.5}\selectfont
%   \begin{tabular}{ll}
%     style & example \\ \hline \noalign{\smallskip}
%     \exmpl{regular}{} \\
%     \exmpl{bold-extended}{\bfseries} \\
%     \exmpl{slanted}{\slshape} \\
%     \exmpl{calligraphic}{\calseries} \\
%     \exmpl{fixed-thickness}{\ftseries} \\
%     wide & \cursive\wideseries The quick brown fox jumps \dots \\
%     \exmpl{academic}{\acadshape}
%   \end{tabular}
% \end{center}
% The extra styles come with associated macros:
% \begin{center}
%   \begin{tabular}{lll}
%     style & environment & local macro \\ \hline
%     cursive & \texttt{cursive} & \texttt{\string\textcursive} \\
%     calligraphic & \texttt{calseries} & \texttt{\string\textcal} \\
%     fixed-thickness & \texttt{ftseries} & \texttt{\string\textft} \\
%     wide & \texttt{wideseries} & \texttt{\string\textwide} \\
%     academic & \texttt{acadshape} & \texttt{\string\textacad} \\
%   \end{tabular}
% \end{center}
%
% For a given design size, the choice was made to make the base height (1\,ex)
% equal to the one for Computer Modern faces, \mbox{i.e.} small letters like
% ``a'' have the same height in both fonts at 10pt (namely $155/36$ points).
% As you can see, the ascending and descending loops are larger than the
% largest letters in Computer Modern and other roman fonts. For this reason,
% the space between lines has to be augmented a lot. We must actually use a
% |\linespread| value of $3/2$ in paragraphs that contain cursive text.
%
% Inter-letter links are inserted using a complex ligature system. Since
% ligatures are incompatible with \TeX's way of composing accented letters,
% all accented letters have to be provided by the font itself, therefore the
% encoding used is T1. Though technically the font can be used in standard OT1
% encoding, this is only suitable if no accented character is to be used,
% therefore OT1 encoding is not the default.
%
% \section{Interface}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{frcursive}
  [2004/02/01 v1.2 support package for French Cursive]
%    \end{macrocode}
%
% \subsection{Package options}
%
% \begin{macro}{OT1}
% The default encoding used for the font is T1, but we provide the option
% ``OT1'' to use this encoding instead.
%    \begin{macrocode}
\newcommand{\frcursive@enc}{T1}
\DeclareOption{OT1}{%
  \renewcommand{\frcursive@enc}{OT1}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{default}
% By default we don't change the font for the whole document. However, one
% might want to typeset a whole text in French Cursive. For this purpose, we
% provide the option ``default''. We must delay the redefinition of the
% default face in order to take care of these encoding issues.
%    \begin{macrocode}
\newif\if@frcursive@default
\@frcursive@defaultfalse
\DeclareOption{default}{%
  \@frcursive@defaulttrue}
%    \end{macrocode}
% \end{macro}
%
% These are the only options we provide.
%    \begin{macrocode}
\ProcessOptions\relax
%    \end{macrocode}
%
% Now we can change fonts if asked for it.
%    \begin{macrocode}
\if@frcursive@default
\renewcommand{\rmdefault}{frc}
\linespread{1.5}
\RequirePackage[T1]{fontenc}
\fi
%    \end{macrocode}
%
%
% \subsection{Macros}
%
% \begin{macro}{\cursive}
% The main macro we define is obviously the one that switches to cursive font.
% What it has to do is change the font family and encoding, and also change
% the line spread, because letters in French Cursive are larger. We define
% this as an environment because it can be used either in plain \TeX\ style as
% |{\cursive |\emph{text}|}| or as a \LaTeX\ environment.
%    \begin{macrocode}
\newenvironment{cursive}{%
  \fontencoding{\frcursive@enc}%
  \fontfamily{frc}%
  \linespread{1.5}%
  \selectfont}{%
  \par}
%    \end{macrocode}
% For the sake of completeness, we provide the alternative form for short
% cursive texts as |\textcursive{|\emph{text}|}|:
%    \begin{macrocode}
\newcommand{\textcursive}[1]{{\cursive#1}}
%    \end{macrocode}
% However, take care that the effect of the |\linespread| macro only appears
% when changing paragraphs, which means that the |\par| must appear inside the
% group where |\cursive| is used. That is why we put it at the end of the
% |cursive| environment.
% \end{macro}
%
% \begin{macro}{\calseries}
% \begin{macro}{\textcal}
% One of the variants of the typeface is called ``calligraphic''. It is a
% series like ``medium'' and ``bold'', with strong stems and thing hairlines.
% We thus provide a macro to use this series. Using this macro when not using
% the \texttt{frc} family will not work.
%    \begin{macrocode}
\newenvironment{calseries}{\fontseries{cal}\selectfont}{}
%    \end{macrocode}
% We also provide a variant of this macro in the style of |\textbf|:
%    \begin{macrocode}
\newcommand{\textcal}[1]{{\calseries#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\ftseries}
% \begin{macro}{\textft}
% Another variant is called ``fixed-thickness'', it is also a series like
% ``medium'' and ``bold'', but with a constant line thickness We provide a
% macro to use this series. As before, using this macro when not using the
% \texttt{frc} family will not work.
%    \begin{macrocode}
\newenvironment{ftseries}{\fontseries{ft}\selectfont}{}
\newcommand{\textft}[1]{{\ftseries#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\wideseries}
% \begin{macro}{\textwide}
% There is a variant with wide inter-letter links, we declare it a as a new
% series called ``wide''. This is also specific to French Cursive.
%    \begin{macrocode}
\newenvironment{wideseries}{\fontseries{w}\selectfont}{}
\newcommand{\textwide}[1]{{\wideseries#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\acadshape}
% \begin{macro}{\textacad}
% In the same spirit, we now define a pair of macros for accessing the
% ``academic'' shape, the one with integer height ratios between base height,
% ascenders and descenders. This also will not work with other font families.
%    \begin{macrocode}
\newenvironment{acadshape}{\fontshape{ac}\selectfont}{}
\newcommand{\textacad}[1]{{\acadshape#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Workbook lines}
%
% The following macro is an experimental mechanism for drawing horizontal
% lines behind cursive text, in the style of children's workbooks.
% \begin{center}
%   \cursive\acadshape
%   \seyes{Here is an example of its behaviour.}
% \end{center}
% I took this idea from C. Verchery's typeface family Plum. His approach was
% to create a version (named Seyes) with the lines in them. Although this
% would be rather trivial to implement with Metafont, it would not work with
% \TeX, in particular because of its handling of spaces. Therefore my approach
% is to put the rules using \TeX\ commands, which also allows, for instance,
% for changing their color independently of the text.
%
% \begin{macro}{\seyesThickness}
% The default thickness of the rules will be a twentieth of a millimeter,
% which can be changed be redefining the |\seyesThickness| length:
%    \begin{macrocode}
\newlength{\seyesThickness}
\setlength{\seyesThickness}{0.05mm}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\seyesDefault}
% The default code for changing colors is contained in |\seyesDefault|, which
% is empty by default. One can redefine it for instance to |\color{blue}| to
% make the rules blue.
%    \begin{macrocode}
\newcommand{\seyesDefault}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\seyes}
% The main macro thus takes the text as argument and behaves as a box with
% this text in it and the lines behind. The width of the box is the one of the
% text, while its height and depth are the maximal ones in the font. We
% actually take reference characters to define the height of each line, so
% that it works with any font. However the result is strange when not using
% the academic shape of French Cursive.
%    \begin{macrocode}
\newsavebox{\seyes@box}
\newlength{\seyes@ln}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand{\seyes}[2][\seyesDefault]{%
  \mbox{%
    \sbox\seyes@box{#2}%
    #1%
    \raisebox{-0.5\seyesThickness}{\mbox{%
      \rlap{\rule{\wd\seyes@box}{\seyesThickness}}%
      \settoheight\seyes@ln{a}%
      \rlap{\rule[\seyes@ln]{\wd\seyes@box}{\seyesThickness}}%
      \settoheight\seyes@ln{d}%
      \rlap{\rule[\seyes@ln]{\wd\seyes@box}{\seyesThickness}}%
      \settoheight\seyes@ln{b}%
      \rlap{\rule[\seyes@ln]{\wd\seyes@box}{\seyesThickness}}%
      \settodepth\seyes@ln{p}%
      \rlap{\rule[-\seyes@ln]{\wd\seyes@box}{\seyesThickness}}%
      \settodepth\seyes@ln{g}%
      \rlap{\rule[-\seyes@ln]{\wd\seyes@box}{\seyesThickness}}%
    }}%
    \usebox\seyes@box}}
%    \end{macrocode}
% \end{macro}
%
% \Finale