]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/tex/fonts.doc
release: 0.1.61
[lilypond.git] / Documentation / tex / fonts.doc
1 % -*-LaTeX-*-
2
3 \documentclass{article}
4 \def\kdots{,\ldots,}
5 \title{Not the Font-En-Tja font}
6 \author{HWN \& JCN} 
7 \begin{document}
8 \maketitle
9
10
11 \section{Introduction}
12
13 This document are some design notes of the Feta font, and other
14 symbols related to LilyPond.  Feta (not an abbreviation of
15 Font-En-Tja) is a font of music symbols.  All MetaFont sources are
16 original.  The symbols are modelled after various editions of music,
17 notably \begin{itemize} \item B\"arenreiter \item Hofmeister \item
18 Breitkopf \item Durand \& C'ie \end{itemize}
19
20 The best references on Music engraving are Wanske\cite{wanske} and
21 Ross\cite{ross} quite some of their insights were used.  Although it
22 is a matter of taste, I'd say that B\"arenreiter has the finest
23 typography of all.
24
25
26 \section{Bezier curves for slurs}
27
28 Objective:  slurs in music are curved objects designating that notes
29 should fluently bound.  They are drawn as smooth curves, with their
30 center thicker and the endings tapered.
31
32 There are some variants: the simplest slur shape only has the width as
33 parameter.  Then we give some suggestions for tuning the shapes.  The
34 simple slur algorithm is used for drawing ties as well.
35
36
37
38 \subsection{Simple slurs}
39
40 Long slurs are flat, whereas short slurs look like small circle arcs.
41 Details are given in Wanske\cite{ross} and Ross\cite{wanske}.  The
42 shape of a slur can be given as a Bezier curve with four control
43 points:
44
45 \begin{eqnarray*}
46   B(t) &=& (1-t)^3c_1 +3(1-t)^2tc_2 + 3(1-t)t^2c_3 + t^3c_4.
47 \end{eqnarray*}
48
49 We will assume that the slur connects two notes of the same
50 pitch.  Different slurs can be created by rotating the derived shape.
51 We will also assume that the slur has a vertical axis of symmetry
52 through its center.  The left point will be the origin.     So we have
53 the following equations for the control points $c_1\kdots c_4$.
54
55 \begin{eqnarray*}
56 c_1&=& (0,0)\\
57 c_2&=& (i, h)\\
58 c_3&=& (b-i, h)\\
59 c_4&=& (b, 0)
60 \end{eqnarray*}
61
62 The quantity $b$ is given, it is the width of the slur.  The
63 conditions on the shape of the slur for small and large $b$ transform
64 to
65 \begin{eqnarray*}
66  h \to h_{\infty} , &&\quad b \to \infty\\
67  h \approx r_{0} b, &&\quad b \to 0.
68 \end{eqnarray*}
69 To tackle  this, we  will  assume that $h   = F(b)$, for  some kind of
70 $F(\cdot)$.  One function that satisfies the above conditions is
71 $$
72 F(b) = h_{\infty} \frac{2}{\pi} \arctan \left( \frac{\pi r_0}{2
73 h_{\infty}} b \right).
74 $$
75
76 For satisfying results we choose $h_{\infty} = 2\cdot \texttt{interline}$
77 and $r_0 = \frac 13$.
78
79 \subsection{Height correction}
80
81 Aside from being a smooth curve, slurs should avoid crossing
82 enclosed notes and their stems.
83
84 An easy way to achieve this is to extend the slur's height,
85 so that the slur will curve just above any disturbing notes.
86
87 The parameter $i$ determines the flatness of the curve.  Satisfying
88 results have been obtained with $i = h$.
89
90 The formula can be generalised to allow for corrections in the shape, 
91 \begin{eqnarray*}
92 c_1&=& (0,0)\\
93 c_2&=& (i', h')\\
94 c_3&=& (b-i', h')\\
95 c_4&=& (b, 0)
96 \end{eqnarray*}
97 Where
98 $$
99 i' = h(b) (1 + i_{corr}), \quad h' = h(b) (1 + h_{corr}).
100 $$
101
102 The default values for these corrections are $0$.  A $h_{corr}$ that is
103 negative, makes the curve flatter in the center.  A $h_{corr}$ that is
104 positive make the curve higher. 
105
106 At every encompassed note's x position the difference $\delta _y$ 
107 between the slur's height and the note is calculated.  The greatest 
108 $\delta _y$ is used to calculate $h_{corr}$ is by lineair extrapolation.
109
110 However, this simple method produces satisfactory results only for 
111 small and symmetric disturbances.
112
113
114 \subsection{Tangent method correction}
115
116 A somewhat more elaborate\footnote{While staying in the realm 
117 of emperic computer science} way of having a slur avoid 
118 disturbing notes is by first defining the slur's ideal shape 
119 and then using the height correction.  The ideal shape of a 
120 slur can be guessed by calculating the tangents of the disturbing 
121 notes:
122 % a picture wouldn't hurt...
123 \begin{eqnarray*}
124   y_{disturb,l} &=& \rm{rc}_l x\\
125   y_{disturb,r} &=& \rm{rc}_r + c_{3,x},
126 \end{eqnarray*}
127 where
128 \begin{eqnarray*}
129   \rm{rc}_l &=& \frac{y_{disturb,l} - y_{encompass,1}}
130     {x_{disturb,l} - x_{encompass,1}}\dot x\\
131   \rm{rc}_r &=& \frac{y_{encompass,n} - y_{disturb,r}}
132     {x_{encompass,n} - x_{disturb,r}} \dot x + c_{3,x}.
133 \end{eqnarray*}
134
135 We assume that having the control points $c_2$ and $c_3$ located 
136 on tangent$_1$ and tangent$_2$ resp. 
137 % t: tangent
138 \begin{eqnarray*}
139   y_{tangent,l} &=& \alpha \rm{rc}_l x\\
140   y_{tangent,r} &=& \alpha \rm{rc}_r + c_{3,x}.
141 \end{eqnarray*}
142
143 Beautiful slurs have rather strong curvature at the extreme
144 control points.  That's why we'll have $\alpha > 1$.
145 Satisfactory resulsts have been obtained with
146 $$
147   \alpha \approx 2.4.
148 $$
149
150 The positions of control points $c_2$ and $c_3$ are obtained
151 by solving with the height-line
152 \begin{eqnarray*}
153   y_h &=& \rm{rc}_h + c_h.
154 \end{eqnarray*}
155
156 The top-line runs through the points disturb$_{left}$ and
157 disturb$_{right}$.  In the case that 
158 $$
159 z_{disturb,l} = z_{disturb,r},
160 $$
161 we'll have 
162 $$
163   \angle(y_{tangent,l},y_h) = \angle(y_{tangent,r},y_h).
164 $$
165
166
167
168 \section{Sizes}
169
170 Traditional engraving uses a set of 9 standardised sizes for Staffs
171 (running from 0 to 8).  
172
173 We have tried to measure these (helped by a magnifying glass), and
174 found the staffsizes in  table~\ref{fonts:staff-size}.  One should note that
175 these are estimates, so I think there could be a measuring error of ~
176 .5 pt.  Moreover [Ross] states that not all engravers use exactly
177 those sizes.
178
179 \begin{table}[h]
180   \begin{center}
181     \begin{tabular}{lll}
182 Staffsize       &Numbers                &Name\\
183 \hline\\
184 26.2pt  &No. 0\\
185 22.6pt  &No. 1          &Giant/English\\
186 21.3pt  &No. 2          &Giant/English\\
187 19.9pt  &No. 3          &Regular, Ordinary, Common\\
188 19.1pt  &No. 4          &Peter\\
189 17.1pt  &No. 5          &Large middle\\
190 15.9pt  &No. 6          &Small middle\\
191 13.7pt  &No. 7          &Cadenza\\
192 11.1pt  &No. 8          &Pearl\\
193
194     \end{tabular}
195     \caption{Foo}
196     \label{fonts:staff-size}
197   \end{center}
198 \end{table}
199
200 Ross states that the dies (the stamps to make the symbols) come in
201 12 different sizes.
202
203 \section{Beams}
204
205 \subsection{Slope}
206
207 Traditionally, beam slopes are computed by following a large and hairy
208 set of rules.  Some of these are talked-about in Wanske, a more
209 recipy-like description can be found in Ross.
210
211 There are some problems when trying to follow these rules:
212 \begin{itemize}
213
214 \item the set is not complete
215
216 \item they are not formulated as a general rule with exceptions, but
217 rather as a huge case of individual rules\cite{ross}
218
219 \item in some cases, the result is wrong or ugly (or both)
220
221 \item they try to solve a couple of problems at a time (e.g. Ross
222 handles ideal slope and slope-quantisation as a paired problem)
223 \end{itemize}
224 Reading Ross it is clear that the rules presented there are certainly
225 not the ultimate idea of what beam(slope)s should look like, but
226 rather a (very much) simplified hands-on recipy for a human engraver.
227
228 There are good reasons not to follow those rules:
229
230 \begin{itemize}
231 \item One cannot expect a human engraver to solve least-squares
232 problems for every beam
233   
234 \item A human engravers will allways trust themselves in judging the
235 outcome of the applied recipy.  If, in a complicated case, the result
236 "doesn't look good", they will ignore the rules and draw their own
237 beams, based on experience.
238
239 \item The exact rules probably even don't "really exsist" but in the
240 minds of good engravers, in the form of experience
241 \end{itemize}
242
243 We'll propose to do a least-squares solve.  This seems to be the best
244 way to calculate the slope for a computerised engraver such as Lily.
245
246 It would be nice to have some rules to catch and handle "ugly" cases,
247 though.  In general, the slope of the beam should mirror the pitches
248 of the notes.  If this "can't be done" because there simply is no
249 uniform "trend", it would probably be best to set the slope to zero.
250
251
252 \subsection{Quantising}
253
254 The beams should be prevented to conflict with the stafflines,
255 especially at small slopes.  Traditionally, poor printing techniques
256 imposed rather strict rules for quantisation.  In modern (post 1955)
257 music printing we see that quality has improved substantially and
258 obsoleted the technical justification for following some of these
259 strict rules, notably the avoiding of so-called wedges.
260
261
262
263 \bibliographystyle{plain}
264 \bibliography{engraving}
265
266
267
268 \end{document}