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