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