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